mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
list: introduce LIST_HEAD_GUARDED
Introduce LIST_HEAD_GUARDED(name, lock) to define a struct list_head annotated with __guarded_by(lock). This provides a convenient shorthand for defining lock-protected list heads and allows compiler context analysis to validate accesses to the list against the associated lock. The new helper also reduces boilerplate and improves consistency across callers that annotate struct list_head objects with __guarded_by(). This is a preparatory change for subsequent patches that annotate LIST_HEAD() instances with their protecting lock. Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
737a3b5352
commit
a760903362
|
|
@ -33,6 +33,14 @@
|
|||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
/**
|
||||
* LIST_HEAD_GUARDED - define a &struct list_head annotated with __guarded_by()
|
||||
* @name: name of the list_head
|
||||
* @lock: lock protecting the list
|
||||
*/
|
||||
#define LIST_HEAD_GUARDED(name, lock) \
|
||||
__guarded_by(&(lock)) LIST_HEAD(name)
|
||||
|
||||
/**
|
||||
* INIT_LIST_HEAD - Initialize a list_head structure
|
||||
* @list: list_head structure to be initialized.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user