login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
September
»
4
Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Oren Laadan
Subject:
Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects
Date: Thursday, September 4, 2008 - 7:23 am
Louis Rilling wrote:
quoted text
> On Thu, Sep 04, 2008 at 04:05:22AM -0400, Oren Laadan wrote: >> Infrastructure to handle objects that may be shared and referenced by >> multiple tasks or other objects, e..g open files, memory address space >> etc. >> >> The state of shared objects is saved once. On the first encounter, the >> state is dumped and the object is assigned a unique identifier and also >> stored in a 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. >> > > [...] > >> diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c >> new file mode 100644 >> index 0000000..442b08c >> --- /dev/null >> +++ b/checkpoint/objhash.c >> @@ -0,0 +1,205 @@ >> +/* >> + * Checkpoint-restart - object hash infrastructure to manage shared objects >> + * >> + * Copyright (C) 2008 Oren Laadan >> + * >> + * This file is subject to the terms and conditions of the GNU General Public >> + * License. See the file COPYING in the main directory of the Linux >> + * distribution for more details. >> + */ >> + >> +#include <linux/kernel.h> >> +#include <linux/file.h> >> +#include <linux/hash.h> >> +#include <linux/ckpt.h> >> + >> +struct cr_objref { >> + int objref; >> + void *ptr; >> + unsigned short type; >> + unsigned short flags; >> + struct hlist_node hash; >> +}; >> + >> +struct cr_objhash { >> + struct hlist_head *head; >> + int objref_index; >> +}; >> + >> +#define CR_OBJHASH_NBITS 10 >> +#define CR_OBJHASH_TOTAL (1UL << CR_OBJHASH_NBITS - 1) > > Why -1? This makes a total number of 512 entries, which will break below with > hashes in range 0..1023.
Ugh !!! Was fixed and tested, but sneaked back in :( Thanks for spotting, will resend the patchset. Oren.
quoted text
> >> + >> +static void cr_obj_ref_drop(struct cr_objref *obj) >> +{ >> + switch (obj->type) { >> + case CR_OBJ_FILE: >> + fput((struct file *) obj->ptr); >> + break; >> + default: >> + BUG(); >> + } >> +} >> + >> +static void cr_obj_ref_grab(struct cr_objref *obj) >> +{ >> + switch (obj->type) { >> + case CR_OBJ_FILE: >> + get_file((struct file *) obj->ptr); >> + break; >> + default: >> + BUG(); >> + } >> +} >> + >> +static void cr_objhash_clear(struct cr_objhash *objhash) >> +{ >> + struct hlist_head *h = objhash->head; >> + struct hlist_node *n, *t; >> + struct cr_objref *obj; >> + int i; >> + >> + for (i = 0; i < CR_OBJHASH_TOTAL; i++) { >> + hlist_for_each_entry_safe(obj, n, t, &h[i], hash) { >> + cr_obj_ref_drop(obj); >> + kfree(obj); >> + } >> + } >> +} >> + >> +void cr_objhash_free(struct cr_ctx *ctx) >> +{ >> + struct cr_objhash *objhash = ctx->objhash; >> + >> + if (objhash) { >> + cr_objhash_clear(objhash); >> + kfree(objhash->head); >> + kfree(ctx->objhash); >> + ctx->objhash = NULL; >> + } >> +} >> + >> +int cr_objhash_alloc(struct cr_ctx *ctx) >> +{ >> + struct cr_objhash *objhash; >> + struct hlist_head *head; >> + >> + objhash = kzalloc(sizeof(*objhash), GFP_KERNEL); >> + if (!objhash) >> + return -ENOMEM; >> + head = kzalloc(CR_OBJHASH_TOTAL * sizeof(*head), GFP_KERNEL); > > 512 entries allocated > >> + if (!head) { >> + kfree(objhash); >> + return -ENOMEM; >> + } >> + >> + objhash->head = head; >> + objhash->objref_index = 1; >> + >> + ctx->objhash = objhash; >> + return 0; >> +} >> + >> +static struct cr_objref *cr_obj_find_by_ptr(struct cr_ctx *ctx, void *ptr) >> +{ >> + struct hlist_head *h; >> + struct hlist_node *n; >> + struct cr_objref *obj; >> + >> + h = &ctx->objhash->head[hash_ptr(ptr, CR_OBJHASH_NBITS)]; > > access to entries 0..1023 > > Louis >
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[RFC v3][PATCH 0/9] Kernel based checkpoint/restart
, Oren Laadan
, (Thu Sep 4, 12:57 am)
[RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, sys_r ...
, Oren Laadan
, (Thu Sep 4, 1:02 am)
[RFC v3][PATCH 2/9] General infrastructure for checkpoint ...
, Oren Laadan
, (Thu Sep 4, 1:02 am)
[RFC v3][PATCH 3/9] x86 support for checkpoint/restart
, Oren Laadan
, (Thu Sep 4, 1:03 am)
[RFC v3][PATCH 4/9] Memory management (dump)
, Oren Laadan
, (Thu Sep 4, 1:03 am)
[RFC v3][PATCH 5/9] Memory managemnet (restore)
, Oren Laadan
, (Thu Sep 4, 1:04 am)
[RFC v3][PATCH 6/9] Checkpoint/restart: initial documentation
, Oren Laadan
, (Thu Sep 4, 1:04 am)
[RFC v3][PATCH 7/9] Infrastructure for shared objects
, Oren Laadan
, (Thu Sep 4, 1:05 am)
[RFC v3][PATCH 8/9] File descriprtors (dump)
, Oren Laadan
, (Thu Sep 4, 1:05 am)
[RFC v3][PATCH 9/9] File descriprtors (restore)
, Oren Laadan
, (Thu Sep 4, 1:06 am)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Cedric Le Goater
, (Thu Sep 4, 1:37 am)
Re: [RFC v3][PATCH 2/9] General infrastructure for checkpo ...
, Louis Rilling
, (Thu Sep 4, 2:12 am)
Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects
, Louis Rilling
, (Thu Sep 4, 2:38 am)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Louis Rilling
, (Thu Sep 4, 2:47 am)
Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects
, Oren Laadan
, (Thu Sep 4, 7:23 am)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Serge E. Hallyn
, (Thu Sep 4, 7:42 am)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Oren Laadan
, (Thu Sep 4, 7:43 am)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Dave Hansen
, (Thu Sep 4, 8:01 am)
Re: [RFC v3][PATCH 2/9] General infrastructure for checkpo ...
, Serge E. Hallyn
, (Thu Sep 4, 9:00 am)
Re: [RFC v3][PATCH 2/9] General infrastructure for checkpo ...
, Serge E. Hallyn
, (Thu Sep 4, 9:03 am)
Re: [RFC v3][PATCH 2/9] General infrastructure for checkpo ...
, Dave Hansen
, (Thu Sep 4, 9:09 am)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Oren Laadan
, (Thu Sep 4, 10:32 am)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Dave Hansen
, (Thu Sep 4, 11:08 am)
Re: [RFC v3][PATCH 7/9] Infrastructure for shared objects
, Dave Hansen
, (Thu Sep 4, 11:14 am)
Re: [RFC v3][PATCH 4/9] Memory management (dump)
, Dave Hansen
, (Thu Sep 4, 11:25 am)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Dave Hansen
, (Thu Sep 4, 11:41 am)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Serge E. Hallyn
, (Thu Sep 4, 1:37 pm)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Oren Laadan
, (Thu Sep 4, 2:05 pm)
Re: [RFC v3][PATCH 1/9] Create syscalls: sys_checkpoint, s ...
, Serge E. Hallyn
, (Thu Sep 4, 3:03 pm)
Re: [RFC v3][PATCH 4/9] Memory management (dump)
, Oren Laadan
, (Sat Sep 6, 6:54 pm)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Oren Laadan
, (Sat Sep 6, 8:09 pm)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Oren Laadan
, (Sat Sep 6, 9:52 pm)
Re: [Devel] Re: [RFC v3][PATCH 1/9] Create syscalls: sys_c ...
, Andrey Mirkin
, (Mon Sep 8, 8:02 am)
Re: [RFC v3][PATCH 4/9] Memory management (dump)
, Dave Hansen
, (Mon Sep 8, 8:55 am)
Re: [Devel] Re: [RFC v3][PATCH 1/9] Create syscalls: sys_c ...
, Cedric Le Goater
, (Mon Sep 8, 9:07 am)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Dave Hansen
, (Mon Sep 8, 9:49 am)
Re: [RFC v3][PATCH 8/9] File descriprtors (dump)
, Dave Hansen
, (Mon Sep 8, 9:57 am)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Oren Laadan
, (Mon Sep 8, 11:01 pm)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Dave Hansen
, (Wed Sep 10, 2:42 pm)
Cleanups for: [PATCH 5/9] Memory managemnet (restore)
, Dave Hansen
, (Wed Sep 10, 3:00 pm)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Oren Laadan
, (Thu Sep 11, 12:37 am)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Serge E. Hallyn
, (Thu Sep 11, 8:38 am)
Re: [RFC v3][PATCH 5/9] Memory managemnet (restore)
, Dave Hansen
, (Fri Sep 12, 9:34 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Michael Trimarchi
Re: [PATCH] VFS: make file->f_pos access atomic on 32bit arch
Miklos Szeredi
[patch 14/15] vfs: more path_permission() conversions
Serge E. Hallyn
Re: [RFC v5][PATCH 7/8] Infrastructure for shared objects
Bernd Schmidt
Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3
Takashi Iwai
[PATCH 2/2] input: Add LED support to Synaptics device
git
:
Junio C Hamano
Re: mingw, windows, crlf/lf, and git
Eyvind Bernhardsen
Re: Where has "git ls-remote" reference pattern matching gone?
Shawn O. Pearce
Re: Switching from CVS to GIT
Todd Zullinger
Re: [PATCH 2/2] send-email: rfc2047-quote subject lines with non-ascii characters
Santi Béjar
Re: How to use git-fmt-merge-msg?
linux-netdev
:
Ramkrishna Vepa
[net-2.6 PATCH 1/10] Neterion: New driver: Driver help file
Mark Anthony
invitation / inquiry
Ingo Molnar
Re: [PATCH 08/16] dma-debug: add core checking functions
David Miller
Re: [PATCH 1/3] f_phonet: dev_kfree_skb instead of dev_kfree_skb_any in TX callback
Sascha Hauer
[PATCH 03/12] fec: do not typedef struct types
git-commits-head
:
Linux Kernel Mailing List
amba: struct device - replace bus_id with dev_name(), dev_set_name()
Linux Kernel Mailing List
MIPS: Yosemite: Convert SMP startup lock to arch spinlock.
Linux Kernel Mailing List
ARM: S5PC100: IRQ and timer
Linux Kernel Mailing List
davinci: edma: clear interrupt status for interrupt enabled channels only
Linux Kernel Mailing List
x86, mm, kprobes: fault.c, simplify notify_page_fault()
openbsd-misc
:
Daniel A. Ramaley
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Matthias Kilian
Re: can't get vesa @ 1280x800 or nv
Tobias Ulmer
Re: Problem after upgrade 4.5 to 4.6: ERR M
Philip Guenther
Re: SIGCHLD and libpthread.so
J.C. Roberts
Re: [semi-OT] Can anyone recommend an OpenBSD-compatible colour laser printer?
Colocation donated by:
Syndicate