1. 21 1月, 2009 1 次提交
    • J
      klist.c: bit 0 in pointer can't be used as flag · c0e69a5b
      Jesper Nilsson 提交于
      The commit a1ed5b0c
      (klist: don't iterate over deleted entries) introduces use of the
      low bit in a pointer to indicate if the knode is dead or not,
      assuming that this bit is always free.
      
      This is not true for all architectures, CRIS for example may align data
      on byte borders.
      
      The result is a bunch of warnings on bootup, devices not being
      added correctly etc, reported by Hinko Kocevar <hinko.kocevar@cetrtapot.si>:
      
      ------------[ cut here ]------------
      WARNING: at lib/klist.c:62 ()
      Modules linked in:
      
      Stack from c1fe1cf0:
             c01cc7f4 c1fe1d11 c000eb4e c000e4de 00000000 00000000 c1f4f78f c1f50c2d
             c01d008c c1fdd1a0 c1fdd1a0 c1fe1d38 c0192954 c1fe0000 00000000 c1fe1dc0
             00000002 7fffffff c1fe1da8 c0192d50 c1fe1dc0 00000002 7fffffff c1ff9fcc
      Call Trace: [<c000eb4e>] [<c000e4de>] [<c0192954>] [<c0192d50>] [<c001d49e>] [<c000b688>] [<c0192a3c>]
             [<c000b63e>] [<c000b63e>] [<c001a542>] [<c00b55b0>] [<c00411c0>] [<c00b559c>] [<c01918e6>] [<c0191988>]
             [<c01919d0>] [<c00cd9c8>] [<c00cdd6a>] [<c0034178>] [<c000409a>] [<c0015576>] [<c0029130>] [<c0029078>]
             [<c0029170>] [<c0012336>] [<c00b4076>] [<c00b4770>] [<c006d6e4>] [<c006d974>] [<c006dca0>] [<c0028d6c>]
             [<c0028e12>] [<c0006424>] <4>---[ end trace 4eaa2a86a8e2da22 ]---
      ------------[ cut here ]------------
      Repeat ad nauseam.
      
      Wed, Jan 14, 2009 at 12:11:32AM +0100, Bastien ROUCARIES wrote:
      > Perhaps using a pointerhackalign trick on this structure where
      > #define pointerhackalign(x) __attribute__ ((aligned (x)))
      > and declare
      > struct klist_node {
      > ...
      > }  pointerhackalign(2);
      >
      > Because  __attribute__ ((aligned (x))) could only increase alignment
      > it will safe to do that and serve as documentation purpose :)
      
      That works, but we need to do it not for the struct klist_node,
      but for the struct we insert into the void * in klist_node,
      which is struct klist.
      
      Reported-by: Hinko Kocevar <hinko.kocevar@cetrtapot.si
      Cc: Bastien ROUCARIES <roucaries.bastien@gmail.com>
      Signed-off-by: NJesper Nilsson <jesper.nilsson@axis.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c0e69a5b
  2. 07 1月, 2009 1 次提交
  3. 09 10月, 2008 1 次提交
    • T
      klist: don't iterate over deleted entries · a1ed5b0c
      Tejun Heo 提交于
      A klist entry is kept on the list till all its current iterations are
      finished; however, a new iteration after deletion also iterates over
      deleted entries as long as their reference count stays above zero.
      This causes problems for cases where there are users which iterate
      over the list while synchronized against list manipulations and
      natuarally expect already deleted entries to not show up during
      iteration.
      
      This patch implements dead flag which gets set on deletion so that
      iteration can skip already deleted entries.  The dead flag piggy backs
      on the lowest bit of knode->n_klist and only visible to klist
      implementation proper.
      
      While at it, drop klist_iter->i_head as it's redundant and doesn't
      offer anything in semantics or performance wise as klist_iter->i_klist
      is dereferenced on every iteration anyway.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Jens Axboe <jens.axboe@oracle.com>
      Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
      a1ed5b0c
  4. 01 5月, 2008 3 次提交
  5. 08 9月, 2005 1 次提交
  6. 06 9月, 2005 1 次提交
  7. 21 6月, 2005 2 次提交
    • M
      [PATCH] add klist_node_attached() to determine if a node is on a list or not. · 8b0c250b
      mochel@digitalimplant.org 提交于
      Signed-off-by: NPatrick Mochel <mochel@digitalimplant.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      diff -Nru a/include/linux/klist.h b/include/linux/klist.h
      8b0c250b
    • M
      [PATCH] Add initial implementation of klist helpers. · 9a19fea4
      mochel@digitalimplant.org 提交于
      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: NPatrick Mochel <mochel@digitalimplant.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      diff -Nru a/include/linux/klist.h b/include/linux/klist.h
      9a19fea4