Harden list_for_each_entry_rcu() and family
Subsystems (12)
cover Harden list_for_each_entry_rcu() and family
Hi,
Please consider this as an RFC / proof-of-concept to gather some feedback. This series aims to provide lockdep checking to RCU list macros.
RCU has a number of primitives for "consumption" of an RCU protected pointer. Most of the time, these consumers make sure that such accesses are under a RCU reader-section (such as rcu_dereference{,sched,bh} or under a lock, such as with rcu_dereference_protected()).
However, there are other ways to consume RCU pointers, such as by list_for_each_enry_rcu or hlist_for_each_enry_rcu. Unlike the rcu_dereference family, these consumers do no lockdep checking at all. And with the growing number of RCU list uses, it is possible for bugs to creep in and go unnoticed which lockdep checks can catch.
Since RCU consolidation efforts last year, the different traditional RCU flavors (preempt, bh, sched) are all consolidated. In other words, any of these flavors can cause a reader section to occur and all of them must cease before the reader section is considered to be unlocked.
Now, the list_for_each_entry_rcu and family are different from the rcu_dereference family in that, there is no _bh or _sched version of this macro. They are used under many different RCU reader flavors, and also SRCU. This series adds a new internal function rcu_read_lock_any_held() which checks if any reader section is active at all, when these macros are called. If no reader section exists, then the optional fourth argument to list_for_each_entry_rcu() can be a lockdep expression which is evaluated (similar to how rcu_dereference_check() works).
The optional argument trick to list_for_each_entry_rcu() can also be used in the future to possibly remove rcu_dereference_{,bh,sched}_protected() API and we can pass an optional lockdep expression to rcu_dereference() itself. Thus eliminating 3 more RCU APIs.
Note that some list macro wrappers already do their own lockdep checking in the caller side. These can be eliminated in favor of the built-in lockdep checking in the list macro that this series adds. For example, workqueue code has a assert_rcu_or_wq_mutex() function which is called in for_each_wq(). This series replaces that in favor of the built-in one.
Also in the future, we can extend these checks to list_entry_rcu() and other list macros as well.
Joel Fernandes (Google) (6):
rcu: Add support for consolidated-RCU reader checking
ipv4: add lockdep condition to fix for_each_entry driver/core: Convert to use built-in RCU list checking
workqueue: Convert for_each_wq to use built-in list check x86/pci: Pass lockdep condition to pcm_mmcfg_list iterator
acpi: Use built-in RCU list checking for acpi_ioremaps list
arch/x86/pci/mmconfig-shared.c | 5 +++-- drivers/acpi/osl.c | 6 +++-- drivers/base/base.h | 1 + drivers/base/core.c | 10 +++++++++ drivers/base/power/runtime.c | 15 ++++++++----- include/linux/rculist.h | 40 ++++++++++++++++++++++++++++++---- include/linux/rcupdate.h | 7 ++++++ kernel/rcu/update.c | 26 ++++++++++++++++++++++ kernel/workqueue.c | 5 ++--- net/ipv4/fib_frontend.c | 3 ++- 10 files changed, 101 insertions(+), 17 deletions(-)
--
2.22.0.rc1.311.g5d7573a151-goog
RFC 1/6 rcu: Add support for consolidated-RCU reader checking
This patch adds support for checking RCU reader sections in list traversal macros. Optionally, if the list macro is called under SRCU or other lock/mutex protection, then appropriate lockdep expressions can be passed to make the checks pass.
Existing list_for_each_entry_rcu() invocations don't need to pass the optional fourth argument (cond) unless they are under some non-RCU protection and needs to make lockdep check pass.
--- include/linux/rculist.h | 40 ++++++++++++++++++++++++++++++++++++---- include/linux/rcupdate.h | 7 +++++++ kernel/rcu/update.c | 26 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-)
include/linux/rculist.h +36 -4
@@ -40,6 +40,25 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)*/ #define list_next_rcu (list) (*((struct list_head __rcu **)(&(list)->next))) +/* +* Check during list traversal that we are within an RCU reader +*/ +#define __list_check_rcu () \ + RCU_LOCKDEP_WARN(!rcu_read_lock_any_held(), \ + "RCU-list traversed in non-reader section!") + +static inline void __list_check_rcu_cond (int dummy, ...) +{ +va_list ap; +int cond; + +va_start (ap, dummy); + cond =va_arg (ap, int); +va_end (ap); + +RCU_LOCKDEP_WARN (!cond && !rcu_read_lock_any_held (), +"RCU-list traversed in non-reader section!" ); +}/* * Insert a new entry between two known consecutive entries. *
@@ -338,6 +357,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, member) : NULL; \ }) +#define SIXTH_ARG (a1, a2, a3, a4, a5, a6, ...) a6 +#define COUNT_VARGS (...) SIXTH_ARG(dummy, ## __VA_ARGS__, 4, 3, 2, 1, 0) +/** * list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop cursor.
@@ -348,9 +370,14 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* the _rcu list-mutation primitives such as list_add_rcu() * as long as the traversal is guarded by rcu_read_lock(). */ -#define list_for_each_entry_rcu (pos, head, member) \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))/**
@@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock(). */ -#define hlist_for_each_entry_rcu (pos, head, member) \ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \
include/linux/rcupdate.h +7 -0
@@ -223,6 +223,7 @@ int debug_lockdep_rcu_enabled(void);int rcu_read_lock_held (void );int rcu_read_lock_bh_held (void );int rcu_read_lock_sched_held (void ); +int rcu_read_lock_any_held (void );#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
@@ -243,6 +244,12 @@ static inline int rcu_read_lock_sched_held(void) {return !preemptible (); } + +static inline int rcu_read_lock_any_held (void ) +{ +return !preemptible (); +} +#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */ #ifdef CONFIG_PROVE_RCU
kernel/rcu/update.c +26 -0
@@ -298,6 +298,32 @@ int rcu_read_lock_bh_held(void) }EXPORT_SYMBOL_GPL (rcu_read_lock_bh_held); +int rcu_read_lock_any_held (void ) +{ +int lockdep_opinion =0 ; + +if (!debug_lockdep_rcu_enabled ()) +return 1 ; +if (!rcu_is_watching ()) +return 0 ; +if (!rcu_lockdep_current_cpu_online ()) +return 0 ; + +/* Preemptible RCU flavor */ +if (lock_is_held (&rcu_lock_map)) +return 1 ; + +/* BH flavor */ +if (in_softirq () ||irqs_disabled ()) +return 1 ; + +/* Sched flavor */ +if (debug_locks) + lockdep_opinion =lock_is_held (&rcu_sched_lock_map); +return lockdep_opinion || !preemptible (); +} +EXPORT_SYMBOL_GPL (rcu_read_lock_any_held); +#endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ /**
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
Quoted 14 lines · Joel Fernandes (Google)
include/linux/rculist.h +8
-0+#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))/** @@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock().
include/linux/rculist.h static inline void hlist_add_behind_rcu(struct hlist_node *n, · line 659
Quoted 10 lines
include/linux/rculist.h +6
-0*/ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \
This breaks code like:
if (...) list_for_each_entry_rcu(...);
as they are no longer a single statement. You'll have to frob it into the initializer part of the for statement.
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
Quoted 29 lines · Peter Zijlstra
Quoted 14 lines · Joel Fernandes (Google)
(quoted diff) +8
-0+#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) /**@@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, * the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock().Review static inline void hlist_add_behind_rcu(struct hlist_node *n, · line 659
Quoted 10 lines
(quoted diff) +6
-0*/ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \This breaks code like:
Quoted 5 lines
if (...) list_for_each_entry_rcu(...);as they are no longer a single statement. You'll have to frob it into the initializer part of the for statement.
Thanks a lot for that. I fixed it as below (diff is on top of the patch):
If not for that '##' , I could have abstracted the whole if/else expression into its own macro and called it from list_for_each_entry_rcu() to keep it more clean.
---8<-----------------------
include/linux/rculist.h +18 -12
@@ -371,12 +372,15 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \ - } \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + for ( \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }), \ + pos = list_entry_rcu((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
@@ -649,12 +653,15 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* as long as the traversal is guarded by rcu_read_lock(). */ #define hlist_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \ - } \ - for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ + for ( \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }), \ + pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
Quoted 33 lines · Joel Fernandes
Quoted 32 lines · Peter Zijlstra
Quoted 14 lines · Joel Fernandes (Google)
(quoted diff) +8
-0+#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) /**@@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, * the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock().Review static inline void hlist_add_behind_rcu(struct hlist_node *n, · line 659
Quoted 10 lines
(quoted diff) +6
-0*/ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \This breaks code like:
if (...) list_for_each_entry_rcu(...);
Quoted 8 lines
Quoted 2 lines
as they are no longer a single statement. You'll have to frob it into the initializer part of the for statement.
Thanks a lot for that. I fixed it as below (diff is on top of the patch):
If not for that '##' , I could have abstracted the whole if/else expression into its own macro and called it from
list_for_each_entry_rcu()to keep it more clean.
Actually was able to roll the if/else into its own macro as well, thus keeping it clean. thanks!
---8<-----------------------
include/linux/rculist.h +19 -16
@@ -43,7 +43,11 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)/* * Check during list traversal that we are within an RCU reader */ -#define __list_check_rcu () \ + +#define SIXTH_ARG (a1, a2, a3, a4, a5, a6, ...) a6 +#define COUNT_VARGS (...) SIXTH_ARG(dummy, ## __VA_ARGS__, 4, 3, 2, 1, 0) + +#define __list_check_rcu_nocond () \ RCU_LOCKDEP_WARN(!rcu_read_lock_any_held(), \ "RCU-list traversed in non-reader section!")
@@ -59,6 +63,16 @@ static inline void __list_check_rcu_cond(int dummy, ...)RCU_LOCKDEP_WARN (!cond && !rcu_read_lock_any_held (),"RCU-list traversed in non-reader section!" ); } + +#define __list_check_rcu(cond...) \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }) +/* * Insert a new entry between two known consecutive entries. *
@@ -357,9 +371,6 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, member) : NULL; \ }) -#define SIXTH_ARG (a1, a2, a3, a4, a5, a6, ...) a6 -#define COUNT_VARGS (...) SIXTH_ARG(dummy, ## __VA_ARGS__, 4, 3, 2, 1, 0) -/** * list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop cursor.
@@ -371,12 +382,8 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \ - } \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + for (__list_check_rcu(cond), \ + pos = list_entry_rcu((head)->next, typeof(*pos), member); \ &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
@@ -649,12 +656,8 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* as long as the traversal is guarded by rcu_read_lock(). */ #define hlist_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \ - } \ - for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ + for (__list_check_rcu(cond), \ + pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Steven Rostedt
reviewerRe: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
In reply to Joel FernandesQuoted 56 lines · On Mon, 3 Jun 2019 10:18:47 -0400 Joel Fernandes <[email protected]> wrote:
Quoted 29 lines · Peter Zijlstra
Quoted 14 lines · Joel Fernandes (Google)
include/linux/rculist.h +8
-0+#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))/** @@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock(). include/linux/rculist.h static inline void hlist_add_behind_rcu(struct hlist_node *n, · line 659
Quoted 10 lines
include/linux/rculist.h +6
-0*/ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \This breaks code like:
Quoted 5 lines
if (...) list_for_each_entry_rcu(...);as they are no longer a single statement. You'll have to frob it into the initializer part of the for statement.
Thanks a lot for that. I fixed it as below (diff is on top of the patch):
If not for that '##' , I could have abstracted the whole if/else expression into its own macro and called it from
list_for_each_entry_rcu()to keep it more clean.---8<-----------------------
include/linux/rculist.h +0
-4@@ -371,12 +372,15 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \
include/linux/rculist.h static inline void list_splice_tail_init_rcu(struct list_head *list, · line 382
Quoted 10 lines
include/linux/rculist.h +8
-2- } \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + for ( \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }), \
For easier to read I would do something like this:
#define check_rcu_list(cond) \
({ \
if (COUNT_VARGS(cond) != 0) \
__list_check_rcu_cond(0, ## cond); \
else \
__list_check_rcu_nocond(); \
})#define list_for_each_entry_rcu(pos, head, member, cond...) \ for (check_rcu_list(cond), \
-- Steve
Quoted 26 lines
include/linux/rculist.h +10
-6+ pos =list_entry_rcu ((head)->next,typeof (*pos), member); \ &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))@@ -649,12 +653,15 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* as long as the traversal is guarded by rcu_read_lock(). */ #define hlist_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \ - } \ - for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ + for ( \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }), \ + pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \ pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(\
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
Quoted 80 lines · Steven Rostedt
Quoted 56 lines · On Mon, 3 Jun 2019 10:18:47 -0400 Joel Fernandes <[email protected]> wrote:
Quoted 29 lines · Peter Zijlstra
Quoted 14 lines · Joel Fernandes (Google)
include/linux/rculist.h +8
-0+#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))/** @@ -621,7 +648,12 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n,* the _rcu list-mutation primitives such as hlist_add_head_rcu() * as long as the traversal is guarded by rcu_read_lock(). include/linux/rculist.h static inline void hlist_add_behind_rcu(struct hlist_node *n, · line 659
Quoted 10 lines
include/linux/rculist.h +6
-0*/ +#define hlist_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ typeof(*(pos)), member); \ pos; \This breaks code like:
Quoted 5 lines
if (...) list_for_each_entry_rcu(...);as they are no longer a single statement. You'll have to frob it into the initializer part of the for statement.
Thanks a lot for that. I fixed it as below (diff is on top of the patch):
If not for that '##' , I could have abstracted the whole if/else expression into its own macro and called it from
list_for_each_entry_rcu()to keep it more clean.---8<-----------------------
include/linux/rculist.h +0
-4@@ -371,12 +372,15 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* as long as the traversal is guarded by rcu_read_lock(). */ #define list_for_each_entry_rcu(pos, head, member, cond...) \ - if (COUNT_VARGS(cond) != 0) { \ - __list_check_rcu_cond(0, ## cond); \ - } else { \ - __list_check_rcu(); \include/linux/rculist.h static inline void list_splice_tail_init_rcu(struct list_head *list, · line 382
Quoted 10 lines
include/linux/rculist.h +8
-2- } \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + for ( \ + ({ \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu_nocond(); \ + } \ + }), \For easier to read I would do something like this:
#define check_rcu_list(cond) \ ({ \ if (COUNT_VARGS(cond) != 0) \ __list_check_rcu_cond(0, ## cond); \ else \ __list_check_rcu_nocond(); \ })
Quoted 2 lines
#define list_for_each_entry_rcu(pos, head, member, cond...) \ for (check_rcu_list(cond), \
Yes, already doing it this way as I replied to Peter here:
https://lore.kernel.org/patchwork/patch/1082846/#1278489
Thanks!
- Joel
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
In reply to Joel Fernandes (Google)Quoted 61 lines · Joel Fernandes (Google)
This patch adds support for checking RCU reader sections in list traversal macros. Optionally, if the list macro is called under SRCU or other lock/mutex protection, then appropriate lockdep expressions can be passed to make the checks pass.
Existing
list_for_each_entry_rcu()invocations don't need to pass the optional fourth argument (cond) unless they are under some non-RCU protection and needs to make lockdep check pass.Signed-off-by Joel Fernandes (Google) <[email protected]>--- include/linux/rculist.h | 40 ++++++++++++++++++++++++++++++++++++---- include/linux/rcupdate.h | 7 +++++++ kernel/rcu/update.c | 26 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-)include/linux/rculist.h +22
-2@@ -40,6 +40,25 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)*/ #define list_next_rcu (list) (*((struct list_head __rcu **)(&(list)->next))) +/* +* Check during list traversal that we are within an RCU reader +*/ +#define __list_check_rcu () \ + RCU_LOCKDEP_WARN(!rcu_read_lock_any_held(), \ + "RCU-list traversed in non-reader section!") + +static inline void __list_check_rcu_cond (int dummy, ...) +{ +va_list ap; +int cond; + +va_start (ap, dummy); + cond =va_arg (ap, int); +va_end (ap); + +RCU_LOCKDEP_WARN (!cond && !rcu_read_lock_any_held (), +"RCU-list traversed in non-reader section!" ); +}/* * Insert a new entry between two known consecutive entries. * @@ -338,6 +357,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, member) : NULL; \ }) +#define SIXTH_ARG (a1, a2, a3, a4, a5, a6, ...) a6 +#define COUNT_VARGS (...) SIXTH_ARG(dummy, ## __VA_ARGS__, 4, 3, 2, 1, 0) +> /*** list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop cursor. @@ -348,9 +370,14 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* the _rcu list-mutation primitives such as list_add_rcu() * as long as the traversal is guarded by rcu_read_lock(). */ -#define list_for_each_entry_rcu (pos, head, member) \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \
include/linux/rculist.h static inline void list_splice_tail_init_rcu(struct list_head *list, · line 381
Quoted 10 lines
include/linux/rculist.h +8
-1- &pos->member != (head); \ +#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
Wouldn't something as simple as
#define __list_check_rcu(dummy, cond, ...) \
RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \
"RCU-list traversed in non-reader section!");for ( ({ __list_check_rcu(junk, ##cond, 0); }), pos = ... )
work just as well (i.e., no need for two list_check_rcu and list_check_rcu_cond variants)? If there's an optional cond, we use that, if not, we pick the trailing 0, so !cond disappears and it reduces to your __list_check_rcu(). Moreover, this ensures the RCU_LOCKDEP_WARN expansion actually picks up the __LINE__ and __FILE__ where the for loop is used, and not the __FILE__ and __LINE__ of the static inline function from the header file. It also makes it a bit more type safe/type generic (if the cond expression happened to have type long or u64 something rather odd could happen with the inline vararg function).
Rasmus
Re: [RFC 1/6] rcu: Add support for consolidated-RCU reader checking
Quoted 81 lines · Rasmus Villemoes
Quoted 61 lines · Joel Fernandes (Google)
This patch adds support for checking RCU reader sections in list traversal macros. Optionally, if the list macro is called under SRCU or other lock/mutex protection, then appropriate lockdep expressions can be passed to make the checks pass.
Existing
list_for_each_entry_rcu()invocations don't need to pass the optional fourth argument (cond) unless they are under some non-RCU protection and needs to make lockdep check pass.Signed-off-by Joel Fernandes (Google) <[email protected]>--- include/linux/rculist.h | 40 ++++++++++++++++++++++++++++++++++++---- include/linux/rcupdate.h | 7 +++++++ kernel/rcu/update.c | 26 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-)include/linux/rculist.h +22
-2@@ -40,6 +40,25 @@ static inline void INIT_LIST_HEAD_RCU(struct list_head *list)*/ #define list_next_rcu (list) (*((struct list_head __rcu **)(&(list)->next))) +/* +* Check during list traversal that we are within an RCU reader +*/ +#define __list_check_rcu () \ + RCU_LOCKDEP_WARN(!rcu_read_lock_any_held(), \ + "RCU-list traversed in non-reader section!") + +static inline void __list_check_rcu_cond (int dummy, ...) +{ +va_list ap; +int cond; + +va_start (ap, dummy); + cond =va_arg (ap, int); +va_end (ap); + +RCU_LOCKDEP_WARN (!cond && !rcu_read_lock_any_held (), +"RCU-list traversed in non-reader section!" ); +}/* * Insert a new entry between two known consecutive entries. * @@ -338,6 +357,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, member) : NULL; \ }) +#define SIXTH_ARG (a1, a2, a3, a4, a5, a6, ...) a6 +#define COUNT_VARGS (...) SIXTH_ARG(dummy, ## __VA_ARGS__, 4, 3, 2, 1, 0) +> /*** list_for_each_entry_rcu - iterate over rcu list of given type * @pos: the type * to use as a loop cursor. @@ -348,9 +370,14 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,* the _rcu list-mutation primitives such as list_add_rcu() * as long as the traversal is guarded by rcu_read_lock(). */ -#define list_for_each_entry_rcu (pos, head, member) \ - for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \include/linux/rculist.h static inline void list_splice_tail_init_rcu(struct list_head *list, · line 381
Quoted 10 lines
include/linux/rculist.h +8
-1- &pos->member != (head); \ +#define list_for_each_entry_rcu(pos, head, member, cond...) \ + if (COUNT_VARGS(cond) != 0) { \ + __list_check_rcu_cond(0, ## cond); \ + } else { \ + __list_check_rcu(); \ + } \ + for (pos = list_entry_rcu((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member))Wouldn't something as simple as
#define __list_check_rcu(dummy, cond, ...) \ RCU_LOCKDEP_WARN(!cond && !rcu_read_lock_any_held(), \ "RCU-list traversed in non-reader section!");for ( ({
__list_check_rcu(junk, ##cond, 0); }), pos = ... )
Quoted 9 lines
work just as well (i.e., no need for two
list_check_rcuandlist_check_rcu_condvariants)? If there's an optional cond, we use that, if not, we pick the trailing 0, so !cond disappears and it reduces to your__list_check_rcu(). Moreover, this ensures theRCU_LOCKDEP_WARNexpansion actually picks up the__LINE__and__FILE__where the for loop is used, and not the__FILE__and__LINE__of the static inline function from the header file. It also makes it a bit more type safe/type generic (if the cond expression happened to have type long or u64 something rather odd could happen with the inline vararg function).
This is much better. I will do it this way. Thank you!
- Joel
RFC 2/6 ipv4: add lockdep condition to fix for_each_entry
In reply to Joel Fernandes (Google)--- net/ipv4/fib_frontend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/fib_frontend.c +2 -1
@@ -127,7 +127,8 @@ struct fib_table *fib_get_table(struct net *net, u32 id) h = id & (FIB_TABLE_HASHSZ -1 ); head = &net->ipv4.fib_table_hash[h]; -hlist_for_each_entry_rcu (tb, head, tb_hlist) { +hlist_for_each_entry_rcu (tb, head, tb_hlist, +lockdep_rtnl_is_held ()) {if (tb->tb_id == id)return tb; }
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Re: [RFC 2/6] ipv4: add lockdep condition to fix for_each_entry
Quoted 1 line · Joel Fernandes (Google)
Signed-off-by Joel Fernandes (Google) <[email protected]>
This really needs to be merged to previous patch, you can't break compilation in middle of series...
Or probably you need hlist_for_each_entry_rcu_lockdep() macro with additional argument, and switch users to it.
Pavel
Quoted 17 lines
net/ipv4/fib_frontend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/ipv4/fib_frontend.c +2
-1@@ -127,7 +127,8 @@ struct fib_table *fib_get_table(struct net *net, u32 id) h = id & (FIB_TABLE_HASHSZ -1 ); head = &net->ipv4.fib_table_hash[h]; -hlist_for_each_entry_rcu (tb, head, tb_hlist) { +hlist_for_each_entry_rcu (tb, head, tb_hlist, +lockdep_rtnl_is_held ()) {if (tb->tb_id == id)return tb; }
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [RFC 2/6] ipv4: add lockdep condition to fix for_each_entry
Quoted 9 lines · Pavel Machek
Quoted 1 line · Joel Fernandes (Google)
Signed-off-by Joel Fernandes (Google) <[email protected]>This really needs to be merged to previous patch, you can't break compilation in middle of series...
Or probably you need
hlist_for_each_entry_rcu_lockdep()macro with additional argument, and switch users to it.
Good point. I can also just add a temporary transition macro, and then remove it in the last patch. That way no new macro is needed.
Thanks!
Re: [RFC 2/6] ipv4: add lockdep condition to fix for_each_entry
Quoted 6 lines · Joel Fernandes
Quoted 4 lines · Pavel Machek
Quoted 1 line · Joel Fernandes (Google)
Signed-off-by Joel Fernandes (Google) <[email protected]>
Quoted 8 lines
Quoted 5 lines
This really needs to be merged to previous patch, you can't break compilation in middle of series...
Or probably you need
hlist_for_each_entry_rcu_lockdep()macro with additional argument, and switch users to it.Good point. I can also just add a temporary transition macro, and then remove it in the last patch. That way no new macro is needed.
Actually, no. There is no compilation break so I did not follow what you mean. The fourth argument to the hlist_for_each_entry_rcu is optional. The only thing that happens is new lockdep warnings will arise which later parts of the series fix by passing in that fourth argument.
Re: [RFC 2/6] ipv4: add lockdep condition to fix for_each_entry
Quoted 13 lines · Joel Fernandes
Quoted 12 lines · Joel Fernandes
Quoted 9 lines · Pavel Machek
Quoted 1 line · Joel Fernandes (Google)
Signed-off-by Joel Fernandes (Google) <[email protected]>This really needs to be merged to previous patch, you can't break compilation in middle of series...
Or probably you need
hlist_for_each_entry_rcu_lockdep()macro with additional argument, and switch users to it.
Quoted 8 lines
Quoted 2 lines
Good point. I can also just add a temporary transition macro, and then remove it in the last patch. That way no new macro is needed.
Actually, no. There is no compilation break so I did not follow what you mean. The fourth argument to the
hlist_for_each_entry_rcuis optional. The only thing that happens is new lockdep warnings will arise which later parts of the series fix by passing in that fourth argument.
Sorry, I missed that subtlety. Might be worth it enabling the lockdep warning last in the series...
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Re: [RFC 2/6] ipv4: add lockdep condition to fix for_each_entry
Quoted 18 lines · Pavel Machek
Quoted 16 lines · Joel Fernandes
Quoted 14 lines · Joel Fernandes
Quoted 9 lines · Pavel Machek
Quoted 1 line · Joel Fernandes (Google)
Signed-off-by Joel Fernandes (Google) <[email protected]>This really needs to be merged to previous patch, you can't break compilation in middle of series...
Or probably you need
hlist_for_each_entry_rcu_lockdep()macro with additional argument, and switch users to it.Good point. I can also just add a temporary transition macro, and then remove it in the last patch. That way no new macro is needed.
Quoted 8 lines
Quoted 5 lines
Actually, no. There is no compilation break so I did not follow what you mean. The fourth argument to the
hlist_for_each_entry_rcuis optional. The only thing that happens is new lockdep warnings will arise which later parts of the series fix by passing in that fourth argument.Sorry, I missed that subtlety. Might be worth it enabling the lockdep warning last in the series...
Good idea, will do! Thanks.
RFC 3/6 driver/core: Convert to use built-in RCU list checking
In reply to Joel Fernandes (Google)list_for_each_entry_rcu has built-in RCU and lock checking. Make use of it in driver core.
--- drivers/base/base.h | 1 + drivers/base/core.c | 10 ++++++++++ drivers/base/power/runtime.c | 15 ++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-)
drivers/base/base.h +1 -0
@@ -165,6 +165,7 @@ static inline int devtmpfs_init(void) { return 0; }/* Device links support */ extern int device_links_read_lock (void );extern void device_links_read_unlock (int idx); +extern int device_links_read_lock_held (void );extern int device_links_check_suppliers (struct device *dev);extern void device_links_driver_bound (struct device *dev);extern void device_links_driver_cleanup (struct device *dev);
drivers/base/core.c +10 -0
@@ -68,6 +68,11 @@ void device_links_read_unlock(int idx) {srcu_read_unlock (&device_links_srcu, idx); } + +int device_links_read_lock_held (void ) +{ +return srcu_read_lock_held (&device_links_srcu); +}#else /* !CONFIG_SRCU */ static DECLARE_RWSEM (device_links_lock);
@@ -91,6 +96,11 @@ void device_links_read_unlock(int not_used) {up_read (&device_links_lock); } + +int device_links_read_lock_held (void ) +{ +return lock_is_held (&device_links_lock); +}#endif /* !CONFIG_SRCU */ /**
drivers/base/power/runtime.c +10 -5
@@ -287,7 +287,8 @@ static int rpm_get_suppliers(struct device *dev) {struct device_link *link; -list_for_each_entry_rcu (link, &dev->links.suppliers, c_node) { +list_for_each_entry_rcu (link, &dev->links.suppliers, c_node, +device_links_read_lock_held ()) {int retval; if (!(link->flags & DL_FLAG_PM_RUNTIME) ||
@@ -309,7 +310,8 @@ static void rpm_put_suppliers(struct device *dev) {struct device_link *link; -list_for_each_entry_rcu (link, &dev->links.suppliers, c_node) { +list_for_each_entry_rcu (link, &dev->links.suppliers, c_node, +device_links_read_lock_held ()) {if (READ_ONCE (link->status) ==DL_STATE_SUPPLIER_UNBIND )continue ;
@@ -1640,7 +1642,8 @@ void pm_runtime_clean_up_links(struct device *dev) idx =device_links_read_lock (); -list_for_each_entry_rcu (link, &dev->links.consumers, s_node) { +list_for_each_entry_rcu (link, &dev->links.consumers, s_node, +device_links_read_lock_held ()) {if (link->flags &DL_FLAG_STATELESS )continue ;
@@ -1662,7 +1665,8 @@ void pm_runtime_get_suppliers(struct device *dev) idx =device_links_read_lock (); -list_for_each_entry_rcu (link, &dev->links.suppliers, c_node) +list_for_each_entry_rcu (link, &dev->links.suppliers, c_node, +device_links_read_lock_held ())if (link->flags &DL_FLAG_PM_RUNTIME ) { link->supplier_preactivated = true;refcount_inc (&link->rpm_active);
@@ -1683,7 +1687,8 @@ void pm_runtime_put_suppliers(struct device *dev) idx =device_links_read_lock (); -list_for_each_entry_rcu (link, &dev->links.suppliers, c_node) +list_for_each_entry_rcu (link, &dev->links.suppliers, c_node, +device_links_read_lock_held ())if (link->supplier_preactivated) { link->supplier_preactivated = false;if (refcount_dec_not_one (&link->rpm_active))
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
RFC 4/6 workqueue: Convert for_each_wq to use built-in list check
In reply to Joel Fernandes (Google)list_for_each_entry_rcu now has support to check for RCU reader sections as well as lock. Just use the support in it, instead of explictly checking in the caller.
--- kernel/workqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
kernel/workqueue.c +2 -3
@@ -424,9 +424,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);* ignored. */ #define for_each_pwq (pwq, wq) \ - list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \ - if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \ - else + list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \ + lock_is_held(&(wq->mutex).dep_map))#ifdef CONFIG_DEBUG_OBJECTS_WORK
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
Re: [RFC 4/6] workqueue: Convert for_each_wq to use built-in list check
Quoted 14 lines · Joel Fernandes (Google)
list_for_each_entry_rcunow has support to check for RCU reader sections as well as lock. Just use the support in it, instead of explictly checking in the caller.Signed-off-by Joel Fernandes (Google) <[email protected]>--- kernel/workqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)kernel/workqueue.c +0
-0
kernel/workqueue.c static void workqueue_sysfs_unregister(struct workqueue_struct *wq); · line 429
Quoted 9 lines
kernel/workqueue.c +2
-3@@ -424,9 +424,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);* ignored. */ #define for_each_pwq (pwq, wq) \ - list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \ - if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \ - else + list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \ + lock_is_held(&(wq->mutex).dep_map))
I think the definition of assert_rcu_or_wq_mutex can also be deleted.
Re: [RFC 4/6] workqueue: Convert for_each_wq to use built-in list check
Quoted 11 lines · Daniel Jordan
Quoted 9 lines · Joel Fernandes (Google)
list_for_each_entry_rcunow has support to check for RCU reader sections as well as lock. Just use the support in it, instead of explictly checking in the caller.Signed-off-by Joel Fernandes (Google) <[email protected]>--- kernel/workqueue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 16 lines
Quoted 5 lines
kernel/workqueue.c +0
-0kernel/workqueue.c static void workqueue_sysfs_unregister(struct workqueue_struct *wq); · line 429
Quoted 9 lines
kernel/workqueue.c +2
-3@@ -424,9 +424,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);* ignored. */ #define for_each_pwq (pwq, wq) \ - list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \ - if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \ - else + list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \ + lock_is_held(&(wq->mutex).dep_map))I think the definition of
assert_rcu_or_wq_mutexcan also be deleted.
Sure, will do. Thank you.
RFC 5/6 x86/pci: Pass lockdep condition to pcm_mmcfg_list iterator
In reply to Joel Fernandes (Google)The pcm_mmcfg_list is traversed with list_for_each_entry_rcu without a reader-lock held, because the pci_mmcfg_lock is already held. Make this known to the list macro so that it fixes new lockdep warnings that trigger due to lockdep checks added to list_for_each_entry_rcu().
--- arch/x86/pci/mmconfig-shared.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/pci/mmconfig-shared.c +3 -2
@@ -29,6 +29,7 @@static bool pci_mmcfg_running_state;static bool pci_mmcfg_arch_init_failed;static DEFINE_MUTEX (pci_mmcfg_lock); +#define pci_mmcfg_lock_held () lock_is_held(&(pci_mmcfg_lock).dep_map)LIST_HEAD (pci_mmcfg_list);
@@ -54,7 +55,7 @@ static void list_add_sorted(struct pci_mmcfg_region *new)struct pci_mmcfg_region *cfg;/* keep list sorted by segment and starting bus number */ -list_for_each_entry_rcu (cfg, &pci_mmcfg_list, list) { +list_for_each_entry_rcu (cfg, &pci_mmcfg_list, list,pci_mmcfg_lock_held ()) {if (cfg->segment > new->segment || (cfg->segment == new->segment && cfg->start_bus >= new->start_bus)) {
@@ -118,7 +119,7 @@ struct pci_mmcfg_region *pci_mmconfig_lookup(int segment, int bus) {struct pci_mmcfg_region *cfg; -list_for_each_entry_rcu (cfg, &pci_mmcfg_list, list) +list_for_each_entry_rcu (cfg, &pci_mmcfg_list, list,pci_mmcfg_lock_held ())if (cfg->segment == segment && cfg->start_bus <= bus && bus <= cfg->end_bus)return cfg;
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog
RFC 6/6 acpi: Use built-in RCU list checking for acpi_ioremaps list
In reply to Joel Fernandes (Google)list_for_each_entry_rcu has built-in RCU and lock checking. Make use of it for acpi_ioremaps list traversal.
--- drivers/acpi/osl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/osl.c +4 -2
@@ -28,6 +28,7 @@#include <linux/slab.h> #include <linux/mm.h> #include <linux/highmem.h> +#include <linux/lockdep.h> #include <linux/pci.h> #include <linux/interrupt.h> #include <linux/kmod.h>
@@ -94,6 +95,7 @@ struct acpi_ioremap {static LIST_HEAD (acpi_ioremaps);static DEFINE_MUTEX (acpi_ioremap_lock); +#define acpi_ioremap_lock_held () lock_is_held(&acpi_ioremap_lock.dep_map)static void __init acpi_request_region (struct acpi_generic_address *gas,unsigned int length,char *desc)
@@ -220,7 +222,7 @@ acpi_map_lookup(acpi_physical_address phys, acpi_size size) {struct acpi_ioremap *map; -list_for_each_entry_rcu (map, &acpi_ioremaps, list) +list_for_each_entry_rcu (map, &acpi_ioremaps, list,acpi_ioremap_lock_held ())if (map->phys <= phys && phys + size <= map->phys + map->size)return map;
@@ -263,7 +265,7 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size) {struct acpi_ioremap *map; -list_for_each_entry_rcu (map, &acpi_ioremaps, list) +list_for_each_entry_rcu (map, &acpi_ioremaps, list,acpi_ioremap_lock_held ())if (map->virt <= virt && virt + size <= map->virt + map->size)return map;
Signature · 1 line
2.22.0.rc1.311.g5d7573a151-goog