Skip to content

Commit 608723c

Browse files
urezkipaulmckrcu
authored andcommitted
rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
The kvfree_rcu() and kfree_rcu() APIs are hazardous in that if you forget the second argument, it works, but might sleep. This sleeping can be a correctness bug from atomic contexts, and even in non-atomic contexts it might introduce unacceptable latencies. This commit therefore adds kvfree_rcu_mightsleep() and kfree_rcu_mightsleep(), which will replace the single-argument kvfree_rcu() and kfree_rcu(), respectively. This commit enables a series of commits that switch from single-argument kvfree_rcu() and kfree_rcu() to their _mightsleep() counterparts. Once all of these commits land, the single-argument versions will be removed. Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 2ca836b commit 608723c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/linux/rcupdate.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
10041004
#define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \
10051005
kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__)
10061006

1007+
#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr)
1008+
#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr)
1009+
10071010
#define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME
10081011
#define kvfree_rcu_arg_2(ptr, rhf) \
10091012
do { \

0 commit comments

Comments
 (0)