Thread (9 messages) read the whole thread 9 messages, 3 authors, 1d ago

Re: [PATCH net-next v2] rds: synchronize info callbacks with module unload

From: Paolo Abeni <pabeni@redhat.com>
Date: 2026-07-30 10:02:05
Also in: linux-rdma, lkml

Hi,

It looks like I was too optimistic in my previous reply.

On 7/27/26 7:48 PM, Chengfeng Ye wrote:
quoted hunk ↗ jump to hunk
@@ -78,8 +80,13 @@ void rds_info_register_func(int optname, rds_info_func func)
 	BUG_ON(optname < RDS_INFO_FIRST || optname > RDS_INFO_LAST);
 
 	spin_lock(&rds_info_lock);
-	BUG_ON(rds_info_funcs[offset]);
-	rds_info_funcs[offset] = func;
+	/* Validate the latest published slot value. */
+	if (WARN_ON_ONCE(smp_load_acquire(&rds_info_funcs[offset]))) {
This read is under the same lock that perform the store. It's totally
unclear why smp_load_acquire() would be needed here. Very reasonably
it's not.
quoted hunk ↗ jump to hunk
+		spin_unlock(&rds_info_lock);
+		return;
+	}
+	/* Pair with lockless callback lookup. */
+	smp_store_release(&rds_info_funcs[offset], func);
 	spin_unlock(&rds_info_lock);
 }
 EXPORT_SYMBOL_GPL(rds_info_register_func);
@@ -91,9 +98,15 @@ void rds_info_deregister_func(int optname, rds_info_func func)
 	BUG_ON(optname < RDS_INFO_FIRST || optname > RDS_INFO_LAST);
 
 	spin_lock(&rds_info_lock);
-	BUG_ON(rds_info_funcs[offset] != func);
-	rds_info_funcs[offset] = NULL;
+	/* Validate the latest published slot value. */
+	if (WARN_ON_ONCE(smp_load_acquire(&rds_info_funcs[offset]) != func)) {
Same here.

/P
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help