All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
@ 2023-02-01 15:08 Uladzislau Rezki (Sony)
  2023-02-01 15:08 ` [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (12 more replies)
  0 siblings, 13 replies; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.

1.
The problem is that, recently we have run into a precedent when
a user intended to give a second argument to kfree_rcu() API but
forgot to do it in a code so a call became as a single argument
of kfree_rcu() API.

2.
Such mistyping can lead to hidden bags where sleeping is forbidden.

3.
_mightsleep() prefix gives much more information for which contexts
it can be used for.

Uladzislau Rezki (Sony) (13):
  rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
  drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  lib/test_vmalloc.c: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
  ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
  ipvs: Rename kfree_rcu() to kfree_rcu_mightsleep()
  rcuscale: Rename kfree_rcu() to kfree_rcu_mightsleep()
  doc: Update whatisRCU.rst
  rcu/kvfree: Eliminate k[v]free_rcu() single argument macro

 Documentation/RCU/whatisRCU.rst               |  6 ++--
 drivers/block/drbd/drbd_nl.c                  |  6 ++--
 drivers/block/drbd/drbd_receiver.c            |  4 +--
 drivers/block/drbd/drbd_state.c               |  2 +-
 drivers/infiniband/sw/rxe/rxe_pool.c          |  2 +-
 drivers/misc/vmw_vmci/vmci_context.c          |  2 +-
 drivers/misc/vmw_vmci/vmci_event.c            |  2 +-
 .../mellanox/mlx5/core/en/tc/int_port.c       |  2 +-
 .../mellanox/mlx5/core/en_accel/macsec.c      |  4 +--
 fs/ext4/super.c                               |  2 +-
 include/linux/rcupdate.h                      | 28 ++++++-------------
 kernel/rcu/rcuscale.c                         |  2 +-
 kernel/trace/trace_osnoise.c                  |  2 +-
 kernel/trace/trace_probe.c                    |  2 +-
 lib/test_vmalloc.c                            |  2 +-
 net/core/sysctl_net_core.c                    |  4 +--
 net/netfilter/ipvs/ip_vs_est.c                |  2 +-
 17 files changed, 32 insertions(+), 42 deletions(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 77+ messages in thread

* [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-02-02  7:54   ` Zhuo, Qiuxu
  2023-02-01 15:08 ` [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

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(+)

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 {									\
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
  2023-02-01 15:08 ` [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:39   ` Uladzislau Rezki
  2023-02-01 15:08 ` [PATCH 03/13] misc: vmw_vmci: " Uladzislau Rezki (Sony)
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Lars Ellenberg

The kvfree_rcu()'s single argument name is deprecated therefore
rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Jens Axboe <axboe@kernel.dk>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 drivers/block/drbd/drbd_nl.c       | 6 +++---
 drivers/block/drbd/drbd_receiver.c | 4 ++--
 drivers/block/drbd/drbd_state.c    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index 60757ac31701..f49f2a5282e1 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -1615,7 +1615,7 @@ int drbd_adm_disk_opts(struct sk_buff *skb, struct genl_info *info)
 			drbd_send_sync_param(peer_device);
 	}
 
-	kvfree_rcu(old_disk_conf);
+	kvfree_rcu_mightsleep(old_disk_conf);
 	kfree(old_plan);
 	mod_timer(&device->request_timer, jiffies + HZ);
 	goto success;
@@ -2446,7 +2446,7 @@ int drbd_adm_net_opts(struct sk_buff *skb, struct genl_info *info)
 
 	mutex_unlock(&connection->resource->conf_update);
 	mutex_unlock(&connection->data.mutex);
-	kvfree_rcu(old_net_conf);
+	kvfree_rcu_mightsleep(old_net_conf);
 
 	if (connection->cstate >= C_WF_REPORT_PARAMS) {
 		struct drbd_peer_device *peer_device;
@@ -2860,7 +2860,7 @@ int drbd_adm_resize(struct sk_buff *skb, struct genl_info *info)
 		new_disk_conf->disk_size = (sector_t)rs.resize_size;
 		rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 		mutex_unlock(&device->resource->conf_update);
-		kvfree_rcu(old_disk_conf);
+		kvfree_rcu_mightsleep(old_disk_conf);
 		new_disk_conf = NULL;
 	}
 
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 757f4692b5bd..e197b2a465d2 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3759,7 +3759,7 @@ static int receive_protocol(struct drbd_connection *connection, struct packet_in
 		drbd_info(connection, "peer data-integrity-alg: %s\n",
 			  integrity_alg[0] ? integrity_alg : "(none)");
 
-	kvfree_rcu(old_net_conf);
+	kvfree_rcu_mightsleep(old_net_conf);
 	return 0;
 
 disconnect_rcu_unlock:
@@ -4127,7 +4127,7 @@ static int receive_sizes(struct drbd_connection *connection, struct packet_info
 
 			rcu_assign_pointer(device->ldev->disk_conf, new_disk_conf);
 			mutex_unlock(&connection->resource->conf_update);
-			kvfree_rcu(old_disk_conf);
+			kvfree_rcu_mightsleep(old_disk_conf);
 
 			drbd_info(device, "Peer sets u_size to %lu sectors (old: %lu)\n",
 				 (unsigned long)p_usize, (unsigned long)my_usize);
diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 75d13ea0024f..2aeea295fa28 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -2071,7 +2071,7 @@ static int w_after_conn_state_ch(struct drbd_work *w, int unused)
 		conn_free_crypto(connection);
 		mutex_unlock(&connection->resource->conf_update);
 
-		kvfree_rcu(old_conf);
+		kvfree_rcu_mightsleep(old_conf);
 	}
 
 	if (ns_max.susp_fen) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 03/13] misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
  2023-02-01 15:08 ` [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
  2023-02-01 15:08 ` [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:41   ` Uladzislau Rezki
  2023-03-09 14:36   ` Vishnu Dasa
  2023-02-01 15:08 ` [PATCH 04/13] tracing: " Uladzislau Rezki (Sony)
                   ` (9 subsequent siblings)
  12 siblings, 2 replies; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Vishnu Dasa

The kvfree_rcu()'s single argument name is deprecated therefore
rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Bryan Tan <bryantan@vmware.com>
Cc: Vishnu Dasa <vdasa@vmware.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 drivers/misc/vmw_vmci/vmci_context.c | 2 +-
 drivers/misc/vmw_vmci/vmci_event.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
index 172696abce31..f22b44827e92 100644
--- a/drivers/misc/vmw_vmci/vmci_context.c
+++ b/drivers/misc/vmw_vmci/vmci_context.c
@@ -687,7 +687,7 @@ int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid)
 	spin_unlock(&context->lock);
 
 	if (notifier)
-		kvfree_rcu(notifier);
+		kvfree_rcu_mightsleep(notifier);
 
 	vmci_ctx_put(context);
 
diff --git a/drivers/misc/vmw_vmci/vmci_event.c b/drivers/misc/vmw_vmci/vmci_event.c
index 2100297c94ad..5d7ac07623c2 100644
--- a/drivers/misc/vmw_vmci/vmci_event.c
+++ b/drivers/misc/vmw_vmci/vmci_event.c
@@ -209,7 +209,7 @@ int vmci_event_unsubscribe(u32 sub_id)
 	if (!s)
 		return VMCI_ERROR_NOT_FOUND;
 
-	kvfree_rcu(s);
+	kvfree_rcu_mightsleep(s);
 
 	return VMCI_SUCCESS;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (2 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 03/13] misc: vmw_vmci: " Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:45   ` Uladzislau Rezki
  2023-02-01 15:08 ` [PATCH 05/13] lib/test_vmalloc.c: " Uladzislau Rezki (Sony)
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

The kvfree_rcu()'s single argument name is deprecated therefore
rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 kernel/trace/trace_osnoise.c | 2 +-
 kernel/trace/trace_probe.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 94c1b5eb1dc0..67392d872b67 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -160,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
 	if (!found)
 		return;
 
-	kvfree_rcu(inst);
+	kvfree_rcu_mightsleep(inst);
 }
 
 /*
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 01ebabbbe8c9..32a7741dc731 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1170,7 +1170,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
 		return -ENOENT;
 
 	list_del_rcu(&link->list);
-	kvfree_rcu(link);
+	kvfree_rcu_mightsleep(link);
 
 	if (list_empty(&tp->event->files))
 		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 05/13] lib/test_vmalloc.c: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (3 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 04/13] tracing: " Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-02-01 15:08 ` [PATCH 06/13] net/sysctl: " Uladzislau Rezki (Sony)
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

The kvfree_rcu()'s single argument name is deprecated therefore
rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 lib/test_vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c
index f90d2c27675b..6d8c5c0afd53 100644
--- a/lib/test_vmalloc.c
+++ b/lib/test_vmalloc.c
@@ -328,7 +328,7 @@ kvfree_rcu_1_arg_vmalloc_test(void)
 			return -1;
 
 		p->array[0] = 'a';
-		kvfree_rcu(p);
+		kvfree_rcu_mightsleep(p);
 	}
 
 	return 0;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 06/13] net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (4 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 05/13] lib/test_vmalloc.c: " Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:48   ` Uladzislau Rezki
  2023-03-09 13:49   ` Uladzislau Rezki
  2023-02-01 15:08 ` [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (6 subsequent siblings)
  12 siblings, 2 replies; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, David S . Miller

The kvfree_rcu()'s single argument name is deprecated therefore
rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Eric Dumazet <edumazet@google.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 net/core/sysctl_net_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 5b1ce656baa1..a28562d4e468 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -101,7 +101,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
 			if (orig_sock_table) {
 				static_branch_dec(&rps_needed);
 				static_branch_dec(&rfs_needed);
-				kvfree_rcu(orig_sock_table);
+				kvfree_rcu_mightsleep(orig_sock_table);
 			}
 		}
 	}
@@ -139,7 +139,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write,
 				     lockdep_is_held(&flow_limit_update_mutex));
 			if (cur && !cpumask_test_cpu(i, mask)) {
 				RCU_INIT_POINTER(sd->flow_limit, NULL);
-				kfree_rcu(cur);
+				kfree_rcu_mightsleep(cur);
 			} else if (!cur && cpumask_test_cpu(i, mask)) {
 				cur = kzalloc_node(len, GFP_KERNEL,
 						   cpu_to_node(i));
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (5 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 06/13] net/sysctl: " Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:48   ` Uladzislau Rezki
  2023-02-01 15:08 ` [PATCH 08/13] net/mlx5: " Uladzislau Rezki (Sony)
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Jason Gunthorpe

The kfree_rcu()'s single argument name is deprecated therefore
rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Please check the RXE driver in a way that a single argument can
be used. Briefly looking at it and rcu_head should be embed to
free an obj over RCU-core. The context might be atomic.

Cc: Bob Pearson <rpearsonhpe@gmail.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
index f50620f5a0a1..e2fa061f19b3 100644
--- a/drivers/infiniband/sw/rxe/rxe_pool.c
+++ b/drivers/infiniband/sw/rxe/rxe_pool.c
@@ -276,7 +276,7 @@ int __rxe_cleanup(struct rxe_pool_elem *elem, bool sleepable)
 		pool->cleanup(elem);
 
 	if (pool->type == RXE_TYPE_MR)
-		kfree_rcu(elem->obj);
+		kfree_rcu_mightsleep(elem->obj);
 
 	atomic_dec(&pool->num_elem);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 08/13] net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (6 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:47   ` Uladzislau Rezki
  2023-02-01 15:08 ` [PATCH 09/13] ext4/super: " Uladzislau Rezki (Sony)
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Saeed Mahameed, Vlad Buslov

The kfree_rcu()'s single argument name is deprecated therefore
rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Ariel Levkovich <lariel@nvidia.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c  | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c
index ca834bbcb44f..8afcec0c5d3c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c
@@ -242,7 +242,7 @@ mlx5e_int_port_remove(struct mlx5e_tc_int_port_priv *priv,
 		mlx5_del_flow_rules(int_port->rx_rule);
 	mapping_remove(ctx, int_port->mapping);
 	mlx5e_int_port_metadata_free(priv, int_port->match_metadata);
-	kfree_rcu(int_port);
+	kfree_rcu_mightsleep(int_port);
 	priv->num_ports--;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
index 9369a580743e..5d32a8a5e5a4 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
@@ -672,7 +672,7 @@ static int mlx5e_macsec_del_txsa(struct macsec_context *ctx)
 
 	mlx5e_macsec_cleanup_sa(macsec, tx_sa, true);
 	mlx5_destroy_encryption_key(macsec->mdev, tx_sa->enc_key_id);
-	kfree_rcu(tx_sa);
+	kfree_rcu_mightsleep(tx_sa);
 	macsec_device->tx_sa[assoc_num] = NULL;
 
 out:
@@ -851,7 +851,7 @@ static void macsec_del_rxsc_ctx(struct mlx5e_macsec *macsec, struct mlx5e_macsec
 	xa_erase(&macsec->sc_xarray, rx_sc->sc_xarray_element->fs_id);
 	metadata_dst_free(rx_sc->md_dst);
 	kfree(rx_sc->sc_xarray_element);
-	kfree_rcu(rx_sc);
+	kfree_rcu_mightsleep(rx_sc);
 }
 
 static int mlx5e_macsec_del_rxsc(struct macsec_context *ctx)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* [PATCH 09/13] ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (7 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 08/13] net/mlx5: " Uladzislau Rezki (Sony)
@ 2023-02-01 15:08 ` Uladzislau Rezki (Sony)
  2023-03-09 13:43   ` Uladzislau Rezki
  2023-02-01 19:12 ` [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Paul E. McKenney
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki (Sony) @ 2023-02-01 15:08 UTC (permalink / raw)
  To: LKML, RCU, Paul E . McKenney
  Cc: Uladzislau Rezki, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Lukas Czerner

The kfree_rcu()'s single argument name is deprecated therefore
rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
underline that it is for sleepable contexts.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 260c1b3e3ef2..87aa23d047c9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2500,7 +2500,7 @@ static void ext4_apply_quota_options(struct fs_context *fc,
 			qname = rcu_replace_pointer(sbi->s_qf_names[i], qname,
 						lockdep_is_held(&sb->s_umount));
 			if (qname)
-				kfree_rcu(qname);
+				kfree_rcu_mightsleep(qname);
 		}
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (8 preceding siblings ...)
  2023-02-01 15:08 ` [PATCH 09/13] ext4/super: " Uladzislau Rezki (Sony)
@ 2023-02-01 19:12 ` Paul E. McKenney
  2023-02-02 15:54   ` Uladzislau Rezki
  2023-02-23 12:45 ` Frederic Weisbecker
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-01 19:12 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> 
> 1.
> The problem is that, recently we have run into a precedent when
> a user intended to give a second argument to kfree_rcu() API but
> forgot to do it in a code so a call became as a single argument
> of kfree_rcu() API.
> 
> 2.
> Such mistyping can lead to hidden bags where sleeping is forbidden.
> 
> 3.
> _mightsleep() prefix gives much more information for which contexts
> it can be used for.

Thank you!!!

I have queued these (aside from 10/13, which is being replaced by a
patch from Julian Anastasov) for further testing and review.  And with
the usual wordsmithing.

If testing goes well, I might try to get 1/13 into the next merge window,
which would simplify things if maintainers want to take their patches
separately.

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* RE: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-02-02  7:54   ` Zhuo, Qiuxu
  2023-02-02 15:07     ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Zhuo, Qiuxu @ 2023-02-02  7:54 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony), LKML, RCU, Paul E . McKenney
  Cc: Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

> 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>
> ...

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
  2023-02-02  7:54   ` Zhuo, Qiuxu
@ 2023-02-02 15:07     ` Paul E. McKenney
  0 siblings, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-02 15:07 UTC (permalink / raw)
  To: Zhuo, Qiuxu
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

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 {									\

^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-01 19:12 ` [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Paul E. McKenney
@ 2023-02-02 15:54   ` Uladzislau Rezki
  2023-02-02 16:35     ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-02-02 15:54 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Feb 01, 2023 at 11:12:11AM -0800, Paul E. McKenney wrote:
> On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> > This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> > it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> > 
> > 1.
> > The problem is that, recently we have run into a precedent when
> > a user intended to give a second argument to kfree_rcu() API but
> > forgot to do it in a code so a call became as a single argument
> > of kfree_rcu() API.
> > 
> > 2.
> > Such mistyping can lead to hidden bags where sleeping is forbidden.
> > 
> > 3.
> > _mightsleep() prefix gives much more information for which contexts
> > it can be used for.
> 
> Thank you!!!
> 
> I have queued these (aside from 10/13, which is being replaced by a
> patch from Julian Anastasov) for further testing and review.  And with
> the usual wordsmithing.
> 
Good. 10/13 will go with two arguments. So it is not needed. Just for
confirmation.

BTW, i see two complains from the robot due to 10/13 patch uses an old API
name.

>
> If testing goes well, I might try to get 1/13 into the next merge window,
> which would simplify things if maintainers want to take their patches
> separately.
> 
Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-02 15:54   ` Uladzislau Rezki
@ 2023-02-02 16:35     ` Paul E. McKenney
  0 siblings, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-02 16:35 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Thu, Feb 02, 2023 at 04:54:15PM +0100, Uladzislau Rezki wrote:
> On Wed, Feb 01, 2023 at 11:12:11AM -0800, Paul E. McKenney wrote:
> > On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> > > This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> > > it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> > > 
> > > 1.
> > > The problem is that, recently we have run into a precedent when
> > > a user intended to give a second argument to kfree_rcu() API but
> > > forgot to do it in a code so a call became as a single argument
> > > of kfree_rcu() API.
> > > 
> > > 2.
> > > Such mistyping can lead to hidden bags where sleeping is forbidden.
> > > 
> > > 3.
> > > _mightsleep() prefix gives much more information for which contexts
> > > it can be used for.
> > 
> > Thank you!!!
> > 
> > I have queued these (aside from 10/13, which is being replaced by a
> > patch from Julian Anastasov) for further testing and review.  And with
> > the usual wordsmithing.
> > 
> Good. 10/13 will go with two arguments. So it is not needed. Just for
> confirmation.

Got it, thank you!

> BTW, i see two complains from the robot due to 10/13 patch uses an old API
> name.

Thank you for the heads up!  I will be careful not to expose the last in
the series to -next before they get something in.  Unless they take too
long.  ;-)

							Thanx, Paul

> > If testing goes well, I might try to get 1/13 into the next merge window,
> > which would simplify things if maintainers want to take their patches
> > separately.
> > 
> Thanks!
> 
> --
> Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (9 preceding siblings ...)
  2023-02-01 19:12 ` [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Paul E. McKenney
@ 2023-02-23 12:45 ` Frederic Weisbecker
  2023-02-23 14:29   ` Zhuo, Qiuxu
  2023-02-23 14:57 ` Jens Axboe
  2023-03-15 19:14 ` Steven Rostedt
  12 siblings, 1 reply; 77+ messages in thread
From: Frederic Weisbecker @ 2023-02-23 12:45 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> 
> 1.
> The problem is that, recently we have run into a precedent when
> a user intended to give a second argument to kfree_rcu() API but
> forgot to do it in a code so a call became as a single argument
> of kfree_rcu() API.
> 
> 2.
> Such mistyping can lead to hidden bags where sleeping is forbidden.
> 
> 3.
> _mightsleep() prefix gives much more information for which contexts
> it can be used for.
> 
> Uladzislau Rezki (Sony) (13):
>   rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
>   drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
>   misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
>   tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
>   lib/test_vmalloc.c: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
>   net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
>   RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
>   net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
>   ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
>   ipvs: Rename kfree_rcu() to kfree_rcu_mightsleep()
>   rcuscale: Rename kfree_rcu() to kfree_rcu_mightsleep()
>   doc: Update whatisRCU.rst
>   rcu/kvfree: Eliminate k[v]free_rcu() single argument macro

Hi,

Not sure if you guys noticed but on latest rcu/dev:

net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2 arguments, but only 1 given
   kfree_rcu(td);
               ^
net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in this function); did you mean ‘kfree_skb’?
   kfree_rcu(td);
   ^~~~~~~~~
   kfree_skb
net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is reported only once for each function it appears in


Thanks.

^ permalink raw reply	[flat|nested] 77+ messages in thread

* RE: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 12:45 ` Frederic Weisbecker
@ 2023-02-23 14:29   ` Zhuo, Qiuxu
  2023-02-23 15:54     ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Zhuo, Qiuxu @ 2023-02-23 14:29 UTC (permalink / raw)
  To: Frederic Weisbecker, Uladzislau Rezki (Sony), Paul E . McKenney
  Cc: LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

> From: Frederic Weisbecker <frederic@kernel.org>
> Sent: Thursday, February 23, 2023 8:45 PM
> To: Uladzislau Rezki (Sony) <urezki@gmail.com>
> Cc: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul
> E . McKenney <paulmck@kernel.org>; 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: Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to
> k[v]free_rcu_mightsleep()
> 
> On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> > This small series is based on Paul's "dev" branch. Head is
> > 6002817348a1c610dc1b1c01ff81654cdec12be4
> > it renames a single argument of k[v]free_rcu() to its new
> k[v]free_rcu_mightsleep() name.
> >
> > 1.
> > The problem is that, recently we have run into a precedent when a user
> > intended to give a second argument to kfree_rcu() API but forgot to do
> > it in a code so a call became as a single argument of kfree_rcu() API.
> >
> > 2.
> > Such mistyping can lead to hidden bags where sleeping is forbidden.
> >
> > 3.
> > _mightsleep() prefix gives much more information for which contexts it
> > can be used for.
> >
> > Uladzislau Rezki (Sony) (13):
> >   rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
> >   drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> >   misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> >   tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> >   lib/test_vmalloc.c: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> >   net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> >   RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
> >   net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
> >   ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
> >   ipvs: Rename kfree_rcu() to kfree_rcu_mightsleep()
> >   rcuscale: Rename kfree_rcu() to kfree_rcu_mightsleep()
> >   doc: Update whatisRCU.rst
> >   rcu/kvfree: Eliminate k[v]free_rcu() single argument macro
> 
> Hi,
> 
> Not sure if you guys noticed but on latest rcu/dev:
> 
> net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> arguments, but only 1 given
>    kfree_rcu(td);
>                ^
> net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> this function); did you mean ‘kfree_skb’?
>    kfree_rcu(td);
>    ^~~~~~~~~
>    kfree_skb
> net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> reported only once for each function it appears in
> 

Hi Frederic Weisbecker,

I encountered the same build error as yours. 
Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
@Paul E . McKenney, please correct me if my understanding is wrong. 😊

    https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/

-Qiuxu


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (10 preceding siblings ...)
  2023-02-23 12:45 ` Frederic Weisbecker
@ 2023-02-23 14:57 ` Jens Axboe
  2023-02-23 18:31   ` Paul E. McKenney
  2023-03-15 19:14 ` Steven Rostedt
  12 siblings, 1 reply; 77+ messages in thread
From: Jens Axboe @ 2023-02-23 14:57 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony), LKML, RCU, Paul E . McKenney
  Cc: Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Steven Rostedt,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On 2/1/23 8:08 AM, Uladzislau Rezki (Sony) wrote:
> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> 
> 1.
> The problem is that, recently we have run into a precedent when
> a user intended to give a second argument to kfree_rcu() API but
> forgot to do it in a code so a call became as a single argument
> of kfree_rcu() API.
> 
> 2.
> Such mistyping can lead to hidden bags where sleeping is forbidden.
> 
> 3.
> _mightsleep() prefix gives much more information for which contexts
> it can be used for.

This patchset seems weird to me. We have a LOT of calls that might
sleep, yet we don't suffix them all with _mightsleep(). Why is this
any different? Why isn't this just a might_sleep() call in the
actual helper, which will suffice for checkers and catch it at
runtime as well.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 14:29   ` Zhuo, Qiuxu
@ 2023-02-23 15:54     ` Paul E. McKenney
  2023-02-23 16:21       ` Julian Anastasov
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-23 15:54 UTC (permalink / raw)
  To: Zhuo, Qiuxu
  Cc: Frederic Weisbecker, Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov, pablo

On Thu, Feb 23, 2023 at 02:29:42PM +0000, Zhuo, Qiuxu wrote:
> > From: Frederic Weisbecker <frederic@kernel.org>
> > Sent: Thursday, February 23, 2023 8:45 PM
> > To: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > Cc: LKML <linux-kernel@vger.kernel.org>; RCU <rcu@vger.kernel.org>; Paul
> > E . McKenney <paulmck@kernel.org>; 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: Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to
> > k[v]free_rcu_mightsleep()
> > 
> > On Wed, Feb 01, 2023 at 04:08:06PM +0100, Uladzislau Rezki (Sony) wrote:
> > > This small series is based on Paul's "dev" branch. Head is
> > > 6002817348a1c610dc1b1c01ff81654cdec12be4
> > > it renames a single argument of k[v]free_rcu() to its new
> > k[v]free_rcu_mightsleep() name.
> > >
> > > 1.
> > > The problem is that, recently we have run into a precedent when a user
> > > intended to give a second argument to kfree_rcu() API but forgot to do
> > > it in a code so a call became as a single argument of kfree_rcu() API.
> > >
> > > 2.
> > > Such mistyping can lead to hidden bags where sleeping is forbidden.
> > >
> > > 3.
> > > _mightsleep() prefix gives much more information for which contexts it
> > > can be used for.
> > >
> > > Uladzislau Rezki (Sony) (13):
> > >   rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep()
> > >   drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> > >   misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> > >   tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> > >   lib/test_vmalloc.c: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> > >   net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
> > >   RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
> > >   net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
> > >   ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
> > >   ipvs: Rename kfree_rcu() to kfree_rcu_mightsleep()
> > >   rcuscale: Rename kfree_rcu() to kfree_rcu_mightsleep()
> > >   doc: Update whatisRCU.rst
> > >   rcu/kvfree: Eliminate k[v]free_rcu() single argument macro
> > 
> > Hi,
> > 
> > Not sure if you guys noticed but on latest rcu/dev:
> > 
> > net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> > net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> > arguments, but only 1 given
> >    kfree_rcu(td);
> >                ^
> > net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> > this function); did you mean ‘kfree_skb’?
> >    kfree_rcu(td);
> >    ^~~~~~~~~
> >    kfree_skb
> > net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> > reported only once for each function it appears in
> 
> Hi Frederic Weisbecker,
> 
> I encountered the same build error as yours. 
> Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
> @Paul E . McKenney, please correct me if my understanding is wrong. 😊
> 
>     https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/

Pablo and Julian, how are things coming with that patch?

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 15:54     ` Paul E. McKenney
@ 2023-02-23 16:21       ` Julian Anastasov
  2023-02-23 17:14         ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Julian Anastasov @ 2023-02-23 16:21 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Zhuo, Qiuxu, Frederic Weisbecker, Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, pablo, netdev

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]


	Hello,

On Thu, 23 Feb 2023, Paul E. McKenney wrote:

> > > Not sure if you guys noticed but on latest rcu/dev:
> > > 
> > > net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> > > net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> > > arguments, but only 1 given
> > >    kfree_rcu(td);
> > >                ^
> > > net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> > > this function); did you mean ‘kfree_skb’?
> > >    kfree_rcu(td);
> > >    ^~~~~~~~~
> > >    kfree_skb
> > > net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> > > reported only once for each function it appears in
> > 
> > Hi Frederic Weisbecker,
> > 
> > I encountered the same build error as yours. 
> > Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
> > @Paul E . McKenney, please correct me if my understanding is wrong. 😊
> > 
> >     https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/
> 
> Pablo and Julian, how are things coming with that patch?

	Fix is already in net and net-next tree

Regards

--
Julian Anastasov <ja@ssi.bg>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 16:21       ` Julian Anastasov
@ 2023-02-23 17:14         ` Paul E. McKenney
  2023-02-23 17:36           ` Pablo Neira Ayuso
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-23 17:14 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: Zhuo, Qiuxu, Frederic Weisbecker, Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, pablo, netdev

On Thu, Feb 23, 2023 at 06:21:46PM +0200, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Thu, 23 Feb 2023, Paul E. McKenney wrote:
> 
> > > > Not sure if you guys noticed but on latest rcu/dev:
> > > > 
> > > > net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> > > > net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> > > > arguments, but only 1 given
> > > >    kfree_rcu(td);
> > > >                ^
> > > > net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> > > > this function); did you mean ‘kfree_skb’?
> > > >    kfree_rcu(td);
> > > >    ^~~~~~~~~
> > > >    kfree_skb
> > > > net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> > > > reported only once for each function it appears in
> > > 
> > > Hi Frederic Weisbecker,
> > > 
> > > I encountered the same build error as yours. 
> > > Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
> > > @Paul E . McKenney, please correct me if my understanding is wrong. 😊
> > > 
> > >     https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/
> > 
> > Pablo and Julian, how are things coming with that patch?
> 
> 	Fix is already in net and net-next tree

Very good, thank you!  Is this going into this merge window or is it
expected to wait for v6.4?

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 17:14         ` Paul E. McKenney
@ 2023-02-23 17:36           ` Pablo Neira Ayuso
  2023-02-23 18:21             ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Pablo Neira Ayuso @ 2023-02-23 17:36 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Julian Anastasov, Zhuo, Qiuxu, Frederic Weisbecker,
	Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, netdev

On Thu, Feb 23, 2023 at 09:14:32AM -0800, Paul E. McKenney wrote:
> On Thu, Feb 23, 2023 at 06:21:46PM +0200, Julian Anastasov wrote:
> > 
> > 	Hello,
> > 
> > On Thu, 23 Feb 2023, Paul E. McKenney wrote:
> > 
> > > > > Not sure if you guys noticed but on latest rcu/dev:
> > > > > 
> > > > > net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> > > > > net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> > > > > arguments, but only 1 given
> > > > >    kfree_rcu(td);
> > > > >                ^
> > > > > net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> > > > > this function); did you mean ‘kfree_skb’?
> > > > >    kfree_rcu(td);
> > > > >    ^~~~~~~~~
> > > > >    kfree_skb
> > > > > net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> > > > > reported only once for each function it appears in
> > > > 
> > > > Hi Frederic Weisbecker,
> > > > 
> > > > I encountered the same build error as yours. 
> > > > Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
> > > > @Paul E . McKenney, please correct me if my understanding is wrong. 😊
> > > > 
> > > >     https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/
> > > 
> > > Pablo and Julian, how are things coming with that patch?
> > 
> > 	Fix is already in net and net-next tree
> 
> Very good, thank you!  Is this going into this merge window or is it
> expected to wait for v6.4?

this merge window. 							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 17:36           ` Pablo Neira Ayuso
@ 2023-02-23 18:21             ` Paul E. McKenney
  0 siblings, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-23 18:21 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Julian Anastasov, Zhuo, Qiuxu, Frederic Weisbecker,
	Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Jens Axboe, Philipp Reisner,
	Bryan Tan, Steven Rostedt, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, netdev

On Thu, Feb 23, 2023 at 06:36:26PM +0100, Pablo Neira Ayuso wrote:
> On Thu, Feb 23, 2023 at 09:14:32AM -0800, Paul E. McKenney wrote:
> > On Thu, Feb 23, 2023 at 06:21:46PM +0200, Julian Anastasov wrote:
> > > 
> > > 	Hello,
> > > 
> > > On Thu, 23 Feb 2023, Paul E. McKenney wrote:
> > > 
> > > > > > Not sure if you guys noticed but on latest rcu/dev:
> > > > > > 
> > > > > > net/netfilter/ipvs/ip_vs_est.c: In function ‘ip_vs_stop_estimator’:
> > > > > > net/netfilter/ipvs/ip_vs_est.c:552:15: error: macro "kfree_rcu" requires 2
> > > > > > arguments, but only 1 given
> > > > > >    kfree_rcu(td);
> > > > > >                ^
> > > > > > net/netfilter/ipvs/ip_vs_est.c:552:3: error: ‘kfree_rcu’ undeclared (first use in
> > > > > > this function); did you mean ‘kfree_skb’?
> > > > > >    kfree_rcu(td);
> > > > > >    ^~~~~~~~~
> > > > > >    kfree_skb
> > > > > > net/netfilter/ipvs/ip_vs_est.c:552:3: note: each undeclared identifier is
> > > > > > reported only once for each function it appears in
> > > > > 
> > > > > Hi Frederic Weisbecker,
> > > > > 
> > > > > I encountered the same build error as yours. 
> > > > > Per the discussion link below, the fix for this build error by Uladzislau Rezki will be picked up by some other maintainer's branch?
> > > > > @Paul E . McKenney, please correct me if my understanding is wrong. 😊
> > > > > 
> > > > >     https://lore.kernel.org/rcu/Y9qc+lgR1CgdszKs@salvia/
> > > > 
> > > > Pablo and Julian, how are things coming with that patch?
> > > 
> > > 	Fix is already in net and net-next tree
> > 
> > Very good, thank you!  Is this going into this merge window or is it
> > expected to wait for v6.4?
> 
> this merge window. 							Thanx, Paul

Thank you, and looking forward to it!

								Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 14:57 ` Jens Axboe
@ 2023-02-23 18:31   ` Paul E. McKenney
  2023-02-23 19:36     ` Jens Axboe
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-23 18:31 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On Thu, Feb 23, 2023 at 07:57:13AM -0700, Jens Axboe wrote:
> On 2/1/23 8:08 AM, Uladzislau Rezki (Sony) wrote:
> > This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> > it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> > 
> > 1.
> > The problem is that, recently we have run into a precedent when
> > a user intended to give a second argument to kfree_rcu() API but
> > forgot to do it in a code so a call became as a single argument
> > of kfree_rcu() API.
> > 
> > 2.
> > Such mistyping can lead to hidden bags where sleeping is forbidden.
> > 
> > 3.
> > _mightsleep() prefix gives much more information for which contexts
> > it can be used for.
> 
> This patchset seems weird to me. We have a LOT of calls that might
> sleep, yet we don't suffix them all with _mightsleep(). Why is this
> any different? Why isn't this just a might_sleep() call in the
> actual helper, which will suffice for checkers and catch it at
> runtime as well.

Fair enough, and the situation that this patchset is addressing is also a
bit unusual.  This change was requested by Eric Dumazet due to a situation
where someone forgot the optional second argument to kfree_rcu().  Now,
you are right that this would be caught if invoked from a non-sleepable
context, but there are also cases where sleeping is legal, but where the
occasional wait for an RCU grace period would be a problem.  The checkers
cannot easily catch this sort of thing, and hence the change in name.

Hey, the combined one/two-argument form seemed like a good idea at
the time!  ;-)

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 18:31   ` Paul E. McKenney
@ 2023-02-23 19:36     ` Jens Axboe
  2023-02-23 19:47       ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Jens Axboe @ 2023-02-23 19:36 UTC (permalink / raw)
  To: paulmck
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On 2/23/23 11:31 AM, Paul E. McKenney wrote:
> On Thu, Feb 23, 2023 at 07:57:13AM -0700, Jens Axboe wrote:
>> On 2/1/23 8:08 AM, Uladzislau Rezki (Sony) wrote:
>>> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
>>> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
>>>
>>> 1.
>>> The problem is that, recently we have run into a precedent when
>>> a user intended to give a second argument to kfree_rcu() API but
>>> forgot to do it in a code so a call became as a single argument
>>> of kfree_rcu() API.
>>>
>>> 2.
>>> Such mistyping can lead to hidden bags where sleeping is forbidden.
>>>
>>> 3.
>>> _mightsleep() prefix gives much more information for which contexts
>>> it can be used for.
>>
>> This patchset seems weird to me. We have a LOT of calls that might
>> sleep, yet we don't suffix them all with _mightsleep(). Why is this
>> any different? Why isn't this just a might_sleep() call in the
>> actual helper, which will suffice for checkers and catch it at
>> runtime as well.
> 
> Fair enough, and the situation that this patchset is addressing is also a
> bit unusual.  This change was requested by Eric Dumazet due to a situation
> where someone forgot the optional second argument to kfree_rcu().  Now,
> you are right that this would be caught if invoked from a non-sleepable
> context, but there are also cases where sleeping is legal, but where the
> occasional wait for an RCU grace period would be a problem.  The checkers
> cannot easily catch this sort of thing, and hence the change in name.
> 
> Hey, the combined one/two-argument form seemed like a good idea at
> the time!  ;-)

Hah, not sure what you were smoking back then!

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 19:36     ` Jens Axboe
@ 2023-02-23 19:47       ` Paul E. McKenney
  2023-02-23 19:57         ` Jens Axboe
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-02-23 19:47 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On Thu, Feb 23, 2023 at 12:36:57PM -0700, Jens Axboe wrote:
> On 2/23/23 11:31 AM, Paul E. McKenney wrote:
> > On Thu, Feb 23, 2023 at 07:57:13AM -0700, Jens Axboe wrote:
> >> On 2/1/23 8:08 AM, Uladzislau Rezki (Sony) wrote:
> >>> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> >>> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> >>>
> >>> 1.
> >>> The problem is that, recently we have run into a precedent when
> >>> a user intended to give a second argument to kfree_rcu() API but
> >>> forgot to do it in a code so a call became as a single argument
> >>> of kfree_rcu() API.
> >>>
> >>> 2.
> >>> Such mistyping can lead to hidden bags where sleeping is forbidden.
> >>>
> >>> 3.
> >>> _mightsleep() prefix gives much more information for which contexts
> >>> it can be used for.
> >>
> >> This patchset seems weird to me. We have a LOT of calls that might
> >> sleep, yet we don't suffix them all with _mightsleep(). Why is this
> >> any different? Why isn't this just a might_sleep() call in the
> >> actual helper, which will suffice for checkers and catch it at
> >> runtime as well.
> > 
> > Fair enough, and the situation that this patchset is addressing is also a
> > bit unusual.  This change was requested by Eric Dumazet due to a situation
> > where someone forgot the optional second argument to kfree_rcu().  Now,
> > you are right that this would be caught if invoked from a non-sleepable
> > context, but there are also cases where sleeping is legal, but where the
> > occasional wait for an RCU grace period would be a problem.  The checkers
> > cannot easily catch this sort of thing, and hence the change in name.
> > 
> > Hey, the combined one/two-argument form seemed like a good idea at
> > the time!  ;-)
> 
> Hah, not sure what you were smoking back then!

If I remember, would you like me to send you some?  ;-)

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-23 19:47       ` Paul E. McKenney
@ 2023-02-23 19:57         ` Jens Axboe
  0 siblings, 0 replies; 77+ messages in thread
From: Jens Axboe @ 2023-02-23 19:57 UTC (permalink / raw)
  To: paulmck
  Cc: Uladzislau Rezki (Sony),
	LKML, RCU, Oleksiy Avramchenko, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On 2/23/23 12:47?PM, Paul E. McKenney wrote:
>>> Hey, the combined one/two-argument form seemed like a good idea at
>>> the time!  ;-)
>>
>> Hah, not sure what you were smoking back then!
> 
> If I remember, would you like me to send you some?  ;-)

Definitely, might improve my reviews :-)

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-03-09 13:39   ` Uladzislau Rezki
  0 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:39 UTC (permalink / raw)
  To: Jens Axboe, Philipp Reisner, Lars Ellenberg
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Lars Ellenberg

> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Philipp Reisner <philipp.reisner@linbit.com>
> Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  drivers/block/drbd/drbd_nl.c       | 6 +++---
>  drivers/block/drbd/drbd_receiver.c | 4 ++--
>  drivers/block/drbd/drbd_state.c    | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> 
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 03/13] misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 03/13] misc: vmw_vmci: " Uladzislau Rezki (Sony)
@ 2023-03-09 13:41   ` Uladzislau Rezki
  2023-03-09 14:36   ` Vishnu Dasa
  1 sibling, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:41 UTC (permalink / raw)
  To: Bryan Tan, Vishnu Dasa
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Vishnu Dasa

> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Bryan Tan <bryantan@vmware.com>
> Cc: Vishnu Dasa <vdasa@vmware.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 09/13] ext4/super: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 09/13] ext4/super: " Uladzislau Rezki (Sony)
@ 2023-03-09 13:43   ` Uladzislau Rezki
  0 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:43 UTC (permalink / raw)
  To: Theodore Ts'o, Lukas Czerner
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Lukas Czerner

> The kfree_rcu()'s single argument name is deprecated therefore
> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Theodore Ts'o <tytso@mit.edu>
> Cc: Lukas Czerner <lczerner@redhat.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 04/13] tracing: " Uladzislau Rezki (Sony)
@ 2023-03-09 13:45   ` Uladzislau Rezki
  2023-03-15 22:36     ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzisslau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 08/13] net/mlx5: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 08/13] net/mlx5: " Uladzislau Rezki (Sony)
@ 2023-03-09 13:47   ` Uladzislau Rezki
  0 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:47 UTC (permalink / raw)
  To: Ariel Levkovich, Saeed Mahameed, Vlad Buslov
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Saeed Mahameed, Vlad Buslov

On Wed, Feb 01, 2023 at 04:08:14PM +0100, Uladzislau Rezki (Sony) wrote:
> The kfree_rcu()'s single argument name is deprecated therefore
> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Ariel Levkovich <lariel@nvidia.com>
> Cc: Saeed Mahameed <saeedm@nvidia.com>
> Cc: Vlad Buslov <vladbu@nvidia.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en/tc/int_port.c  | 2 +-
>  drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
@ 2023-03-09 13:48   ` Uladzislau Rezki
  2023-03-09 14:13     ` Uladzislau Rezki
  0 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:48 UTC (permalink / raw)
  To: Bob Pearson, Jason Gunthorpe
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Jason Gunthorpe

On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
> The kfree_rcu()'s single argument name is deprecated therefore
> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Please check the RXE driver in a way that a single argument can
> be used. Briefly looking at it and rcu_head should be embed to
> free an obj over RCU-core. The context might be atomic.
> 
> Cc: Bob Pearson <rpearsonhpe@gmail.com>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki



^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 06/13] net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 06/13] net/sysctl: " Uladzislau Rezki (Sony)
@ 2023-03-09 13:48   ` Uladzislau Rezki
  2023-03-09 13:49   ` Uladzislau Rezki
  1 sibling, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:48 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, David S . Miller

On Wed, Feb 01, 2023 at 04:08:12PM +0100, Uladzislau Rezki (Sony) wrote:
> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  net/core/sysctl_net_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 06/13] net/sysctl: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 06/13] net/sysctl: " Uladzislau Rezki (Sony)
  2023-03-09 13:48   ` Uladzislau Rezki
@ 2023-03-09 13:49   ` Uladzislau Rezki
  1 sibling, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 13:49 UTC (permalink / raw)
  To: Eric Dumazet, David S. Miller
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, David S . Miller

> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> ---
>  net/core/sysctl_net_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Could you please add you reviwed-by or Acked-by tags so we can bring
our series with renaming for the next merge window?

Thanks!

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-09 13:48   ` Uladzislau Rezki
@ 2023-03-09 14:13     ` Uladzislau Rezki
  2023-03-10  0:55       ` Joel Fernandes
  2023-03-14  6:31       ` Zhu Yanjun
  0 siblings, 2 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-09 14:13 UTC (permalink / raw)
  To: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, linux-rdma
  Cc: Bob Pearson, Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

> On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
> > The kfree_rcu()'s single argument name is deprecated therefore
> > rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> > underline that it is for sleepable contexts.
> > 
> > Please check the RXE driver in a way that a single argument can
> > be used. Briefly looking at it and rcu_head should be embed to
> > free an obj over RCU-core. The context might be atomic.
> > 
> > Cc: Bob Pearson <rpearsonhpe@gmail.com>
> > Cc: Jason Gunthorpe <jgg@nvidia.com>
> > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > ---
> >  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> Could you please add you reviwed-by or Acked-by tags so we can bring
> our series with renaming for the next merge window?
> 
> Thanks!
> 
__rxe_cleanup() can be called in two contexts, sleepable and not.
Therefore usage of a single argument of the kvfree_rcu() is not correct
here.

Could you please fix and check your driver? If my above statement
is not correct, please provide Acked-by or Reviwed-by tags to the
path that is in question.

Otherwise please add an rcu_head in your data to free objects over
kvfree_rcu() using double argument API.

Could you please support?

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 03/13] misc: vmw_vmci: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-02-01 15:08 ` [PATCH 03/13] misc: vmw_vmci: " Uladzislau Rezki (Sony)
  2023-03-09 13:41   ` Uladzislau Rezki
@ 2023-03-09 14:36   ` Vishnu Dasa
  1 sibling, 0 replies; 77+ messages in thread
From: Vishnu Dasa @ 2023-03-09 14:36 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Steven Rostedt, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov


> On Feb 1, 2023, at 7:08 AM, Uladzislau Rezki (Sony) <urezki@gmail.com> wrote:
> 
> The kvfree_rcu()'s single argument name is deprecated therefore
> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> underline that it is for sleepable contexts.
> 
> Cc: Bryan Tan <bryantan@vmware.com>
> Cc: Vishnu Dasa <vdasa@vmware.com>
> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Reviewed-by: Vishnu Dasa <vdasa@vmware.com>

> ---
> drivers/misc/vmw_vmci/vmci_context.c | 2 +-
> drivers/misc/vmw_vmci/vmci_event.c   | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
> index 172696abce31..f22b44827e92 100644
> --- a/drivers/misc/vmw_vmci/vmci_context.c
> +++ b/drivers/misc/vmw_vmci/vmci_context.c
> @@ -687,7 +687,7 @@ int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid)
> spin_unlock(&context->lock);
> 
> if (notifier)
> - kvfree_rcu(notifier);
> + kvfree_rcu_mightsleep(notifier);
> 
> vmci_ctx_put(context);
> 
> diff --git a/drivers/misc/vmw_vmci/vmci_event.c b/drivers/misc/vmw_vmci/vmci_event.c
> index 2100297c94ad..5d7ac07623c2 100644
> --- a/drivers/misc/vmw_vmci/vmci_event.c
> +++ b/drivers/misc/vmw_vmci/vmci_event.c
> @@ -209,7 +209,7 @@ int vmci_event_unsubscribe(u32 sub_id)
> if (!s)
> return VMCI_ERROR_NOT_FOUND;
> 
> - kvfree_rcu(s);
> + kvfree_rcu_mightsleep(s);
> 
> return VMCI_SUCCESS;
> }
> -- 
> 2.30.2
> 


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-09 14:13     ` Uladzislau Rezki
@ 2023-03-10  0:55       ` Joel Fernandes
  2023-03-13 19:43         ` Bob Pearson
  2023-03-14  6:31       ` Zhu Yanjun
  1 sibling, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-10  0:55 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
	Bob Pearson, Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, Mar 09, 2023 at 03:13:08PM +0100, Uladzislau Rezki wrote:
> > On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
> > > The kfree_rcu()'s single argument name is deprecated therefore
> > > rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> > > underline that it is for sleepable contexts.
> > > 
> > > Please check the RXE driver in a way that a single argument can
> > > be used. Briefly looking at it and rcu_head should be embed to
> > > free an obj over RCU-core. The context might be atomic.
> > > 
> > > Cc: Bob Pearson <rpearsonhpe@gmail.com>
> > > Cc: Jason Gunthorpe <jgg@nvidia.com>
> > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > > ---
> > >  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > Could you please add you reviwed-by or Acked-by tags so we can bring
> > our series with renaming for the next merge window?
> > 
> > Thanks!
> > 
> __rxe_cleanup() can be called in two contexts, sleepable and not.
> Therefore usage of a single argument of the kvfree_rcu() is not correct
> here.
> 
> Could you please fix and check your driver? If my above statement
> is not correct, please provide Acked-by or Reviwed-by tags to the
> path that is in question.
> 
> Otherwise please add an rcu_head in your data to free objects over
> kvfree_rcu() using double argument API.
> 
> Could you please support?

Also this one needs renaming? It came in because of the commit in 6.3-rc1:
72a03627443d ("RDMA/rxe: Remove rxe_alloc()")

It could be squashed into this patch itself since it is infiniband related.

Paul noticed that this breaks dropping the old API on -next, so it is
blocking the renaming.

---8<-----------------------

diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index b10aa1580a64..ae3a100e18fb 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 		return -EINVAL;
 
 	rxe_cleanup(mr);
-	kfree_rcu(mr);
+	kfree_rcu_mightsleep(mr);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-10  0:55       ` Joel Fernandes
@ 2023-03-13 19:43         ` Bob Pearson
  2023-03-15 11:50           ` Joel Fernandes
  0 siblings, 1 reply; 77+ messages in thread
From: Bob Pearson @ 2023-03-13 19:43 UTC (permalink / raw)
  To: Joel Fernandes, Uladzislau Rezki
  Cc: Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky, linux-rdma,
	Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On 3/9/23 18:55, Joel Fernandes wrote:
> On Thu, Mar 09, 2023 at 03:13:08PM +0100, Uladzislau Rezki wrote:
>>> On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
>>>> The kfree_rcu()'s single argument name is deprecated therefore
>>>> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
>>>> underline that it is for sleepable contexts.
>>>>
>>>> Please check the RXE driver in a way that a single argument can
>>>> be used. Briefly looking at it and rcu_head should be embed to
>>>> free an obj over RCU-core. The context might be atomic.
>>>>
>>>> Cc: Bob Pearson <rpearsonhpe@gmail.com>
>>>> Cc: Jason Gunthorpe <jgg@nvidia.com>
>>>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>>>> ---
>>>>  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>> Could you please add you reviwed-by or Acked-by tags so we can bring
>>> our series with renaming for the next merge window?
>>>
>>> Thanks!
>>>
>> __rxe_cleanup() can be called in two contexts, sleepable and not.
>> Therefore usage of a single argument of the kvfree_rcu() is not correct
>> here.
>>
>> Could you please fix and check your driver? If my above statement
>> is not correct, please provide Acked-by or Reviwed-by tags to the
>> path that is in question.
>>
>> Otherwise please add an rcu_head in your data to free objects over
>> kvfree_rcu() using double argument API.
>>
>> Could you please support?
> 
> Also this one needs renaming? It came in because of the commit in 6.3-rc1:
> 72a03627443d ("RDMA/rxe: Remove rxe_alloc()")
> 
> It could be squashed into this patch itself since it is infiniband related.
> 
> Paul noticed that this breaks dropping the old API on -next, so it is
> blocking the renaming.
> 
> ---8<-----------------------
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
> index b10aa1580a64..ae3a100e18fb 100644
> --- a/drivers/infiniband/sw/rxe/rxe_mr.c
> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
> @@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>  		return -EINVAL;
>  
>  	rxe_cleanup(mr);
> -	kfree_rcu(mr);
> +	kfree_rcu_mightsleep(mr);
>  	return 0;
>  }
>  
I just got back from a 1 week vacation and missed all this.

The "RDMA/rxe: Remove rxe_alloc()" patch just moved the memory allocation for MR (verbs) objects outside
of the rxe_pool code since it only applied to MRs and not the other verbs objects (AH, QP, CQ, ...).
That code has to handle a unique situation for AH objects which can be created or destroyed by connection
manager code in atomic context while all the other ones including MRs are always created/destroyed in process
context. All objects other than MR's are created/destroyed in the rdma-core code (drivers/infiniband/core).

The rxe driver keeps xarray's of pointers to the various objects which are protected by rcu locking and so
it made sense to use kfree_rcu to delete the object with a delay. In the MR case ..._mightsleep seems harmless
and should not be an issue.

However on reflection, all the references to the MR objects are ref counted and they have been dropped before
reaching the kfree and so there really never was a good reason to use kfree_rcu in the first place. So
a better solution would be to replace kfree_rcu with kfree. There is a timeout in completion_done() that
triggers a WARN_ON() and this is only seen if the driver is broken for some reason but that is equivalent to
getting a seg fault so no reason to further delay the kfree.

Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-09 14:13     ` Uladzislau Rezki
  2023-03-10  0:55       ` Joel Fernandes
@ 2023-03-14  6:31       ` Zhu Yanjun
  1 sibling, 0 replies; 77+ messages in thread
From: Zhu Yanjun @ 2023-03-14  6:31 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, Bob Pearson,
	Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, Mar 9, 2023 at 10:13 PM Uladzislau Rezki <urezki@gmail.com> wrote:
>
> > On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
> > > The kfree_rcu()'s single argument name is deprecated therefore
> > > rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> > > underline that it is for sleepable contexts.
> > >
> > > Please check the RXE driver in a way that a single argument can
> > > be used. Briefly looking at it and rcu_head should be embed to
> > > free an obj over RCU-core. The context might be atomic.
> > >
> > > Cc: Bob Pearson <rpearsonhpe@gmail.com>
> > > Cc: Jason Gunthorpe <jgg@nvidia.com>
> > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Thanks.
Acked-by: Zhu Yanjun <zyjzyj2000@gmail.com>

Zhu Yanjun

> > > ---
> > >  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > Could you please add you reviwed-by or Acked-by tags so we can bring
> > our series with renaming for the next merge window?
> >
> > Thanks!
> >
> __rxe_cleanup() can be called in two contexts, sleepable and not.
> Therefore usage of a single argument of the kvfree_rcu() is not correct
> here.
>
> Could you please fix and check your driver? If my above statement
> is not correct, please provide Acked-by or Reviwed-by tags to the
> path that is in question.
>
> Otherwise please add an rcu_head in your data to free objects over
> kvfree_rcu() using double argument API.
>
> Could you please support?
>
> --
> Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-13 19:43         ` Bob Pearson
@ 2023-03-15 11:50           ` Joel Fernandes
  2023-03-15 18:07             ` Bob Pearson
  0 siblings, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-15 11:50 UTC (permalink / raw)
  To: Bob Pearson
  Cc: Uladzislau Rezki, Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky,
	linux-rdma, Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Mon, Mar 13, 2023 at 02:43:43PM -0500, Bob Pearson wrote:
> On 3/9/23 18:55, Joel Fernandes wrote:
> > On Thu, Mar 09, 2023 at 03:13:08PM +0100, Uladzislau Rezki wrote:
> >>> On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
> >>>> The kfree_rcu()'s single argument name is deprecated therefore
> >>>> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
> >>>> underline that it is for sleepable contexts.
> >>>>
> >>>> Please check the RXE driver in a way that a single argument can
> >>>> be used. Briefly looking at it and rcu_head should be embed to
> >>>> free an obj over RCU-core. The context might be atomic.
> >>>>
> >>>> Cc: Bob Pearson <rpearsonhpe@gmail.com>
> >>>> Cc: Jason Gunthorpe <jgg@nvidia.com>
> >>>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> >>>> ---
> >>>>  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
> >>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>
> >>> Could you please add you reviwed-by or Acked-by tags so we can bring
> >>> our series with renaming for the next merge window?
> >>>
> >>> Thanks!
> >>>
> >> __rxe_cleanup() can be called in two contexts, sleepable and not.
> >> Therefore usage of a single argument of the kvfree_rcu() is not correct
> >> here.
> >>
> >> Could you please fix and check your driver? If my above statement
> >> is not correct, please provide Acked-by or Reviwed-by tags to the
> >> path that is in question.
> >>
> >> Otherwise please add an rcu_head in your data to free objects over
> >> kvfree_rcu() using double argument API.
> >>
> >> Could you please support?
> > 
> > Also this one needs renaming? It came in because of the commit in 6.3-rc1:
> > 72a03627443d ("RDMA/rxe: Remove rxe_alloc()")
> > 
> > It could be squashed into this patch itself since it is infiniband related.
> > 
> > Paul noticed that this breaks dropping the old API on -next, so it is
> > blocking the renaming.
> > 
> > ---8<-----------------------
> > 
> > diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
> > index b10aa1580a64..ae3a100e18fb 100644
> > --- a/drivers/infiniband/sw/rxe/rxe_mr.c
> > +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
> > @@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
> >  		return -EINVAL;
> >  
> >  	rxe_cleanup(mr);
> > -	kfree_rcu(mr);
> > +	kfree_rcu_mightsleep(mr);
> >  	return 0;
> >  }
> >  
> I just got back from a 1 week vacation and missed all this.
> 
> The "RDMA/rxe: Remove rxe_alloc()" patch just moved the memory allocation
> for MR (verbs) objects outside of the rxe_pool code since it only applied
> to MRs and not the other verbs objects (AH, QP, CQ, ...).  That code has to
> handle a unique situation for AH objects which can be created or destroyed
> by connection manager code in atomic context while all the other ones
> including MRs are always created/destroyed in process context. All objects
> other than MR's are created/destroyed in the rdma-core code
> (drivers/infiniband/core).
> 
> The rxe driver keeps xarray's of pointers to the various objects which are
> protected by rcu locking and so it made sense to use kfree_rcu to delete
> the object with a delay. In the MR case ..._mightsleep seems harmless and
> should not be an issue.
> 
> However on reflection, all the references to the MR objects are ref counted
> and they have been dropped before reaching the kfree and so there really
> never was a good reason to use kfree_rcu in the first place. So a better
> solution would be to replace kfree_rcu with kfree. There is a timeout in
> completion_done() that triggers a WARN_ON() and this is only seen if the
> driver is broken for some reason but that is equivalent to getting a seg
> fault so no reason to further delay the kfree.
> 
> Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>

Thanks, I am planning to send the following patch for 6.4 consideration,
please let me know if you disagree. Still testing it.

----8<---

From: Joel Fernandes (Google) <joel@joelfernandes.org>
Subject: [PATCH] RDMA/rxe: Rename kfree_rcu() to kvfree_rcu_mightsleep()

The k[v]free_rcu() macro's single-argument form is deprecated.
Therefore switch to the new k[v]free_rcu_mightsleep() variant. The goal
is to avoid accidental use of the single-argument forms, which can
introduce functionality bugs in atomic contexts and latency bugs in
non-atomic contexts.

There is no functionality change with this patch.

Link: https://lore.kernel.org/rcu/20230201150815.409582-1-urezki@gmail.com
Acked-by: Zhu Yanjun <zyjzyj2000@gmail.com>
Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Fixes: 72a03627443d ("RDMA/rxe: Remove rxe_alloc()")
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 drivers/infiniband/sw/rxe/rxe_mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index b10aa1580a64..ae3a100e18fb 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
 		return -EINVAL;
 
 	rxe_cleanup(mr);
-	kfree_rcu(mr);
+	kfree_rcu_mightsleep(mr);
 	return 0;
 }
 
-- 
2.40.0.rc1.284.g88254d51c5-goog


^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep()
  2023-03-15 11:50           ` Joel Fernandes
@ 2023-03-15 18:07             ` Bob Pearson
  0 siblings, 0 replies; 77+ messages in thread
From: Bob Pearson @ 2023-03-15 18:07 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Uladzislau Rezki, Zhu Yanjun, Jason Gunthorpe, Leon Romanovsky,
	linux-rdma, Jason Gunthorpe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Steven Rostedt, Eric Dumazet, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On 3/15/23 06:50, Joel Fernandes wrote:
> On Mon, Mar 13, 2023 at 02:43:43PM -0500, Bob Pearson wrote:
>> On 3/9/23 18:55, Joel Fernandes wrote:
>>> On Thu, Mar 09, 2023 at 03:13:08PM +0100, Uladzislau Rezki wrote:
>>>>> On Wed, Feb 01, 2023 at 04:08:13PM +0100, Uladzislau Rezki (Sony) wrote:
>>>>>> The kfree_rcu()'s single argument name is deprecated therefore
>>>>>> rename it to kfree_rcu_mightsleep() variant. The goal is explicitly
>>>>>> underline that it is for sleepable contexts.
>>>>>>
>>>>>> Please check the RXE driver in a way that a single argument can
>>>>>> be used. Briefly looking at it and rcu_head should be embed to
>>>>>> free an obj over RCU-core. The context might be atomic.
>>>>>>
>>>>>> Cc: Bob Pearson <rpearsonhpe@gmail.com>
>>>>>> Cc: Jason Gunthorpe <jgg@nvidia.com>
>>>>>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>>>>>> ---
>>>>>>  drivers/infiniband/sw/rxe/rxe_pool.c | 2 +-
>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>> Could you please add you reviwed-by or Acked-by tags so we can bring
>>>>> our series with renaming for the next merge window?
>>>>>
>>>>> Thanks!
>>>>>
>>>> __rxe_cleanup() can be called in two contexts, sleepable and not.
>>>> Therefore usage of a single argument of the kvfree_rcu() is not correct
>>>> here.
>>>>
>>>> Could you please fix and check your driver? If my above statement
>>>> is not correct, please provide Acked-by or Reviwed-by tags to the
>>>> path that is in question.
>>>>
>>>> Otherwise please add an rcu_head in your data to free objects over
>>>> kvfree_rcu() using double argument API.
>>>>
>>>> Could you please support?
>>>
>>> Also this one needs renaming? It came in because of the commit in 6.3-rc1:
>>> 72a03627443d ("RDMA/rxe: Remove rxe_alloc()")
>>>
>>> It could be squashed into this patch itself since it is infiniband related.
>>>
>>> Paul noticed that this breaks dropping the old API on -next, so it is
>>> blocking the renaming.
>>>
>>> ---8<-----------------------
>>>
>>> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
>>> index b10aa1580a64..ae3a100e18fb 100644
>>> --- a/drivers/infiniband/sw/rxe/rxe_mr.c
>>> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
>>> @@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>>>  		return -EINVAL;
>>>  
>>>  	rxe_cleanup(mr);
>>> -	kfree_rcu(mr);
>>> +	kfree_rcu_mightsleep(mr);
>>>  	return 0;
>>>  }
>>>  
>> I just got back from a 1 week vacation and missed all this.
>>
>> The "RDMA/rxe: Remove rxe_alloc()" patch just moved the memory allocation
>> for MR (verbs) objects outside of the rxe_pool code since it only applied
>> to MRs and not the other verbs objects (AH, QP, CQ, ...).  That code has to
>> handle a unique situation for AH objects which can be created or destroyed
>> by connection manager code in atomic context while all the other ones
>> including MRs are always created/destroyed in process context. All objects
>> other than MR's are created/destroyed in the rdma-core code
>> (drivers/infiniband/core).
>>
>> The rxe driver keeps xarray's of pointers to the various objects which are
>> protected by rcu locking and so it made sense to use kfree_rcu to delete
>> the object with a delay. In the MR case ..._mightsleep seems harmless and
>> should not be an issue.
>>
>> However on reflection, all the references to the MR objects are ref counted
>> and they have been dropped before reaching the kfree and so there really
>> never was a good reason to use kfree_rcu in the first place. So a better
>> solution would be to replace kfree_rcu with kfree. There is a timeout in
>> completion_done() that triggers a WARN_ON() and this is only seen if the
>> driver is broken for some reason but that is equivalent to getting a seg
>> fault so no reason to further delay the kfree.
>>
>> Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
> 
> Thanks, I am planning to send the following patch for 6.4 consideration,
> please let me know if you disagree. Still testing it.
> 
> ----8<---
> 
> From: Joel Fernandes (Google) <joel@joelfernandes.org>
> Subject: [PATCH] RDMA/rxe: Rename kfree_rcu() to kvfree_rcu_mightsleep()
> 
> The k[v]free_rcu() macro's single-argument form is deprecated.
> Therefore switch to the new k[v]free_rcu_mightsleep() variant. The goal
> is to avoid accidental use of the single-argument forms, which can
> introduce functionality bugs in atomic contexts and latency bugs in
> non-atomic contexts.
> 
> There is no functionality change with this patch.
> 
> Link: https://lore.kernel.org/rcu/20230201150815.409582-1-urezki@gmail.com
> Acked-by: Zhu Yanjun <zyjzyj2000@gmail.com>
> Reviewed-by: Bob Pearson <rpearsonhpe@gmail.com>
> Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
> Fixes: 72a03627443d ("RDMA/rxe: Remove rxe_alloc()")
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
>  drivers/infiniband/sw/rxe/rxe_mr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
> index b10aa1580a64..ae3a100e18fb 100644
> --- a/drivers/infiniband/sw/rxe/rxe_mr.c
> +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
> @@ -731,7 +731,7 @@ int rxe_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata)
>  		return -EINVAL;
>  
>  	rxe_cleanup(mr);
> -	kfree_rcu(mr);
> +	kfree_rcu_mightsleep(mr);
>  	return 0;
>  }
>  

I would prefer just

-	kfree_rcu(mr);
+	kfree(mr);

but either one will work.

Bob

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
                   ` (11 preceding siblings ...)
  2023-02-23 14:57 ` Jens Axboe
@ 2023-03-15 19:14 ` Steven Rostedt
  2023-03-15 19:16   ` Jens Axboe
  12 siblings, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-15 19:14 UTC (permalink / raw)
  To: Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed,  1 Feb 2023 16:08:06 +0100
"Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:

> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> 
> 1.
> The problem is that, recently we have run into a precedent when
> a user intended to give a second argument to kfree_rcu() API but
> forgot to do it in a code so a call became as a single argument
> of kfree_rcu() API.
> 
> 2.
> Such mistyping can lead to hidden bags where sleeping is forbidden.
> 
> 3.
> _mightsleep() prefix gives much more information for which contexts
> it can be used for.

My honest opinion is that I hate that name "kvfree_rcu_mightsleep()" ;-)

As I honestly don't know why it might sleep.

I didn't care about the name before, but now that it's touching code I
maintain I do care ;-)

Why not call it:

 kvfree_rcu_synchronize()

?

As that is much more descriptive of what it does. Especially since these
ugly names are popping up in my code because kvfree_rcu() replaced a
rcu_synchronize() in the first place.

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:14 ` Steven Rostedt
@ 2023-03-15 19:16   ` Jens Axboe
  2023-03-15 19:25     ` Uladzislau Rezki
  0 siblings, 1 reply; 77+ messages in thread
From: Jens Axboe @ 2023-03-15 19:16 UTC (permalink / raw)
  To: Steven Rostedt, Uladzislau Rezki (Sony)
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On 3/15/23 1:14?PM, Steven Rostedt wrote:
> On Wed,  1 Feb 2023 16:08:06 +0100
> "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:
> 
>> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
>> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
>>
>> 1.
>> The problem is that, recently we have run into a precedent when
>> a user intended to give a second argument to kfree_rcu() API but
>> forgot to do it in a code so a call became as a single argument
>> of kfree_rcu() API.
>>
>> 2.
>> Such mistyping can lead to hidden bags where sleeping is forbidden.
>>
>> 3.
>> _mightsleep() prefix gives much more information for which contexts
>> it can be used for.
> 
> My honest opinion is that I hate that name "kvfree_rcu_mightsleep()" ;-)
> 
> As I honestly don't know why it might sleep.
> 
> I didn't care about the name before, but now that it's touching code I
> maintain I do care ;-)
> 
> Why not call it:
> 
>  kvfree_rcu_synchronize()
> 
> ?
> 
> As that is much more descriptive of what it does. Especially since these
> ugly names are popping up in my code because kvfree_rcu() replaced a
> rcu_synchronize() in the first place.

This was my main complaint too, kvfree_rcu_mightsleep() is an absolutely
horrible name for an API... But nobody seemed to care about that!

I like the _synchronize() suggestion, as it matches other RCU naming.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:16   ` Jens Axboe
@ 2023-03-15 19:25     ` Uladzislau Rezki
  2023-03-15 19:34       ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-15 19:25 UTC (permalink / raw)
  To: Jens Axboe, Steven Rostedt
  Cc: Steven Rostedt, Uladzislau Rezki (Sony),
	LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 01:16:20PM -0600, Jens Axboe wrote:
> On 3/15/23 1:14?PM, Steven Rostedt wrote:
> > On Wed,  1 Feb 2023 16:08:06 +0100
> > "Uladzislau Rezki (Sony)" <urezki@gmail.com> wrote:
> > 
> >> This small series is based on Paul's "dev" branch. Head is 6002817348a1c610dc1b1c01ff81654cdec12be4
> >> it renames a single argument of k[v]free_rcu() to its new k[v]free_rcu_mightsleep() name.
> >>
> >> 1.
> >> The problem is that, recently we have run into a precedent when
> >> a user intended to give a second argument to kfree_rcu() API but
> >> forgot to do it in a code so a call became as a single argument
> >> of kfree_rcu() API.
> >>
> >> 2.
> >> Such mistyping can lead to hidden bags where sleeping is forbidden.
> >>
> >> 3.
> >> _mightsleep() prefix gives much more information for which contexts
> >> it can be used for.
> > 
> > My honest opinion is that I hate that name "kvfree_rcu_mightsleep()" ;-)
> > 
> > As I honestly don't know why it might sleep.
> > 
> > I didn't care about the name before, but now that it's touching code I
> > maintain I do care ;-)
> > 
> > Why not call it:
> > 
> >  kvfree_rcu_synchronize()
> > 
> > ?
> > 
> > As that is much more descriptive of what it does. Especially since these
> > ugly names are popping up in my code because kvfree_rcu() replaced a
> > rcu_synchronize() in the first place.
> 
> This was my main complaint too, kvfree_rcu_mightsleep() is an absolutely
> horrible name for an API... But nobody seemed to care about that!
> 
> I like the _synchronize() suggestion, as it matches other RCU naming.
> 
This is basically about what it does. If you renamed it to "_synchronize()"
in reality it would not mean that it always a synchronous call, most of the
time it is not whereas the name would point that it is.

--
Uladzislau Rezki


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:25     ` Uladzislau Rezki
@ 2023-03-15 19:34       ` Steven Rostedt
  2023-03-15 19:57         ` Joel Fernandes
  2023-03-16  0:42         ` Theodore Ts'o
  0 siblings, 2 replies; 77+ messages in thread
From: Steven Rostedt @ 2023-03-15 19:34 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: Jens Axboe, LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, 15 Mar 2023 20:25:10 +0100
Uladzislau Rezki <urezki@gmail.com> wrote:

> > This was my main complaint too, kvfree_rcu_mightsleep() is an absolutely
> > horrible name for an API... But nobody seemed to care about that!
> > 
> > I like the _synchronize() suggestion, as it matches other RCU naming.
> >   
> This is basically about what it does. If you renamed it to "_synchronize()"
> in reality it would not mean that it always a synchronous call, most of the
> time it is not whereas the name would point that it is.

No, just comment it.

I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
getting ridiculous.

Still, I will replace that code back to a kfree() and rcu_synchonize() than
to let that other name get in.

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:34       ` Steven Rostedt
@ 2023-03-15 19:57         ` Joel Fernandes
  2023-03-15 20:28           ` Steven Rostedt
  2023-03-16  0:42         ` Theodore Ts'o
  1 sibling, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-15 19:57 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

Hey Steve,

On Wed, Mar 15, 2023 at 3:35 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 15 Mar 2023 20:25:10 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
>
> > > This was my main complaint too, kvfree_rcu_mightsleep() is an absolutely
> > > horrible name for an API... But nobody seemed to care about that!
> > >
> > > I like the _synchronize() suggestion, as it matches other RCU naming.
> > >
> > This is basically about what it does. If you renamed it to "_synchronize()"
> > in reality it would not mean that it always a synchronous call, most of the
> > time it is not whereas the name would point that it is.
>
> No, just comment it.
>
> I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
> getting ridiculous.

No, synchronize() is incorrect. The code really can sleep for other
reasons like memory allocation. It is not that simple of an
implementation as one may imagine. mightsleep is really the correct
wording IMHO.

> Still, I will replace that code back to a kfree() and rcu_synchonize() than
> to let that other name get in.

I think it is too late for that for now, we already have conversions
going into the other subsystems, that means we'll have to redo all
that over again (even if it sounded like a good idea, which it is
not).

I would rather you just did: "#define kvfree_rcu_tracing
#kvfree_rcu_mightsleep", or something like that, if it is really a
problem. ;-)

Also you are really the first person I know of who has a problem with that name.

 - Joel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:57         ` Joel Fernandes
@ 2023-03-15 20:28           ` Steven Rostedt
  2023-03-15 21:07             ` Uladzislau Rezki
  2023-03-15 22:08             ` Joel Fernandes
  0 siblings, 2 replies; 77+ messages in thread
From: Steven Rostedt @ 2023-03-15 20:28 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, 15 Mar 2023 15:57:02 -0400
Joel Fernandes <joel@joelfernandes.org> wrote:

> > I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
> > getting ridiculous.  
> 
> No, synchronize() is incorrect. The code really can sleep for other
> reasons like memory allocation. It is not that simple of an
> implementation as one may imagine. mightsleep is really the correct
> wording IMHO.
> 
> > Still, I will replace that code back to a kfree() and rcu_synchonize() than
> > to let that other name get in.  
> 
> I think it is too late for that for now, we already have conversions
> going into the other subsystems, that means we'll have to redo all
> that over again (even if it sounded like a good idea, which it is
> not).
> 
> I would rather you just did: "#define kvfree_rcu_tracing
> #kvfree_rcu_mightsleep", or something like that, if it is really a
> problem. ;-)
> 
> Also you are really the first person I know of who has a problem with that name.

I guess you didn't read Jens's reply.

The main issue I have with this, is that "might_sleep" is just an
implementation issue. It has *nothing* to do with what the call is about.
It is only about freeing something with RCU. It has nothing to do with
sleeping. I don't use it because it might sleep. I use it to free something.

If you don't like kvfree_rcu_synchronization() then call it
kvfree_rcu_headless() and note that currently it can sleep. Because in
the future, if we come up with an implementation where we it doesn't sleep,
then we don't need to go and rename all the users in the future.

See where I have the problem with the name "might_sleep"?

-- Steve


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 20:28           ` Steven Rostedt
@ 2023-03-15 21:07             ` Uladzislau Rezki
  2023-03-15 21:14               ` Uladzislau Rezki
  2023-03-15 22:08             ` Joel Fernandes
  1 sibling, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-15 21:07 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Joel Fernandes, Uladzislau Rezki, Jens Axboe, LKML, RCU,
	Paul E . McKenney, Oleksiy Avramchenko, Philipp Reisner,
	Bryan Tan, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 04:28:40PM -0400, Steven Rostedt wrote:
> On Wed, 15 Mar 2023 15:57:02 -0400
> Joel Fernandes <joel@joelfernandes.org> wrote:
> 
> > > I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
> > > getting ridiculous.  
> > 
> > No, synchronize() is incorrect. The code really can sleep for other
> > reasons like memory allocation. It is not that simple of an
> > implementation as one may imagine. mightsleep is really the correct
> > wording IMHO.
> > 
> > > Still, I will replace that code back to a kfree() and rcu_synchonize() than
> > > to let that other name get in.  
> > 
> > I think it is too late for that for now, we already have conversions
> > going into the other subsystems, that means we'll have to redo all
> > that over again (even if it sounded like a good idea, which it is
> > not).
> > 
> > I would rather you just did: "#define kvfree_rcu_tracing
> > #kvfree_rcu_mightsleep", or something like that, if it is really a
> > problem. ;-)
> > 
> > Also you are really the first person I know of who has a problem with that name.
> 
> I guess you didn't read Jens's reply.
> 
> The main issue I have with this, is that "might_sleep" is just an
> implementation issue. It has *nothing* to do with what the call is about.
> It is only about freeing something with RCU. It has nothing to do with
> sleeping. I don't use it because it might sleep. I use it to free something.
> 
> If you don't like kvfree_rcu_synchronization() then call it
> kvfree_rcu_headless() and note that currently it can sleep. Because in
> the future, if we come up with an implementation where we it doesn't sleep,
> then we don't need to go and rename all the users in the future.
> 
> See where I have the problem with the name "might_sleep"?
> 
In that sense there is no need in renaming it. The current name of
single argument is kvfree_rcu(ptr). It is documented that it can sleep.

According to its name it is clear that it is headless since there
is no a second argument.

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 21:07             ` Uladzislau Rezki
@ 2023-03-15 21:14               ` Uladzislau Rezki
  0 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-15 21:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Steven Rostedt, Joel Fernandes, Jens Axboe, LKML, RCU,
	Paul E . McKenney, Oleksiy Avramchenko, Philipp Reisner,
	Bryan Tan, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 10:07:22PM +0100, Uladzislau Rezki wrote:
> On Wed, Mar 15, 2023 at 04:28:40PM -0400, Steven Rostedt wrote:
> > On Wed, 15 Mar 2023 15:57:02 -0400
> > Joel Fernandes <joel@joelfernandes.org> wrote:
> > 
> > > > I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
> > > > getting ridiculous.  
> > > 
> > > No, synchronize() is incorrect. The code really can sleep for other
> > > reasons like memory allocation. It is not that simple of an
> > > implementation as one may imagine. mightsleep is really the correct
> > > wording IMHO.
> > > 
> > > > Still, I will replace that code back to a kfree() and rcu_synchonize() than
> > > > to let that other name get in.  
> > > 
> > > I think it is too late for that for now, we already have conversions
> > > going into the other subsystems, that means we'll have to redo all
> > > that over again (even if it sounded like a good idea, which it is
> > > not).
> > > 
> > > I would rather you just did: "#define kvfree_rcu_tracing
> > > #kvfree_rcu_mightsleep", or something like that, if it is really a
> > > problem. ;-)
> > > 
> > > Also you are really the first person I know of who has a problem with that name.
> > 
> > I guess you didn't read Jens's reply.
> > 
> > The main issue I have with this, is that "might_sleep" is just an
> > implementation issue. It has *nothing* to do with what the call is about.
> > It is only about freeing something with RCU. It has nothing to do with
> > sleeping. I don't use it because it might sleep. I use it to free something.
> > 
> > If you don't like kvfree_rcu_synchronization() then call it
> > kvfree_rcu_headless() and note that currently it can sleep. Because in
> > the future, if we come up with an implementation where we it doesn't sleep,
> > then we don't need to go and rename all the users in the future.
> > 
> > See where I have the problem with the name "might_sleep"?
> > 
> In that sense there is no need in renaming it. The current name of
> single argument is kvfree_rcu(ptr). It is documented that it can sleep.
> 
> According to its name it is clear that it is headless since there
> is no a second argument.
> 
Forgot to add. I agree with you that currently it can sleep but it
does not mean that a future stays the same, thus there might be an
extra need in renaming again.

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 20:28           ` Steven Rostedt
  2023-03-15 21:07             ` Uladzislau Rezki
@ 2023-03-15 22:08             ` Joel Fernandes
  2023-03-15 22:26               ` Steven Rostedt
  2023-03-16  1:25               ` Theodore Ts'o
  1 sibling, 2 replies; 77+ messages in thread
From: Joel Fernandes @ 2023-03-15 22:08 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

Hey Steve,

On Wed, Mar 15, 2023 at 4:28 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 15 Mar 2023 15:57:02 -0400
> Joel Fernandes <joel@joelfernandes.org> wrote:
>
> > > I was going to suggest "kvfree_rcu_might_synchronize()" but that's just
> > > getting ridiculous.
> >
> > No, synchronize() is incorrect. The code really can sleep for other
> > reasons like memory allocation. It is not that simple of an
> > implementation as one may imagine. mightsleep is really the correct
> > wording IMHO.
> >
> > > Still, I will replace that code back to a kfree() and rcu_synchonize() than
> > > to let that other name get in.
> >
> > I think it is too late for that for now, we already have conversions
> > going into the other subsystems, that means we'll have to redo all
> > that over again (even if it sounded like a good idea, which it is
> > not).
> >
> > I would rather you just did: "#define kvfree_rcu_tracing
> > #kvfree_rcu_mightsleep", or something like that, if it is really a
> > problem. ;-)
> >
> > Also you are really the first person I know of who has a problem with that name.
>
> I guess you didn't read Jens's reply.

Apologies, I am trying to keep up with email but this week is crazy.

> The main issue I have with this, is that "might_sleep" is just an
> implementation issue. It has *nothing* to do with what the call is about.
> It is only about freeing something with RCU. It has nothing to do with
> sleeping. I don't use it because it might sleep. I use it to free something.
>
> If you don't like kvfree_rcu_synchronization() then call it
> kvfree_rcu_headless() and note that currently it can sleep. Because in
> the future, if we come up with an implementation where we it doesn't sleep,
> then we don't need to go and rename all the users in the future.
>
> See where I have the problem with the name "might_sleep"?

I am doubtful there may be a future where it does not sleep. Why?
Because you need an rcu_head *somewhere*. Unlike with debubojects,
which involves a lock-free per-CPU pool and a locked global pool, and
has the liberty to shutdown if it runs out of objects -- in RCU code
it doesn't have that liberty and it has to just keep working.  The
kfree_rcu code does have pools of rcu_head as well, but that is not
thought to be enough to prevent OOM when memory needs to be given
back.  AFAIK -- the synchronize_rcu() in there is a last resort and
undesirable (supposed to happen only when running out of
objects/memory).

Also "mightsleep" means just that -- *might*.  That covers the fact
that sleeping may not happen ;-).

This is just my opinion and I will defer to Uladzislau, Paul and you
on how to proceed. Another option is "cansleep" which has the same
number of characters as headless. I don't believe expecting users to
read comments is practical, since we did already have comments and
there was a bug in the usage that triggered this whole series.

thanks,

 - Joel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 22:08             ` Joel Fernandes
@ 2023-03-15 22:26               ` Steven Rostedt
  2023-03-16  2:13                 ` Joel Fernandes
  2023-03-16  1:25               ` Theodore Ts'o
  1 sibling, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-15 22:26 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, 15 Mar 2023 18:08:19 -0400
Joel Fernandes <joel@joelfernandes.org> wrote:

> I am doubtful there may be a future where it does not sleep. Why?
> Because you need an rcu_head *somewhere*. Unlike with debubojects,
> which involves a lock-free per-CPU pool and a locked global pool, and
> has the liberty to shutdown if it runs out of objects -- in RCU code
> it doesn't have that liberty and it has to just keep working.  The
> kfree_rcu code does have pools of rcu_head as well, but that is not
> thought to be enough to prevent OOM when memory needs to be given
> back.  AFAIK -- the synchronize_rcu() in there is a last resort and
> undesirable (supposed to happen only when running out of
> objects/memory).

And everything you said above is still implementation, and the user of
kvfree_rcu() doesn't care.

The only thing different about the two cases is that one is headless.

> 
> Also "mightsleep" means just that -- *might*.  That covers the fact
> that sleeping may not happen ;-).

Yes, and even though you are doubtful of it not ever having a non-sleep
implementation, there is still a chance that there might be something
someday.

> 
> This is just my opinion and I will defer to Uladzislau, Paul and you
> on how to proceed. Another option is "cansleep" which has the same
> number of characters as headless. I don't believe expecting users to
> read comments is practical, since we did already have comments and
> there was a bug in the usage that triggered this whole series.

The point of "headless" is that is the rational for this version of
kvfree_rcu(). It doesn't have a head. That's an API name that users care
about.

Why not call it kvfree_rcu_alloc() ? It allocates right?

We have might_sleep() in lots of places. In fact, the default is things
might sleep. We don't need to call it out. That's what the might_sleep()
call is for. Usually it's the non sleep version that is special.

We could call the normal kvfree_rcu() "kvfree_rcu_inatomic()" ;-)

But I guess that would be a bigger change.

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-09 13:45   ` Uladzislau Rezki
@ 2023-03-15 22:36     ` Steven Rostedt
  2023-03-15 23:19       ` Jens Axboe
                         ` (3 more replies)
  0 siblings, 4 replies; 77+ messages in thread
From: Steven Rostedt @ 2023-03-15 22:36 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Thu, 9 Mar 2023 14:45:21 +0100
Uladzislau Rezki <urezki@gmail.com> wrote:

> > The kvfree_rcu()'s single argument name is deprecated therefore
> > rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> > underline that it is for sleepable contexts.
> > 
> > Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> >  
> Could you please add you reviwed-by or Acked-by tags so we can bring
> our series with renaming for the next merge window?

I don't know. Perhaps we should just apply this patch and not worry about
sleeping and whatnot.

-- Steve

diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
index 04f0fdae19a1..5de945a8f61d 100644
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -76,6 +76,7 @@ static unsigned long osnoise_options	= OSN_DEFAULT_OPTIONS;
 struct osnoise_instance {
 	struct list_head	list;
 	struct trace_array	*tr;
+	struct rcu_head		rcu;
 };
 
 static struct list_head osnoise_instances;
@@ -159,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
 	if (!found)
 		return;
 
-	kvfree_rcu(inst);
+	kvfree_rcu(inst, rcu);
 }
 
 /*
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 20d0c4a97633..ef5fafb40c76 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -1172,7 +1172,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
 		return -ENOENT;
 
 	list_del_rcu(&link->list);
-	kvfree_rcu(link);
+	kvfree_rcu(link, rcu);
 
 	if (list_empty(&tp->event->files))
 		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index ef8ed3b65d05..e6037752dcf0 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -256,6 +256,7 @@ struct trace_probe {
 struct event_file_link {
 	struct trace_event_file		*file;
 	struct list_head		list;
+	struct rcu_head			rcu;
 };
 
 static inline bool trace_probe_test_flag(struct trace_probe *tp,

^ permalink raw reply related	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-15 22:36     ` Steven Rostedt
@ 2023-03-15 23:19       ` Jens Axboe
  2023-03-16  0:37         ` Paul E. McKenney
  2023-03-16  8:16       ` Uladzislau Rezki
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 77+ messages in thread
From: Jens Axboe @ 2023-03-15 23:19 UTC (permalink / raw)
  To: Steven Rostedt, Uladzislau Rezki
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On 3/15/23 4:36 PM, Steven Rostedt wrote:
> On Thu, 9 Mar 2023 14:45:21 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
>>> The kvfree_rcu()'s single argument name is deprecated therefore
>>> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
>>> underline that it is for sleepable contexts.
>>>
>>> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
>>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>>>  
>> Could you please add you reviwed-by or Acked-by tags so we can bring
>> our series with renaming for the next merge window?
> 
> I don't know. Perhaps we should just apply this patch and not worry about
> sleeping and whatnot.

That's a cop out, just removing the one case you care about. Fact is
the naming is awful, and the 1/2 argument thing is making it worse.
If a big change is warranted, why not do it right and ACTUALLY
get it right?

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-15 23:19       ` Jens Axboe
@ 2023-03-16  0:37         ` Paul E. McKenney
  2023-03-16  2:23           ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16  0:37 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Steven Rostedt, Uladzislau Rezki, LKML, RCU, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 05:19:18PM -0600, Jens Axboe wrote:
> On 3/15/23 4:36 PM, Steven Rostedt wrote:
> > On Thu, 9 Mar 2023 14:45:21 +0100
> > Uladzislau Rezki <urezki@gmail.com> wrote:
> > 
> >>> The kvfree_rcu()'s single argument name is deprecated therefore
> >>> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> >>> underline that it is for sleepable contexts.
> >>>
> >>> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> >>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> >>>  
> >> Could you please add you reviwed-by or Acked-by tags so we can bring
> >> our series with renaming for the next merge window?
> > 
> > I don't know. Perhaps we should just apply this patch and not worry about
> > sleeping and whatnot.

That does work, and I am guessing that the size increase is not a big
problem for you there.

> That's a cop out, just removing the one case you care about. Fact is
> the naming is awful, and the 1/2 argument thing is making it worse.
> If a big change is warranted, why not do it right and ACTUALLY
> get it right?

You both do realize that the kvfree_rcu_mightsleep() definition is
already in mainline, right?

Anyway, to sum up, kvfree_rcu_mightsleep()--or whatever the entire
community eventually decides to name it--can do any of the following:

1.	Put the pointer into an already allocated array of pointers.

2.	Allocate a new array of pointers, have the allocation succeed
	without sleeping, then put the pointer into an already allocated
	array of pointers.

3.	Allocate a new array of pointers, have the allocation succeed
	after sleeping, then put the pointer into an already allocated
	array of pointers.

4.	Attempt to allocate a new array of pointers, have the allocation
	fail (presumably after sleeping), then invoke synchronize_rcu()
	directly.

Too much fun!  ;-)

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 19:34       ` Steven Rostedt
  2023-03-15 19:57         ` Joel Fernandes
@ 2023-03-16  0:42         ` Theodore Ts'o
  1 sibling, 0 replies; 77+ messages in thread
From: Theodore Ts'o @ 2023-03-16  0:42 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Julian Anastasov

On Wed, Mar 15, 2023 at 03:34:48PM -0400, Steven Rostedt wrote:
> 
> Still, I will replace that code back to a kfree() and rcu_synchonize() than
> to let that other name get in.

That will have a performance hit relaive to kfree_rcu_mightsleep().
If that's OK with you, sure, you can do that.

Personally, I don't have a lot of problem with that name, which is why
I ack'ed the change for ext4.

						- Ted

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 22:08             ` Joel Fernandes
  2023-03-15 22:26               ` Steven Rostedt
@ 2023-03-16  1:25               ` Theodore Ts'o
  2023-03-16  2:15                 ` Steven Rostedt
  2023-03-16  2:52                 ` Paul E. McKenney
  1 sibling, 2 replies; 77+ messages in thread
From: Theodore Ts'o @ 2023-03-16  1:25 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Steven Rostedt, Uladzislau Rezki, Jens Axboe, LKML, RCU,
	Paul E . McKenney, Oleksiy Avramchenko, Philipp Reisner,
	Bryan Tan, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Julian Anastasov

On Wed, Mar 15, 2023 at 06:08:19PM -0400, Joel Fernandes wrote:
> 
> I am doubtful there may be a future where it does not sleep. Why?
> Because you need an rcu_head *somewhere*.

I think the real problem was that this won't sleep:

   kfree_rcu(ptr, rhf);

While this *could* sleep:

   kfree_rcu(ptr);

So the the original sin was to try to make the same mistake that C++
did --- which is to think that it's good to have functions that have
the same name but different function signatures, and in some cases,
different semantic meanings because they have different implementations.

Personally, this is why I refuse to use C++ for any of my personal
projects --- this kind of "magic" looks good, but it's a great way to
potentially shoot yourself (or worse, your users) in the foot.

So separating out the two-argument kfree_rcu() from the one-argument
kfree_rcu(), by renaming the latter to something else is IMHO, a
Really F***** Good Idea.  So while, sure, kfree_rcu_mightsleep() might
be a little awkward, the name documents the potential landmind
involved with using that function, that's a good thing.  Because do
you really think users will always conscientiously check the
documentation and/or the implementation before using the interface?  :-)

If you hate that name, one other possibility is to try to use the
two-argument form kfree_rcu() and arrange to *have* a rcu_head in the
structure.  That's going to be better from a performance perspective,
and thus kinder to the end user than using rcu_synchronize().

Cheers,

					- Ted

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-15 22:26               ` Steven Rostedt
@ 2023-03-16  2:13                 ` Joel Fernandes
  2023-03-16  2:50                   ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-16  2:13 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

Hey Steve,

On Wed, Mar 15, 2023 at 6:26 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
[...]
> > Also "mightsleep" means just that -- *might*.  That covers the fact
> > that sleeping may not happen ;-).
>
> Yes, and even though you are doubtful of it not ever having a non-sleep
> implementation, there is still a chance that there might be something
> someday.

Perhaps if it never sleeps, then we would introduce back the
single-arg kvfree_rcu() and delete the kvfree_rcu_mightsleep()` at
that point, since it would not serve any purpose.

> > This is just my opinion and I will defer to Uladzislau, Paul and you
> > on how to proceed. Another option is "cansleep" which has the same
> > number of characters as headless. I don't believe expecting users to
> > read comments is practical, since we did already have comments and
> > there was a bug in the usage that triggered this whole series.
>
> The point of "headless" is that is the rational for this version of
> kvfree_rcu(). It doesn't have a head. That's an API name that users care
> about.
>
> Why not call it kvfree_rcu_alloc() ? It allocates right?

Sure, but one can say now that allocating is an implementation detail? ;-)

Also, it may sound strange to have 'free' and 'alloc' in the same name.

> We have might_sleep() in lots of places. In fact, the default is things
> might sleep. We don't need to call it out. That's what the might_sleep()
> call is for. Usually it's the non sleep version that is special.
>
> We could call the normal kvfree_rcu() "kvfree_rcu_inatomic()" ;-)

Heh, I actually like 'inatomic' alot ;-)

> But I guess that would be a bigger change.
>

True.

thanks,

 - Joel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-16  1:25               ` Theodore Ts'o
@ 2023-03-16  2:15                 ` Steven Rostedt
  2023-03-16  2:52                 ` Paul E. McKenney
  1 sibling, 0 replies; 77+ messages in thread
From: Steven Rostedt @ 2023-03-16  2:15 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Joel Fernandes, Uladzislau Rezki, Jens Axboe, LKML, RCU,
	Paul E . McKenney, Oleksiy Avramchenko, Philipp Reisner,
	Bryan Tan, Eric Dumazet, Bob Pearson, Ariel Levkovich,
	Julian Anastasov

On Wed, 15 Mar 2023 21:25:16 -0400
"Theodore Ts'o" <tytso@mit.edu> wrote:

> On Wed, Mar 15, 2023 at 06:08:19PM -0400, Joel Fernandes wrote:
> > 
> > I am doubtful there may be a future where it does not sleep. Why?
> > Because you need an rcu_head *somewhere*.  
> 
> I think the real problem was that this won't sleep:
> 
>    kfree_rcu(ptr, rhf);
> 
> While this *could* sleep:
> 
>    kfree_rcu(ptr);
> 
> So the the original sin was to try to make the same mistake that C++
> did --- which is to think that it's good to have functions that have
> the same name but different function signatures, and in some cases,
> different semantic meanings because they have different implementations.
> 
> Personally, this is why I refuse to use C++ for any of my personal
> projects --- this kind of "magic" looks good, but it's a great way to
> potentially shoot yourself (or worse, your users) in the foot.
> 
> So separating out the two-argument kfree_rcu() from the one-argument
> kfree_rcu(), by renaming the latter to something else is IMHO, a
> Really F***** Good Idea.  So while, sure, kfree_rcu_mightsleep() might
> be a little awkward, the name documents the potential landmind
> involved with using that function, that's a good thing.  Because do
> you really think users will always conscientiously check the
> documentation and/or the implementation before using the interface?  :-)

I agree with everything you said above, and feel that having the same name
with two different semantics was not a good way to go. Not to mention, I
avoid C++ for basically the same reasons (plus others).

> 
> If you hate that name, one other possibility is to try to use the
> two-argument form kfree_rcu() and arrange to *have* a rcu_head in the
> structure.  That's going to be better from a performance perspective,
> and thus kinder to the end user than using rcu_synchronize().

Which is the what I last suggested doing.

  https://lore.kernel.org/all/20230315183648.5164af0f@gandalf.local.home/

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16  0:37         ` Paul E. McKenney
@ 2023-03-16  2:23           ` Steven Rostedt
  2023-03-16  3:44             ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-16  2:23 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Jens Axboe, Uladzislau Rezki, LKML, RCU, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, 15 Mar 2023 17:37:30 -0700
"Paul E. McKenney" <paulmck@kernel.org> wrote:

> 
> That does work, and I am guessing that the size increase is not a big
> problem for you there.

Well, I was fine with it as long as it stayed in the headers, where
ugliness is warmly welcomed. Just ask all the #ifdefs.

> 
> > That's a cop out, just removing the one case you care about. Fact is
> > the naming is awful, and the 1/2 argument thing is making it worse.
> > If a big change is warranted, why not do it right and ACTUALLY
> > get it right?  
> 
> You both do realize that the kvfree_rcu_mightsleep() definition is
> already in mainline, right?
> 
> Anyway, to sum up, kvfree_rcu_mightsleep()--or whatever the entire
> community eventually decides to name it--can do any of the following:
> 
> 1.	Put the pointer into an already allocated array of pointers.
> 
> 2.	Allocate a new array of pointers, have the allocation succeed
> 	without sleeping, then put the pointer into an already allocated
> 	array of pointers.
> 
> 3.	Allocate a new array of pointers, have the allocation succeed
> 	after sleeping, then put the pointer into an already allocated
> 	array of pointers.
> 
> 4.	Attempt to allocate a new array of pointers, have the allocation
> 	fail (presumably after sleeping), then invoke synchronize_rcu()
> 	directly.
> 
> Too much fun!  ;-)
> 

  kvfree_rcu_kitchen_sink() ?

  kvfree_rcu_goldie_locks()?

I honestly like the name "headless" as that perfectly describes the
difference between kvfree_rcu(arg1, arg2) and kvfree_rcu(arg1).

Whereas mightsleep() is confusing to me because it doesn't tell me why
kvfree_rcu() has two args and kvfree_rcu_mightsleep() has only one.
Usually, code that has two sleep variants is about limiting the
functionality of the atomic friendly one.

-- Steve


^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-16  2:13                 ` Joel Fernandes
@ 2023-03-16  2:50                   ` Steven Rostedt
  2023-03-16  5:01                     ` Joel Fernandes
  0 siblings, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-16  2:50 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, 15 Mar 2023 22:13:26 -0400
Joel Fernandes <joel@joelfernandes.org> wrote:

> > Why not call it kvfree_rcu_alloc() ? It allocates right?  
> 
> Sure, but one can say now that allocating is an implementation detail? ;-)

I was being sarcastic.

But as the mighty Linus once said: "In the Internet, nobody can hear your sarcasm"

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-16  1:25               ` Theodore Ts'o
  2023-03-16  2:15                 ` Steven Rostedt
@ 2023-03-16  2:52                 ` Paul E. McKenney
  1 sibling, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16  2:52 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Joel Fernandes, Steven Rostedt, Uladzislau Rezki, Jens Axboe,
	LKML, RCU, Oleksiy Avramchenko, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Julian Anastasov

On Wed, Mar 15, 2023 at 09:25:16PM -0400, Theodore Ts'o wrote:
> On Wed, Mar 15, 2023 at 06:08:19PM -0400, Joel Fernandes wrote:
> > 
> > I am doubtful there may be a future where it does not sleep. Why?
> > Because you need an rcu_head *somewhere*.
> 
> I think the real problem was that this won't sleep:
> 
>    kfree_rcu(ptr, rhf);
> 
> While this *could* sleep:
> 
>    kfree_rcu(ptr);
> 
> So the the original sin was to try to make the same mistake that C++
> did --- which is to think that it's good to have functions that have
> the same name but different function signatures, and in some cases,
> different semantic meanings because they have different implementations.

Guilty to charges as read.  ;-)

> Personally, this is why I refuse to use C++ for any of my personal
> projects --- this kind of "magic" looks good, but it's a great way to
> potentially shoot yourself (or worse, your users) in the foot.
> 
> So separating out the two-argument kfree_rcu() from the one-argument
> kfree_rcu(), by renaming the latter to something else is IMHO, a
> Really F***** Good Idea.  So while, sure, kfree_rcu_mightsleep() might
> be a little awkward, the name documents the potential landmind
> involved with using that function, that's a good thing.  Because do
> you really think users will always conscientiously check the
> documentation and/or the implementation before using the interface?  :-)
> 
> If you hate that name, one other possibility is to try to use the
> two-argument form kfree_rcu() and arrange to *have* a rcu_head in the
> structure.  That's going to be better from a performance perspective,
> and thus kinder to the end user than using rcu_synchronize().

The original reason for single-argument kvfree_rcu() was to avoid
the need for that rcu_head.  The use case was a small data structure
with an extremely high population.

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16  2:23           ` Steven Rostedt
@ 2023-03-16  3:44             ` Paul E. McKenney
  2023-03-16  4:16               ` Joel Fernandes
  0 siblings, 1 reply; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16  3:44 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jens Axboe, Uladzislau Rezki, LKML, RCU, Oleksiy Avramchenko,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 10:23:23PM -0400, Steven Rostedt wrote:
> On Wed, 15 Mar 2023 17:37:30 -0700
> "Paul E. McKenney" <paulmck@kernel.org> wrote:
> 
> > 
> > That does work, and I am guessing that the size increase is not a big
> > problem for you there.
> 
> Well, I was fine with it as long as it stayed in the headers, where
> ugliness is warmly welcomed. Just ask all the #ifdefs.
> 
> > 
> > > That's a cop out, just removing the one case you care about. Fact is
> > > the naming is awful, and the 1/2 argument thing is making it worse.
> > > If a big change is warranted, why not do it right and ACTUALLY
> > > get it right?  
> > 
> > You both do realize that the kvfree_rcu_mightsleep() definition is
> > already in mainline, right?
> > 
> > Anyway, to sum up, kvfree_rcu_mightsleep()--or whatever the entire
> > community eventually decides to name it--can do any of the following:
> > 
> > 1.	Put the pointer into an already allocated array of pointers.
> > 
> > 2.	Allocate a new array of pointers, have the allocation succeed
> > 	without sleeping, then put the pointer into an already allocated
> > 	array of pointers.
> > 
> > 3.	Allocate a new array of pointers, have the allocation succeed
> > 	after sleeping, then put the pointer into an already allocated
> > 	array of pointers.
> > 
> > 4.	Attempt to allocate a new array of pointers, have the allocation
> > 	fail (presumably after sleeping), then invoke synchronize_rcu()
> > 	directly.
> > 
> > Too much fun!  ;-)
> > 
> 
>   kvfree_rcu_kitchen_sink() ?
> 
>   kvfree_rcu_goldie_locks()?
> 
> I honestly like the name "headless" as that perfectly describes the
> difference between kvfree_rcu(arg1, arg2) and kvfree_rcu(arg1).
> 
> Whereas mightsleep() is confusing to me because it doesn't tell me why
> kvfree_rcu() has two args and kvfree_rcu_mightsleep() has only one.
> Usually, code that has two sleep variants is about limiting the
> functionality of the atomic friendly one.

	kvfree_rcu_alloc_head()?
	kvfree_rcu_dynhead()?
	kvfree_rcu_gearhead()?
	kvfree_rcu_radiohead()?
	kvfree_rcu_getahead()?

I don't know about you guys, but to me, kvfree_rcu_mightsleep() is
sounding better and better by comparison...

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16  3:44             ` Paul E. McKenney
@ 2023-03-16  4:16               ` Joel Fernandes
  2023-03-16 12:14                 ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-16  4:16 UTC (permalink / raw)
  To: paulmck
  Cc: Steven Rostedt, Jens Axboe, Uladzislau Rezki, LKML, RCU,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, Mar 15, 2023 at 11:44 PM Paul E. McKenney <paulmck@kernel.org> wrote:
>
> On Wed, Mar 15, 2023 at 10:23:23PM -0400, Steven Rostedt wrote:
> > On Wed, 15 Mar 2023 17:37:30 -0700
> > "Paul E. McKenney" <paulmck@kernel.org> wrote:
> >
> > >
> > > That does work, and I am guessing that the size increase is not a big
> > > problem for you there.
> >
> > Well, I was fine with it as long as it stayed in the headers, where
> > ugliness is warmly welcomed. Just ask all the #ifdefs.
> >
> > >
> > > > That's a cop out, just removing the one case you care about. Fact is
> > > > the naming is awful, and the 1/2 argument thing is making it worse.
> > > > If a big change is warranted, why not do it right and ACTUALLY
> > > > get it right?
> > >
> > > You both do realize that the kvfree_rcu_mightsleep() definition is
> > > already in mainline, right?
> > >
> > > Anyway, to sum up, kvfree_rcu_mightsleep()--or whatever the entire
> > > community eventually decides to name it--can do any of the following:
> > >
> > > 1.  Put the pointer into an already allocated array of pointers.
> > >
> > > 2.  Allocate a new array of pointers, have the allocation succeed
> > >     without sleeping, then put the pointer into an already allocated
> > >     array of pointers.
> > >
> > > 3.  Allocate a new array of pointers, have the allocation succeed
> > >     after sleeping, then put the pointer into an already allocated
> > >     array of pointers.
> > >
> > > 4.  Attempt to allocate a new array of pointers, have the allocation
> > >     fail (presumably after sleeping), then invoke synchronize_rcu()
> > >     directly.
> > >
> > > Too much fun!  ;-)
> > >
> >
> >   kvfree_rcu_kitchen_sink() ?
> >
> >   kvfree_rcu_goldie_locks()?
> >
> > I honestly like the name "headless" as that perfectly describes the
> > difference between kvfree_rcu(arg1, arg2) and kvfree_rcu(arg1).
> >
> > Whereas mightsleep() is confusing to me because it doesn't tell me why
> > kvfree_rcu() has two args and kvfree_rcu_mightsleep() has only one.
> > Usually, code that has two sleep variants is about limiting the
> > functionality of the atomic friendly one.
>
>         kvfree_rcu_alloc_head()?
>         kvfree_rcu_dynhead()?
>         kvfree_rcu_gearhead()?
>         kvfree_rcu_radiohead()?
>         kvfree_rcu_getahead()?
>
> I don't know about you guys, but to me, kvfree_rcu_mightsleep() is
> sounding better and better by comparison...

Indeed, and one could argue that "headless" sounds like something out
of a horror movie ;-). Which of course does match the situation when
the API is applied incorrectly.

 - Joel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep()
  2023-03-16  2:50                   ` Steven Rostedt
@ 2023-03-16  5:01                     ` Joel Fernandes
  0 siblings, 0 replies; 77+ messages in thread
From: Joel Fernandes @ 2023-03-16  5:01 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, Jens Axboe, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, Mar 15, 2023 at 10:50 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 15 Mar 2023 22:13:26 -0400
> Joel Fernandes <joel@joelfernandes.org> wrote:
>
> > > Why not call it kvfree_rcu_alloc() ? It allocates right?
> >
> > Sure, but one can say now that allocating is an implementation detail? ;-)
>
> I was being sarcastic.
>
> But as the mighty Linus once said: "In the Internet, nobody can hear your sarcasm"
>

I guess it's official then - the internet has killed sarcasm. I
suppose we'll all have to resort to using more obvious forms of humor,
like dad jokes. ;)

 - Joel

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-15 22:36     ` Steven Rostedt
  2023-03-15 23:19       ` Jens Axboe
@ 2023-03-16  8:16       ` Uladzislau Rezki
  2023-03-16 13:56         ` Steven Rostedt
  2023-03-16 17:54       ` Paul E. McKenney
  2023-03-16 17:57       ` Uladzislau Rezki
  3 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-16  8:16 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

> On Thu, 9 Mar 2023 14:45:21 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > > The kvfree_rcu()'s single argument name is deprecated therefore
> > > rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> > > underline that it is for sleepable contexts.
> > > 
> > > Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > >  
> > Could you please add you reviwed-by or Acked-by tags so we can bring
> > our series with renaming for the next merge window?
> 
> I don't know. Perhaps we should just apply this patch and not worry about
> sleeping and whatnot.
> 
> -- Steve
> 
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index 04f0fdae19a1..5de945a8f61d 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -76,6 +76,7 @@ static unsigned long osnoise_options	= OSN_DEFAULT_OPTIONS;
>  struct osnoise_instance {
>  	struct list_head	list;
>  	struct trace_array	*tr;
> +	struct rcu_head		rcu;
>  };
>  
>  static struct list_head osnoise_instances;
> @@ -159,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
>  	if (!found)
>  		return;
>  
> -	kvfree_rcu(inst);
> +	kvfree_rcu(inst, rcu);
>  }
>  
>  /*
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 20d0c4a97633..ef5fafb40c76 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -1172,7 +1172,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
>  		return -ENOENT;
>  
>  	list_del_rcu(&link->list);
> -	kvfree_rcu(link);
> +	kvfree_rcu(link, rcu);
>  
>  	if (list_empty(&tp->event->files))
>  		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index ef8ed3b65d05..e6037752dcf0 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -256,6 +256,7 @@ struct trace_probe {
>  struct event_file_link {
>  	struct trace_event_file		*file;
>  	struct list_head		list;
> +	struct rcu_head			rcu;
>  };
>  
>  static inline bool trace_probe_test_flag(struct trace_probe *tp,
>
struct foo_a {
  int a;
  int b;
};

your obj size is 8 byte

struct foo_b {
  struct rcu_head rcu;
  int a;
  int b;
};

now it becomes 16 + 8 = 24 bytes. In reallity a foo_b object
will be 32 bytes since there is no slab for 24 bytes:

<snip>
  kmalloc-32         19840  19840     32  128    1 : tunables    0    0    0 : slabdata    155    155      0
  kmalloc-16         28857  28928     16  256    1 : tunables    0    0    0 : slabdata    113    113      0
  kmalloc-8          37376  37376      8  512    1 : tunables    0    0    0 : slabdata     73     73      0
<snip>

if we allocate 512 objects of foo_a it would be 4096 bytes
in case of foo_b it is 24 * 512 = 12228 bytes.

single argument will give you 4096 + 512 * 8 = 8192 bytes
int terms of memory consumtion.

And double argument will not give you better performance comparing
with a single argument.

So it depends on what you want to achieve by that patch.

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16  4:16               ` Joel Fernandes
@ 2023-03-16 12:14                 ` Steven Rostedt
  2023-03-16 14:56                   ` Paul E. McKenney
  0 siblings, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-16 12:14 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: paulmck, Jens Axboe, Uladzislau Rezki, LKML, RCU,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, 16 Mar 2023 00:16:39 -0400
Joel Fernandes <joel@joelfernandes.org> wrote:

> Indeed, and one could argue that "headless" sounds like something out
> of a horror movie ;-). Which of course does match the situation when
> the API is applied incorrectly.

Well, "headless" is a common term in IT.

   https://en.wikipedia.org/wiki/Headless_software


We could be specific to what horror movie/story, and call it:

  kvfree_rcu_sleepy_hollow()

Which will imply both headless *and* might_sleep!

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16  8:16       ` Uladzislau Rezki
@ 2023-03-16 13:56         ` Steven Rostedt
  2023-03-16 15:05           ` Uladzislau Rezki
  2023-03-16 15:12           ` Paul E. McKenney
  0 siblings, 2 replies; 77+ messages in thread
From: Steven Rostedt @ 2023-03-16 13:56 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: LKML, RCU, Paul E . McKenney, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Thu, 16 Mar 2023 09:16:37 +0100
Uladzislau Rezki <urezki@gmail.com> wrote:

> > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> > index ef8ed3b65d05..e6037752dcf0 100644
> > --- a/kernel/trace/trace_probe.h
> > +++ b/kernel/trace/trace_probe.h
> > @@ -256,6 +256,7 @@ struct trace_probe {
> >  struct event_file_link {
> >  	struct trace_event_file		*file;
> >  	struct list_head		list;
> > +	struct rcu_head			rcu;
> >  };
> >  
> >  static inline bool trace_probe_test_flag(struct trace_probe *tp,
> >  
> struct foo_a {
>   int a;
>   int b;
> };

Most machines today are 64 bits, even low end machines.

 struct foo_a {
	long long a;
	long long b;
 };

is more accurate. That's 16 bytes.

Although it is more likely off because list_head is a double pointer. But
let's just go with this, as the amount really doesn't matter here.

> 
> your obj size is 8 byte
> 
> struct foo_b {
>   struct rcu_head rcu;

Isn't rcu_head defined as;

struct callback_head {
        struct callback_head *next;
        void (*func)(struct callback_head *head);
} __attribute__((aligned(sizeof(void *))));
#define rcu_head callback_head

Which makes it 8 not 16 on 32 bit as well?

>   int a;
>   int b;
> };

So it should be 8 + 8 = 16, on 32 bit and 16 + 16 = 32 on 64bit.

> 
> now it becomes 16 + 8 = 24 bytes. In reallity a foo_b object
> will be 32 bytes since there is no slab for 24 bytes:
> 
> <snip>
>   kmalloc-32         19840  19840     32  128    1 : tunables    0    0    0 : slabdata    155    155      0
>   kmalloc-16         28857  28928     16  256    1 : tunables    0    0    0 : slabdata    113    113      0
>   kmalloc-8          37376  37376      8  512    1 : tunables    0    0    0 : slabdata     73     73      0
> <snip>
> 
> if we allocate 512 objects of foo_a it would be 4096 bytes
> in case of foo_b it is 24 * 512 = 12228 bytes.

This is for probe events. We usually allocate 1, maybe 2. Oh, some may even
allocate 100 to be crazy. But each probe event is in reality much larger
(1K perhaps) as each one allocates dentry's, inodes, etc. So 8 or 16 bytes
extra is still lost in the noise.

> 
> single argument will give you 4096 + 512 * 8 = 8192 bytes
> int terms of memory consumtion.

If someone allocate 512 instances, that would be closer to a meg in size
without this change. 8k is probably less than 1%

> 
> And double argument will not give you better performance comparing
> with a single argument.

It will, because it will no longer have to allocate anything if need be.
Note, when it doesn't allocate the system is probably mostly idle and we
don't care about performance, but when it needs allocation, that's likely a
time when performance is a bit more important.

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 12:14                 ` Steven Rostedt
@ 2023-03-16 14:56                   ` Paul E. McKenney
  0 siblings, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16 14:56 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Joel Fernandes, Jens Axboe, Uladzislau Rezki, LKML, RCU,
	Oleksiy Avramchenko, Philipp Reisner, Bryan Tan, Eric Dumazet,
	Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, Mar 16, 2023 at 08:14:24AM -0400, Steven Rostedt wrote:
> On Thu, 16 Mar 2023 00:16:39 -0400
> Joel Fernandes <joel@joelfernandes.org> wrote:
> 
> > Indeed, and one could argue that "headless" sounds like something out
> > of a horror movie ;-). Which of course does match the situation when
> > the API is applied incorrectly.
> 
> Well, "headless" is a common term in IT.
> 
>    https://en.wikipedia.org/wiki/Headless_software

Indeed it is.  But RCU is incapable of headlessness, so in the
kvfree_rcu_mightsleep() case, the rcu_head is dynamically allocated.

> We could be specific to what horror movie/story, and call it:
> 
>   kvfree_rcu_sleepy_hollow()
> 
> Which will imply both headless *and* might_sleep!

Heh!  That one is almost bad enough to be good!  Almost!  ;-)

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 13:56         ` Steven Rostedt
@ 2023-03-16 15:05           ` Uladzislau Rezki
  2023-03-17  9:05             ` Uladzislau Rezki
  2023-03-16 15:12           ` Paul E. McKenney
  1 sibling, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-16 15:05 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, Mar 16, 2023 at 09:56:53AM -0400, Steven Rostedt wrote:
> On Thu, 16 Mar 2023 09:16:37 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> > > index ef8ed3b65d05..e6037752dcf0 100644
> > > --- a/kernel/trace/trace_probe.h
> > > +++ b/kernel/trace/trace_probe.h
> > > @@ -256,6 +256,7 @@ struct trace_probe {
> > >  struct event_file_link {
> > >  	struct trace_event_file		*file;
> > >  	struct list_head		list;
> > > +	struct rcu_head			rcu;
> > >  };
> > >  
> > >  static inline bool trace_probe_test_flag(struct trace_probe *tp,
> > >  
> > struct foo_a {
> >   int a;
> >   int b;
> > };
> 
> Most machines today are 64 bits, even low end machines.
> 
>  struct foo_a {
> 	long long a;
> 	long long b;
>  };
> 
> is more accurate. That's 16 bytes.
> 
> Although it is more likely off because list_head is a double pointer. But
> let's just go with this, as the amount really doesn't matter here.
> 
> > 
> > your obj size is 8 byte
> > 
> > struct foo_b {
> >   struct rcu_head rcu;
> 
> Isn't rcu_head defined as;
> 
> struct callback_head {
>         struct callback_head *next;
>         void (*func)(struct callback_head *head);
> } __attribute__((aligned(sizeof(void *))));
> #define rcu_head callback_head
> 
> Which makes it 8 not 16 on 32 bit as well?
> 
> >   int a;
> >   int b;
> > };
> 
> So it should be 8 + 8 = 16, on 32 bit and 16 + 16 = 32 on 64bit.
> 
> > 
> > now it becomes 16 + 8 = 24 bytes. In reallity a foo_b object
> > will be 32 bytes since there is no slab for 24 bytes:
> > 
> > <snip>
> >   kmalloc-32         19840  19840     32  128    1 : tunables    0    0    0 : slabdata    155    155      0
> >   kmalloc-16         28857  28928     16  256    1 : tunables    0    0    0 : slabdata    113    113      0
> >   kmalloc-8          37376  37376      8  512    1 : tunables    0    0    0 : slabdata     73     73      0
> > <snip>
> > 
> > if we allocate 512 objects of foo_a it would be 4096 bytes
> > in case of foo_b it is 24 * 512 = 12228 bytes.
> 
> This is for probe events. We usually allocate 1, maybe 2. Oh, some may even
> allocate 100 to be crazy. But each probe event is in reality much larger
> (1K perhaps) as each one allocates dentry's, inodes, etc. So 8 or 16 bytes
> extra is still lost in the noise.
> 
> > 
> > single argument will give you 4096 + 512 * 8 = 8192 bytes
> > int terms of memory consumtion.
> 
> If someone allocate 512 instances, that would be closer to a meg in size
> without this change. 8k is probably less than 1%
> 
In percentage. My case. (12228 - 8192) * 100 / 12228 = ~33% difference.

> > 
> > And double argument will not give you better performance comparing
> > with a single argument.
> 
> It will, because it will no longer have to allocate anything if need be.
> Note, when it doesn't allocate the system is probably mostly idle and we
> don't care about performance, but when it needs allocation, that's likely a
> time when performance is a bit more important.
> 
The problem further is about pointer chasing, like comparing arrays and
lists. It will take longer time to offload all pointers.

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 13:56         ` Steven Rostedt
  2023-03-16 15:05           ` Uladzislau Rezki
@ 2023-03-16 15:12           ` Paul E. McKenney
  1 sibling, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16 15:12 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Thu, Mar 16, 2023 at 09:56:53AM -0400, Steven Rostedt wrote:
> On Thu, 16 Mar 2023 09:16:37 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> > > index ef8ed3b65d05..e6037752dcf0 100644
> > > --- a/kernel/trace/trace_probe.h
> > > +++ b/kernel/trace/trace_probe.h
> > > @@ -256,6 +256,7 @@ struct trace_probe {
> > >  struct event_file_link {
> > >  	struct trace_event_file		*file;
> > >  	struct list_head		list;
> > > +	struct rcu_head			rcu;
> > >  };
> > >  
> > >  static inline bool trace_probe_test_flag(struct trace_probe *tp,
> > >  
> > struct foo_a {
> >   int a;
> >   int b;
> > };
> 
> Most machines today are 64 bits, even low end machines.
> 
>  struct foo_a {
> 	long long a;
> 	long long b;
>  };
> 
> is more accurate. That's 16 bytes.
> 
> Although it is more likely off because list_head is a double pointer. But
> let's just go with this, as the amount really doesn't matter here.
> 
> > 
> > your obj size is 8 byte
> > 
> > struct foo_b {
> >   struct rcu_head rcu;
> 
> Isn't rcu_head defined as;
> 
> struct callback_head {
>         struct callback_head *next;
>         void (*func)(struct callback_head *head);
> } __attribute__((aligned(sizeof(void *))));
> #define rcu_head callback_head
> 
> Which makes it 8 not 16 on 32 bit as well?
> 
> >   int a;
> >   int b;
> > };
> 
> So it should be 8 + 8 = 16, on 32 bit and 16 + 16 = 32 on 64bit.
> 
> > 
> > now it becomes 16 + 8 = 24 bytes. In reallity a foo_b object
> > will be 32 bytes since there is no slab for 24 bytes:
> > 
> > <snip>
> >   kmalloc-32         19840  19840     32  128    1 : tunables    0    0    0 : slabdata    155    155      0
> >   kmalloc-16         28857  28928     16  256    1 : tunables    0    0    0 : slabdata    113    113      0
> >   kmalloc-8          37376  37376      8  512    1 : tunables    0    0    0 : slabdata     73     73      0
> > <snip>
> > 
> > if we allocate 512 objects of foo_a it would be 4096 bytes
> > in case of foo_b it is 24 * 512 = 12228 bytes.
> 
> This is for probe events. We usually allocate 1, maybe 2. Oh, some may even
> allocate 100 to be crazy. But each probe event is in reality much larger
> (1K perhaps) as each one allocates dentry's, inodes, etc. So 8 or 16 bytes
> extra is still lost in the noise.

Agreed, in this case, there is almost no penalty for adding an rcu_head
structure to the probe event...

> > single argument will give you 4096 + 512 * 8 = 8192 bytes
> > int terms of memory consumtion.
> 
> If someone allocate 512 instances, that would be closer to a meg in size
> without this change. 8k is probably less than 1%
> 
> > 
> > And double argument will not give you better performance comparing
> > with a single argument.
> 
> It will, because it will no longer have to allocate anything if need be.
> Note, when it doesn't allocate the system is probably mostly idle and we
> don't care about performance, but when it needs allocation, that's likely a
> time when performance is a bit more important.

... and also agreed that there are performance benefits to doing so,
especially under OOM conditions.

							Thanx, Paul

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-15 22:36     ` Steven Rostedt
  2023-03-15 23:19       ` Jens Axboe
  2023-03-16  8:16       ` Uladzislau Rezki
@ 2023-03-16 17:54       ` Paul E. McKenney
  2023-03-16 17:57       ` Uladzislau Rezki
  3 siblings, 0 replies; 77+ messages in thread
From: Paul E. McKenney @ 2023-03-16 17:54 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Oleksiy Avramchenko, Jens Axboe,
	Philipp Reisner, Bryan Tan, Eric Dumazet, Bob Pearson,
	Ariel Levkovich, Theodore Ts'o, Julian Anastasov

On Wed, Mar 15, 2023 at 06:36:48PM -0400, Steven Rostedt wrote:
> On Thu, 9 Mar 2023 14:45:21 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > > The kvfree_rcu()'s single argument name is deprecated therefore
> > > rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> > > underline that it is for sleepable contexts.
> > > 
> > > Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > >  
> > Could you please add you reviwed-by or Acked-by tags so we can bring
> > our series with renaming for the next merge window?
> 
> I don't know. Perhaps we should just apply this patch and not worry about
> sleeping and whatnot.

Just in case it is not clear:

Acked-by: Paul E. McKenney <paulmck@kernel.org>

> -- Steve
> 
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index 04f0fdae19a1..5de945a8f61d 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -76,6 +76,7 @@ static unsigned long osnoise_options	= OSN_DEFAULT_OPTIONS;
>  struct osnoise_instance {
>  	struct list_head	list;
>  	struct trace_array	*tr;
> +	struct rcu_head		rcu;
>  };
>  
>  static struct list_head osnoise_instances;
> @@ -159,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
>  	if (!found)
>  		return;
>  
> -	kvfree_rcu(inst);
> +	kvfree_rcu(inst, rcu);
>  }
>  
>  /*
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 20d0c4a97633..ef5fafb40c76 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -1172,7 +1172,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
>  		return -ENOENT;
>  
>  	list_del_rcu(&link->list);
> -	kvfree_rcu(link);
> +	kvfree_rcu(link, rcu);
>  
>  	if (list_empty(&tp->event->files))
>  		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index ef8ed3b65d05..e6037752dcf0 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -256,6 +256,7 @@ struct trace_probe {
>  struct event_file_link {
>  	struct trace_event_file		*file;
>  	struct list_head		list;
> +	struct rcu_head			rcu;
>  };
>  
>  static inline bool trace_probe_test_flag(struct trace_probe *tp,

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-15 22:36     ` Steven Rostedt
                         ` (2 preceding siblings ...)
  2023-03-16 17:54       ` Paul E. McKenney
@ 2023-03-16 17:57       ` Uladzislau Rezki
  2023-03-16 18:01         ` Joel Fernandes
  3 siblings, 1 reply; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-16 17:57 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Wed, Mar 15, 2023 at 06:36:48PM -0400, Steven Rostedt wrote:
> On Thu, 9 Mar 2023 14:45:21 +0100
> Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> > > The kvfree_rcu()'s single argument name is deprecated therefore
> > > rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
> > > underline that it is for sleepable contexts.
> > > 
> > > Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
> > >  
> > Could you please add you reviwed-by or Acked-by tags so we can bring
> > our series with renaming for the next merge window?
> 
> I don't know. Perhaps we should just apply this patch and not worry about
> sleeping and whatnot.
> 
> -- Steve
> 
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index 04f0fdae19a1..5de945a8f61d 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -76,6 +76,7 @@ static unsigned long osnoise_options	= OSN_DEFAULT_OPTIONS;
>  struct osnoise_instance {
>  	struct list_head	list;
>  	struct trace_array	*tr;
> +	struct rcu_head		rcu;
>  };
>  
>  static struct list_head osnoise_instances;
> @@ -159,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
>  	if (!found)
>  		return;
>  
> -	kvfree_rcu(inst);
> +	kvfree_rcu(inst, rcu);
>  }
>  
>  /*
> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
> index 20d0c4a97633..ef5fafb40c76 100644
> --- a/kernel/trace/trace_probe.c
> +++ b/kernel/trace/trace_probe.c
> @@ -1172,7 +1172,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
>  		return -ENOENT;
>  
>  	list_del_rcu(&link->list);
> -	kvfree_rcu(link);
> +	kvfree_rcu(link, rcu);
>  
>  	if (list_empty(&tp->event->files))
>  		trace_probe_clear_flag(tp, TP_FLAG_TRACE);
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index ef8ed3b65d05..e6037752dcf0 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -256,6 +256,7 @@ struct trace_probe {
>  struct event_file_link {
>  	struct trace_event_file		*file;
>  	struct list_head		list;
> +	struct rcu_head			rcu;
>  };
>  
>  static inline bool trace_probe_test_flag(struct trace_probe *tp,
>
Anyway i do not see any problems with it

Acked-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 17:57       ` Uladzislau Rezki
@ 2023-03-16 18:01         ` Joel Fernandes
  2023-03-18 16:11           ` Steven Rostedt
  0 siblings, 1 reply; 77+ messages in thread
From: Joel Fernandes @ 2023-03-16 18:01 UTC (permalink / raw)
  To: Uladzislau Rezki
  Cc: Steven Rostedt, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov, Joel Fernandes



> On Mar 16, 2023, at 1:58 PM, Uladzislau Rezki <urezki@gmail.com> wrote:
> 
> On Wed, Mar 15, 2023 at 06:36:48PM -0400, Steven Rostedt wrote:
>> On Thu, 9 Mar 2023 14:45:21 +0100
>> Uladzislau Rezki <urezki@gmail.com> wrote:
>> 
>>>> The kvfree_rcu()'s single argument name is deprecated therefore
>>>> rename it to kvfree_rcu_mightsleep() variant. The goal is explicitly
>>>> underline that it is for sleepable contexts.
>>>> 
>>>> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
>>>> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
>>>> 
>>> Could you please add you reviwed-by or Acked-by tags so we can bring
>>> our series with renaming for the next merge window?
>> 
>> I don't know. Perhaps we should just apply this patch and not worry about
>> sleeping and whatnot.
>> 
>> -- Steve
>> 
>> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
>> index 04f0fdae19a1..5de945a8f61d 100644
>> --- a/kernel/trace/trace_osnoise.c
>> +++ b/kernel/trace/trace_osnoise.c
>> @@ -76,6 +76,7 @@ static unsigned long osnoise_options    = OSN_DEFAULT_OPTIONS;
>> struct osnoise_instance {
>>    struct list_head    list;
>>    struct trace_array    *tr;
>> +    struct rcu_head        rcu;
>> };
>> 
>> static struct list_head osnoise_instances;
>> @@ -159,7 +160,7 @@ static void osnoise_unregister_instance(struct trace_array *tr)
>>    if (!found)
>>        return;
>> 
>> -    kvfree_rcu(inst);
>> +    kvfree_rcu(inst, rcu);
>> }
>> 
>> /*
>> diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
>> index 20d0c4a97633..ef5fafb40c76 100644
>> --- a/kernel/trace/trace_probe.c
>> +++ b/kernel/trace/trace_probe.c
>> @@ -1172,7 +1172,7 @@ int trace_probe_remove_file(struct trace_probe *tp,
>>        return -ENOENT;
>> 
>>    list_del_rcu(&link->list);
>> -    kvfree_rcu(link);
>> +    kvfree_rcu(link, rcu);
>> 
>>    if (list_empty(&tp->event->files))
>>        trace_probe_clear_flag(tp, TP_FLAG_TRACE);
>> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
>> index ef8ed3b65d05..e6037752dcf0 100644
>> --- a/kernel/trace/trace_probe.h
>> +++ b/kernel/trace/trace_probe.h
>> @@ -256,6 +256,7 @@ struct trace_probe {
>> struct event_file_link {
>>    struct trace_event_file        *file;
>>    struct list_head        list;
>> +    struct rcu_head            rcu;
>> };
>> 
>> static inline bool trace_probe_test_flag(struct trace_probe *tp,
>> 
> Anyway i do not see any problems with it
> 
> Acked-by: Uladzislau Rezki (Sony) <urezki@gmail.com>

Just to clarify, we are dropping the original patch and instead taking Steves version?

If so, Steve please send a patch when you are able to and with Vlads Ack,
we can take it via the RCU tree if that is Ok with you.

Thanks,

 - Joel


> 
> --
> Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 15:05           ` Uladzislau Rezki
@ 2023-03-17  9:05             ` Uladzislau Rezki
  0 siblings, 0 replies; 77+ messages in thread
From: Uladzislau Rezki @ 2023-03-17  9:05 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Steven Rostedt, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, Mar 16, 2023 at 04:05:09PM +0100, Uladzislau Rezki wrote:
> On Thu, Mar 16, 2023 at 09:56:53AM -0400, Steven Rostedt wrote:
> > On Thu, 16 Mar 2023 09:16:37 +0100
> > Uladzislau Rezki <urezki@gmail.com> wrote:
> > 
> > > > diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> > > > index ef8ed3b65d05..e6037752dcf0 100644
> > > > --- a/kernel/trace/trace_probe.h
> > > > +++ b/kernel/trace/trace_probe.h
> > > > @@ -256,6 +256,7 @@ struct trace_probe {
> > > >  struct event_file_link {
> > > >  	struct trace_event_file		*file;
> > > >  	struct list_head		list;
> > > > +	struct rcu_head			rcu;
> > > >  };
> > > >  
> > > >  static inline bool trace_probe_test_flag(struct trace_probe *tp,
> > > >  
> > > struct foo_a {
> > >   int a;
> > >   int b;
> > > };
> > 
> > Most machines today are 64 bits, even low end machines.
> > 
> >  struct foo_a {
> > 	long long a;
> > 	long long b;
> >  };
> > 
> > is more accurate. That's 16 bytes.
> > 
> > Although it is more likely off because list_head is a double pointer. But
> > let's just go with this, as the amount really doesn't matter here.
> > 
> > > 
> > > your obj size is 8 byte
> > > 
> > > struct foo_b {
> > >   struct rcu_head rcu;
> > 
> > Isn't rcu_head defined as;
> > 
> > struct callback_head {
> >         struct callback_head *next;
> >         void (*func)(struct callback_head *head);
> > } __attribute__((aligned(sizeof(void *))));
> > #define rcu_head callback_head
> > 
> > Which makes it 8 not 16 on 32 bit as well?
> > 
> > >   int a;
> > >   int b;
> > > };
> > 
> > So it should be 8 + 8 = 16, on 32 bit and 16 + 16 = 32 on 64bit.
> > 
> > > 
> > > now it becomes 16 + 8 = 24 bytes. In reallity a foo_b object
> > > will be 32 bytes since there is no slab for 24 bytes:
> > > 
> > > <snip>
> > >   kmalloc-32         19840  19840     32  128    1 : tunables    0    0    0 : slabdata    155    155      0
> > >   kmalloc-16         28857  28928     16  256    1 : tunables    0    0    0 : slabdata    113    113      0
> > >   kmalloc-8          37376  37376      8  512    1 : tunables    0    0    0 : slabdata     73     73      0
> > > <snip>
> > > 
> > > if we allocate 512 objects of foo_a it would be 4096 bytes
> > > in case of foo_b it is 24 * 512 = 12228 bytes.
> > 
> > This is for probe events. We usually allocate 1, maybe 2. Oh, some may even
> > allocate 100 to be crazy. But each probe event is in reality much larger
> > (1K perhaps) as each one allocates dentry's, inodes, etc. So 8 or 16 bytes
> > extra is still lost in the noise.
> > 
> > > 
> > > single argument will give you 4096 + 512 * 8 = 8192 bytes
> > > int terms of memory consumtion.
> > 
> > If someone allocate 512 instances, that would be closer to a meg in size
> > without this change. 8k is probably less than 1%
> > 
> In percentage. My case. (12228 - 8192) * 100 / 12228 = ~33% difference.
> 
> > > 
> > > And double argument will not give you better performance comparing
> > > with a single argument.
> > 
> > It will, because it will no longer have to allocate anything if need be.
> > Note, when it doesn't allocate the system is probably mostly idle and we
> > don't care about performance, but when it needs allocation, that's likely a
> > time when performance is a bit more important.
> > 
> The problem further is about pointer chasing, like comparing arrays and
> lists. It will take longer time to offload all pointers.
> 
Since i have a data, IMHO it is better to share than not:

--bootargs "rcuscale.kfree_rcu_test=1 rcuscale.kfree_nthreads=3 rcuscale.holdoff=20 rcuscale.kfree_loops=10000 torture.disable_onoff_at_boot"

# double-argument 10 run
Total time taken by all kfree'ers: 4387872408 ns, loops: 10000, batches: 958,  memory footprint: 40MB
Total time taken by all kfree'ers: 4415232304 ns, loops: 10000, batches: 982,  memory footprint: 39MB
Total time taken by all kfree'ers: 4270303081 ns, loops: 10000, batches: 955,  memory footprint: 42MB
Total time taken by all kfree'ers: 4364984147 ns, loops: 10000, batches: 953,  memory footprint: 40MB
Total time taken by all kfree'ers: 4225994506 ns, loops: 10000, batches: 942,  memory footprint: 40MB
Total time taken by all kfree'ers: 4601087346 ns, loops: 10000, batches: 1033, memory footprint: 40MB
Total time taken by all kfree'ers: 4853397855 ns, loops: 10000, batches: 1109, memory footprint: 38MB
Total time taken by all kfree'ers: 4627914204 ns, loops: 10000, batches: 1037, memory footprint: 39MB
Total time taken by all kfree'ers: 4274587317 ns, loops: 10000, batches: 938,  memory footprint: 33MB
Total time taken by all kfree'ers: 4642151205 ns, loops: 10000, batches: 1068, memory footprint: 39MB

# single-argument 10 run
Total time taken by all kfree'ers: 3661190052 ns, loops: 10000, batches: 831, memory footprint: 29MB
Total time taken by all kfree'ers: 3616277061 ns, loops: 10000, batches: 780, memory footprint: 27MB
Total time taken by all kfree'ers: 3704584439 ns, loops: 10000, batches: 810, memory footprint: 27MB
Total time taken by all kfree'ers: 3631291959 ns, loops: 10000, batches: 812, memory footprint: 28MB
Total time taken by all kfree'ers: 3610490769 ns, loops: 10000, batches: 795, memory footprint: 27MB
Total time taken by all kfree'ers: 3595446243 ns, loops: 10000, batches: 825, memory footprint: 28MB
Total time taken by all kfree'ers: 3686252889 ns, loops: 10000, batches: 784, memory footprint: 27MB
Total time taken by all kfree'ers: 3821475275 ns, loops: 10000, batches: 869, memory footprint: 27MB
Total time taken by all kfree'ers: 3740407185 ns, loops: 10000, batches: 813, memory footprint: 28MB
Total time taken by all kfree'ers: 3646684795 ns, loops: 10000, batches: 780, memory footprint: 24MB

And yes, there are side effects. For example a low memory condition.

--
Uladzislau Rezki

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-16 18:01         ` Joel Fernandes
@ 2023-03-18 16:11           ` Steven Rostedt
  2023-03-22 23:10             ` Joel Fernandes
  0 siblings, 1 reply; 77+ messages in thread
From: Steven Rostedt @ 2023-03-18 16:11 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Uladzislau Rezki, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Thu, 16 Mar 2023 14:01:30 -0400
Joel Fernandes <joel@joelfernandes.org> wrote:

> If so, Steve please send a patch when you are able to and with Vlads Ack,
> we can take it via the RCU tree if that is Ok with you.

Daniel acked it, so you can just take it as he can be responsible for that code.

For the trace_probe.c if you get an ack from Masami, then you can take
the original patch as is.

-- Steve

^ permalink raw reply	[flat|nested] 77+ messages in thread

* Re: [PATCH 04/13] tracing: Rename kvfree_rcu() to kvfree_rcu_mightsleep()
  2023-03-18 16:11           ` Steven Rostedt
@ 2023-03-22 23:10             ` Joel Fernandes
  0 siblings, 0 replies; 77+ messages in thread
From: Joel Fernandes @ 2023-03-22 23:10 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Uladzislau Rezki, LKML, RCU, Paul E . McKenney,
	Oleksiy Avramchenko, Jens Axboe, Philipp Reisner, Bryan Tan,
	Eric Dumazet, Bob Pearson, Ariel Levkovich, Theodore Ts'o,
	Julian Anastasov

On Sat, Mar 18, 2023 at 12:11:31PM -0400, Steven Rostedt wrote:
> On Thu, 16 Mar 2023 14:01:30 -0400
> Joel Fernandes <joel@joelfernandes.org> wrote:
> 
> > If so, Steve please send a patch when you are able to and with Vlads Ack,
> > we can take it via the RCU tree if that is Ok with you.
> 
> Daniel acked it, so you can just take it as he can be responsible for that code.
> 
> For the trace_probe.c if you get an ack from Masami, then you can take
> the original patch as is.


Masami, do you Ack the changes of the original patch to trace_probe.c ?

Here it is again:
https://lore.kernel.org/lkml/20230201150815.409582-5-urezki@gmail.com/


thanks,

 - Joel


^ permalink raw reply	[flat|nested] 77+ messages in thread

end of thread, other threads:[~2023-03-22 23:11 UTC | newest]

Thread overview: 77+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 15:08 [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Uladzislau Rezki (Sony)
2023-02-01 15:08 ` [PATCH 01/13] rcu/kvfree: Add kvfree_rcu_mightsleep() and kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
2023-02-02  7:54   ` Zhuo, Qiuxu
2023-02-02 15:07     ` Paul E. McKenney
2023-02-01 15:08 ` [PATCH 02/13] drbd: Rename kvfree_rcu() to kvfree_rcu_mightsleep() Uladzislau Rezki (Sony)
2023-03-09 13:39   ` Uladzislau Rezki
2023-02-01 15:08 ` [PATCH 03/13] misc: vmw_vmci: " Uladzislau Rezki (Sony)
2023-03-09 13:41   ` Uladzislau Rezki
2023-03-09 14:36   ` Vishnu Dasa
2023-02-01 15:08 ` [PATCH 04/13] tracing: " Uladzislau Rezki (Sony)
2023-03-09 13:45   ` Uladzislau Rezki
2023-03-15 22:36     ` Steven Rostedt
2023-03-15 23:19       ` Jens Axboe
2023-03-16  0:37         ` Paul E. McKenney
2023-03-16  2:23           ` Steven Rostedt
2023-03-16  3:44             ` Paul E. McKenney
2023-03-16  4:16               ` Joel Fernandes
2023-03-16 12:14                 ` Steven Rostedt
2023-03-16 14:56                   ` Paul E. McKenney
2023-03-16  8:16       ` Uladzislau Rezki
2023-03-16 13:56         ` Steven Rostedt
2023-03-16 15:05           ` Uladzislau Rezki
2023-03-17  9:05             ` Uladzislau Rezki
2023-03-16 15:12           ` Paul E. McKenney
2023-03-16 17:54       ` Paul E. McKenney
2023-03-16 17:57       ` Uladzislau Rezki
2023-03-16 18:01         ` Joel Fernandes
2023-03-18 16:11           ` Steven Rostedt
2023-03-22 23:10             ` Joel Fernandes
2023-02-01 15:08 ` [PATCH 05/13] lib/test_vmalloc.c: " Uladzislau Rezki (Sony)
2023-02-01 15:08 ` [PATCH 06/13] net/sysctl: " Uladzislau Rezki (Sony)
2023-03-09 13:48   ` Uladzislau Rezki
2023-03-09 13:49   ` Uladzislau Rezki
2023-02-01 15:08 ` [PATCH 07/13] RDMA/rxe: Rename kfree_rcu() to kfree_rcu_mightsleep() Uladzislau Rezki (Sony)
2023-03-09 13:48   ` Uladzislau Rezki
2023-03-09 14:13     ` Uladzislau Rezki
2023-03-10  0:55       ` Joel Fernandes
2023-03-13 19:43         ` Bob Pearson
2023-03-15 11:50           ` Joel Fernandes
2023-03-15 18:07             ` Bob Pearson
2023-03-14  6:31       ` Zhu Yanjun
2023-02-01 15:08 ` [PATCH 08/13] net/mlx5: " Uladzislau Rezki (Sony)
2023-03-09 13:47   ` Uladzislau Rezki
2023-02-01 15:08 ` [PATCH 09/13] ext4/super: " Uladzislau Rezki (Sony)
2023-03-09 13:43   ` Uladzislau Rezki
2023-02-01 19:12 ` [PATCH 00/13] Rename k[v]free_rcu() single argument to k[v]free_rcu_mightsleep() Paul E. McKenney
2023-02-02 15:54   ` Uladzislau Rezki
2023-02-02 16:35     ` Paul E. McKenney
2023-02-23 12:45 ` Frederic Weisbecker
2023-02-23 14:29   ` Zhuo, Qiuxu
2023-02-23 15:54     ` Paul E. McKenney
2023-02-23 16:21       ` Julian Anastasov
2023-02-23 17:14         ` Paul E. McKenney
2023-02-23 17:36           ` Pablo Neira Ayuso
2023-02-23 18:21             ` Paul E. McKenney
2023-02-23 14:57 ` Jens Axboe
2023-02-23 18:31   ` Paul E. McKenney
2023-02-23 19:36     ` Jens Axboe
2023-02-23 19:47       ` Paul E. McKenney
2023-02-23 19:57         ` Jens Axboe
2023-03-15 19:14 ` Steven Rostedt
2023-03-15 19:16   ` Jens Axboe
2023-03-15 19:25     ` Uladzislau Rezki
2023-03-15 19:34       ` Steven Rostedt
2023-03-15 19:57         ` Joel Fernandes
2023-03-15 20:28           ` Steven Rostedt
2023-03-15 21:07             ` Uladzislau Rezki
2023-03-15 21:14               ` Uladzislau Rezki
2023-03-15 22:08             ` Joel Fernandes
2023-03-15 22:26               ` Steven Rostedt
2023-03-16  2:13                 ` Joel Fernandes
2023-03-16  2:50                   ` Steven Rostedt
2023-03-16  5:01                     ` Joel Fernandes
2023-03-16  1:25               ` Theodore Ts'o
2023-03-16  2:15                 ` Steven Rostedt
2023-03-16  2:52                 ` Paul E. McKenney
2023-03-16  0:42         ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.