[Devel] Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects

Dave Hansen dave at linux.vnet.ibm.com
Thu Sep 4 11:14:22 PDT 2008


On Thu, 2008-09-04 at 04:05 -0400, Oren Laadan wrote:
> +=== Shared resources (objects)
> +
> +Many resources used by tasks may be shared by more than one task (e.g.
> +file descriptors, memory address space, etc), or even have multiple
> +references from other resources (e.g. a single inode that represents
> +two ends of a pipe).
> +
> +Clearly, the state of shared objects need only be saved once, even if
> +they occur multiple times. We use a hash table (ctx->objhash) to keep
> +track of shared objects in the following manner.
> +
> +On the first encounter, the state is dumped and the object is assigned
> +a unique identifier and also stored in the hash table (indexed by its
> +physical kenrel address). From then on the object will be found in the
> +hash and only its identifier is saved.
> +
> +On restart the identifier is looked up in the hash table; if not found
> +then the state is read, the object is created, and added to the hash
> +table (this time indexed by its identifier). Otherwise, the object in
> +the hash table is used.
> +
> +The interface for the hash table is the following:
> +
> +int cr_obj_get_by_ptr(struct cr_ctx *ctx, void *ptr, unsigned short type);
> +  [checkpoint] find the unique identifier - object reference (objref)
> +  - of the object that is pointer to by ptr (or 0 if not found).
> +
> +int cr_obj_add_ptr(struct cr_ctx *ctx, void *ptr, int *objref,
> +                  unsigned short type, unsigned short flags);
> +  [checkpoint] add the object pointed to by ptr to the hash table if
> +  it isn't already there, and fill its unique identifier (objref); will
> +  return 0 if already found in the has, or 1 otherwise.
> +
> +void *cr_obj_get_by_ref(struct cr_ctx *ctx, int objref, unsigned short type);
> +  [restart] return the pointer to the object whose unique identifier
> +  is equal to objref.
> +
> +int cr_obj_add_ref(struct cr_ctx *ctx, void *ptr, int objref,
> +                  unsigned short type, unsigned short flags);
> +  [restart] add the object with unique identifier objref, pointed to by
> +  ptr to the hash table if it isn't already there; will return 0 if
> +  already found in the has, or 1 otherwise.

Once you get to the point of putting function prototypes in
Documentation/, it's probably a good time to start using kerneldocs. :)

-- Dave

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list