Skip to content

Commit 32fad12

Browse files
committed
slab: Explain why SLAB_DESTROY_BY_RCU reference before locking
It is not obvious to the casual user why it is absolutely necessary to acquire a reference to a SLAB_DESTROY_BY_RCU structure before acquiring a lock in that structure. Therefore, add a comment explaining this point. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Hyeonggon Yoo <[email protected]> Cc: <[email protected]>
1 parent a442673 commit 32fad12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/linux/slab.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
* rcu_read_lock before reading the address, then rcu_read_unlock after
7575
* taking the spinlock within the structure expected at that address.
7676
*
77+
* Note that it is not possible to acquire a lock within a structure
78+
* allocated with SLAB_DESTROY_BY_RCU without first acquiring a reference
79+
* as described above. The reason is that SLAB_DESTROY_BY_RCU pages are
80+
* not zeroed before being given to the slab, which means that any locks
81+
* must be initialized after each and every kmem_struct_alloc().
82+
*
7783
* Note that SLAB_TYPESAFE_BY_RCU was originally named SLAB_DESTROY_BY_RCU.
7884
*/
7985
/* Defer freeing slabs to RCU */

0 commit comments

Comments
 (0)