[CRIU] [PATCH cr] [RFC] pstree: simplify access to pid, real_pid, born_sid

Cyrill Gorcunov gorcunov at openvz.org
Fri Jun 1 07:45:43 EDT 2012


On Fri, Jun 01, 2012 at 03:39:05PM +0400, Andrew Vagin wrote:
> On Fri, Jun 01, 2012 at 03:33:56PM +0400, Andrey Vagin wrote:
> > 
> > New version of pstree_item looks like:
> Sorry, here is the correct struct pstree_item:
>   struct pstree_item {
>          struct list_head        list;
>          union {
>                 struct pid {
>                         u32 real_pid;
>                         u32 pid;
>                 } cpt_pid;      /* leader pid */
>                 struct {
>                         union {
>                                 u32 born_sid;
>                                 u32 real_pid;
>                         };
>                         u32 pid;
>                 };
>          };
>          struct pstree_item      *parent;
> 
> > In this case we can use pi->pid instead of pi->pid.pid and so on...

OK, as I said it looks reasonable to me, but Andrew could we make it
rather as

struct pstree_item {
	struct list_head        list;
	struct pstree_item      *parent;
	union {
		struct {
			u32	pid;
			u32	real_pid;
		} cpt_pid;	/* leader pid */
		struct {
			u32	pid;
			union {
				u32 real_pid;
				u32 born_sid;
			};
		};
	};
};

This will guarantee that "pid","real_pid", members will be at same
memory addess for both unions, and I suspect it might be a good thing.

	Cyrill


More information about the CRIU mailing list