Message ID | 20230201150815.409582-2-urezki@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d6b54a44de23c83944d042b6f6fd9d19ccd3f1b8 |
Headers | show |
Series | Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() | expand |
> From: Uladzislau Rezki (Sony) <urezki@gmail.com> > Sent: Wednesday, February 1, 2023 11:08 PM > To: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul E . > McKenney <paulmck@kernel.org> > Cc: Uladzislau Rezki <urezki@gmail.com>; Oleksiy Avramchenko > <oleksiy.avramchenko@sony.com>; Jens Axboe <axboe@kernel.dk>; Philipp > Reisner <philipp.reisner@linbit.com>; Bryan Tan <bryantan@vmware.com>; > Steven Rostedt <rostedt@goodmis.org>; Eric Dumazet > <edumazet@google.com>; Bob Pearson <rpearsonhpe@gmail.com>; Ariel > Levkovich <lariel@nvidia.com>; Theodore Ts'o <tytso@mit.edu>; Julian > Anastasov <ja@ssi.bg> > Subject: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and > kfree_rcu_mightsleep() > > These two macroses will replace single-argument k[v]free_rcu() ones. > By adding an extra _mightsleep prefix we can avoid of situations when someone s/prefix/suffix > intended to give a second argument but forgot to do it in a code where sleeping > is illegal. > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > ...
On Thu, Feb 02, 2023 at 07:54:31AM +0000, Zhuo, Qiuxu wrote: > > From: Uladzislau Rezki (Sony) <urezki@gmail.com> > > Sent: Wednesday, February 1, 2023 11:08 PM > > To: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul E . > > McKenney <paulmck@kernel.org> > > Cc: Uladzislau Rezki <urezki@gmail.com>; Oleksiy Avramchenko > > <oleksiy.avramchenko@sony.com>; Jens Axboe <axboe@kernel.dk>; Philipp > > Reisner <philipp.reisner@linbit.com>; Bryan Tan <bryantan@vmware.com>; > > Steven Rostedt <rostedt@goodmis.org>; Eric Dumazet > > <edumazet@google.com>; Bob Pearson <rpearsonhpe@gmail.com>; Ariel > > Levkovich <lariel@nvidia.com>; Theodore Ts'o <tytso@mit.edu>; Julian > > Anastasov <ja@ssi.bg> > > Subject: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and > > kfree_rcu_mightsleep() > > > > These two macroses will replace single-argument k[v]free_rcu() ones. > > By adding an extra _mightsleep prefix we can avoid of situations when someone > > s/prefix/suffix Good eyes, thank you! Please see below for the version currently queued in the -rcu tree. Thanx, Paul > > intended to give a second argument but forgot to do it in a code where sleeping > > is illegal. > > > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> > > ... ------------------------------------------------------------------------ commit d6b54a44de23c83944d042b6f6fd9d19ccd3f1b8 Author: Uladzislau Rezki (Sony) <urezki@gmail.com> Date: Wed Feb 1 16:08:07 2023 +0100 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) <urezki@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 822ff7b4bb1ed..094321c17e48a 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1013,6 +1013,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) +#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr) + #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 822ff7b4bb1e..094321c17e48 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -1013,6 +1013,9 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define kvfree_rcu(...) KVFREE_GET_MACRO(__VA_ARGS__, \ kvfree_rcu_arg_2, kvfree_rcu_arg_1)(__VA_ARGS__) +#define kvfree_rcu_mightsleep(ptr) kvfree_rcu_arg_1(ptr) +#define kfree_rcu_mightsleep(ptr) kvfree_rcu_mightsleep(ptr) + #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \
These two macroses will replace single-argument k[v]free_rcu() ones. By adding an extra _mightsleep prefix we can avoid of situations when someone intended to give a second argument but forgot to do it in a code where sleeping is illegal. Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> --- include/linux/rcupdate.h | 3 +++ 1 file changed, 3 insertions(+)