linux/include
mochel@digitalimplant.org 9a19fea436 [PATCH] Add initial implementation of klist helpers.
This klist interface provides a couple of structures that wrap around
struct list_head to provide explicit list "head" (struct klist) and
list "node" (struct klist_node) objects. For struct klist, a spinlock
is included that protects access to the actual list itself. struct
klist_node provides a pointer to the klist that owns it and a kref
reference count that indicates the number of current users of that node
in the list.

The entire point is to provide an interface for iterating over a list
that is safe and allows for modification of the list during the
iteration (e.g. insertion and removal), including modification of the
current node on the list.

It works using a 3rd object type - struct klist_iter - that is declared
and initialized before an iteration. klist_next() is used to acquire the
next element in the list. It returns NULL if there are no more items.
This klist interface provides a couple of structures that wrap around
struct list_head to provide explicit list "head" (struct klist) and
list "node" (struct klist_node) objects. For struct klist, a spinlock
is included that protects access to the actual list itself. struct
klist_node provides a pointer to the klist that owns it and a kref
reference count that indicates the number of current users of that node
in the list.

The entire point is to provide an interface for iterating over a list
that is safe and allows for modification of the list during the
iteration (e.g. insertion and removal), including modification of the
current node on the list.

It works using a 3rd object type - struct klist_iter - that is declared
and initialized before an iteration. klist_next() is used to acquire the
next element in the list. It returns NULL if there are no more items.
Internally, that routine takes the klist's lock, decrements the reference
count of the previous klist_node and increments the count of the next
klist_node. It then drops the lock and returns.

There are primitives for adding and removing nodes to/from a klist.
When deleting, klist_del() will simply decrement the reference count.
Only when the count goes to 0 is the node removed from the list.
klist_remove() will try to delete the node from the list and block
until it is actually removed. This is useful for objects (like devices)
that have been removed from the system and must be freed (but must wait
until all accessors have finished).

Internally, that routine takes the klist's lock, decrements the reference
count of the previous klist_node and increments the count of the next
klist_node. It then drops the lock and returns.

There are primitives for adding and removing nodes to/from a klist.
When deleting, klist_del() will simply decrement the reference count.
Only when the count goes to 0 is the node removed from the list.
klist_remove() will try to delete the node from the list and block
until it is actually removed. This is useful for objects (like devices)
that have been removed from the system and must be freed (but must wait
until all accessors have finished).

Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

diff -Nru a/include/linux/klist.h b/include/linux/klist.h
2005-06-20 15:15:14 -07:00
..
acpi Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
asm-alpha [PATCH] AGP fix for Xen VMM 2005-06-07 12:35:43 -07:00
asm-arm Merge with ../linux-2.6-smp 2005-06-19 19:26:54 +01:00
asm-arm26 [PATCH] Remove obsolete HAVE_ARCH_GET_SIGNAL_TO_DELIVER? 2005-06-12 20:43:21 -07:00
asm-cris [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-frv [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-generic [PATCH] ppc32: platform-specific functions missing from kallsyms. 2005-05-05 16:36:31 -07:00
asm-h8300 [PATCH] h8300 build error fix 2005-06-06 14:42:23 -07:00
asm-i386 Merge of master.kernel.org:/pub/scm/linux/kernel/git/davej/agpgart 2005-06-07 13:41:30 -07:00
asm-ia64 [PATCH] ia64: fix floating-point preemption problem 2005-06-08 16:21:14 -07:00
asm-m32r [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-m68k [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-m68knommu [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-mips [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-parisc [PATCH] make some things static 2005-05-05 16:36:47 -07:00
asm-ppc Merge with master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6.git 2005-06-18 08:36:46 +01:00
asm-ppc64 [PATCH] ppc64: Fix PER_LINUX32 behaviour 2005-06-08 16:24:15 -07:00
asm-s390 [PATCH] s390: uml ptrace fixes 2005-06-04 17:13:00 -07:00
asm-sh [PATCH] sh: PREEMPT_ACTIVE fix 2005-05-28 16:46:13 -07:00
asm-sh64 [PATCH] sh: PREEMPT_ACTIVE fix 2005-05-28 16:46:13 -07:00
asm-sparc [PATCH] sparc32: silence access_ok() warnings 2005-06-08 16:21:13 -07:00
asm-sparc64 [PATCH] AGP fix for Xen VMM 2005-06-07 12:35:43 -07:00
asm-um [PATCH] uml: remove jail mode + other leftovers 2005-05-28 16:46:14 -07:00
asm-v850 [PATCH] asm/signal.h unification 2005-05-04 07:33:15 -07:00
asm-x86_64 [PATCH] AGP fix for Xen VMM 2005-06-07 12:35:43 -07:00
linux [PATCH] Add initial implementation of klist helpers. 2005-06-20 15:15:14 -07:00
math-emu Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
media [PATCH] dvb: modified dvb_register_adapter() to avoid kmalloc/kfree 2005-05-17 07:59:33 -07:00
mtd Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
net [PKT_SCHED]: Generic queue management interface for qdiscs using internal skb queues 2005-06-18 22:57:26 -07:00
pcmcia Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
rxrpc Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
scsi Automatic merge of ../scsi-misc-2.6-old/ 2005-05-26 14:14:55 -04:00
sound Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
video [PATCH] Clean-up and bug fix for tdfxfb framebuffer size detection 2005-05-01 08:59:25 -07:00