Skip to contentSkip to conversation

smp: Use release stores for csd_lock_record() state

PATCH Superseded Usama Arif 4 participants 7 messages Jun 17 – Jun 18

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Usama Arif

author
#0 lore raw

PATCH 1/1 smp: Use release stores for csd_lock_record() state

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +2 -6
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);
 }
 
 static __always_inline void csd_lock_record(call_single_data_t *csd)
Signature · 1 line
2.53.0-Meta
maintainer
#1 lore raw
Quoted 41 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +0 -2
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 10 lines
kernel/smp.c +2 -4
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

Alan Stern

#2 lore raw
Quoted 48 lines · Alan Stern
Quoted 47 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +1 -3
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
Quoted 8 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 4 lines
kernel/smp.c +1 -3
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

in Documentation/process/submit-checklist.rst:

3) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a comment in the source code that explains the logic of what they are doing and why.

in Documentation/process/4.Coding.rst:

Certain things should always be commented. Uses of memory barriers should be accompanied by a line explaining why the barrier is necessary.

but looking in the 3000+ lines of Documentation/memory-barriers.txt won't tell anyone about that.

Signature · 1 line
~Randy
maintainer
#3 lore raw
Quoted 66 lines · Randy Dunlap
Quoted 48 lines · Alan Stern
Quoted 47 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +1 -3
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
Quoted 8 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 4 lines
kernel/smp.c +1 -3
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

in Documentation/process/submit-checklist.rst:

3) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a comment in the source code that explains the logic of what they are doing and why.

Quoted 7 lines

in Documentation/process/4.Coding.rst:

Certain things should always be commented. Uses of memory barriers should be accompanied by a line explaining why the barrier is necessary.

but looking in the 3000+ lines of Documentation/memory-barriers.txt won't tell anyone about that.

Is smp_store_release() a memory barrier? Sorry, couldn't resist... ;-)

Thanx, Paul

author
#4 lore raw
In reply to Randy Dunlap
Quoted 66 lines · Randy Dunlap
Quoted 48 lines · Alan Stern
Quoted 47 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +1 -3
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
Quoted 8 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 4 lines
kernel/smp.c +1 -3
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

in Documentation/process/submit-checklist.rst:

3) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a comment in the source code that explains the logic of what they are doing and why.

Quoted 9 lines

in Documentation/process/4.Coding.rst:

Certain things should always be commented. Uses of memory barriers should be accompanied by a line explaining why the barrier is necessary.

but looking in the 3000+ lines of Documentation/memory-barriers.txt won't tell anyone about that.

Thanks!
I will send a v2 with the below diff if there are no objections?

kernel/smp.c +10 -0
index 5ba4a20ba77d..685829875a3e 100644
@@ -182,11 +182,21 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
        if (!csd) {
+               /*
+                * Pairs with smp_load_acquire() of cur_csd in
+                * csd_lock_wait_toolong(): orders any preceding CSD
+                * callback/unlock before a remote reader observes NULL.
+                */
                smp_store_release(this_cpu_ptr(&cur_csd), NULL);
                return;
        }
        __this_cpu_write(cur_csd_func, csd->func);
        __this_cpu_write(cur_csd_info, csd->info);
+       /*
+        * Pairs with smp_load_acquire() of cur_csd in
+        * csd_lock_wait_toolong(): publishes cur_csd_func and
+        * cur_csd_info before the non-NULL pointer becomes visible.
+        */
        smp_store_release(this_cpu_ptr(&cur_csd), csd);
 }
maintainer
#5 lore raw
Quoted 83 lines · Usama Arif
Quoted 64 lines · Randy Dunlap
Quoted 48 lines · Alan Stern
Quoted 47 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +1 -3
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
Quoted 8 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 4 lines
kernel/smp.c +1 -3
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

in Documentation/process/submit-checklist.rst:

3) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a comment in the source code that explains the logic of what they are doing and why.

Quoted 9 lines

in Documentation/process/4.Coding.rst:

Certain things should always be commented. Uses of memory barriers should be accompanied by a line explaining why the barrier is necessary.

but looking in the 3000+ lines of Documentation/memory-barriers.txt won't tell anyone about that.

Thanks!
I will send a v2 with the below diff if there are no objections?

kernel/smp.c +0 -0
index 5ba4a20ba77d..685829875a3e 100644

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 189

Quoted 8 lines
kernel/smp.c +5 -0
@@ -182,11 +182,21 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
        if (!csd) {
+               /*
+                * Pairs with smp_load_acquire() of cur_csd in
+                * csd_lock_wait_toolong(): orders any preceding CSD
+                * callback/unlock before a remote reader observes NULL.
+                */

Please replace the spaces with tabs. (Probably a copy-pasta issue.)

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 1 line
kernel/smp.c +0 -0
                smp_store_release(this_cpu_ptr(&cur_csd), NULL);
		smp_store_release(this_cpu_ptr(&cur_csd), NULL); /* ^^^ */

Adding the comment as show above will satisfy tools such as checkpatch.

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 201

Quoted 11 lines
kernel/smp.c +5 -0
                return;
        }
        __this_cpu_write(cur_csd_func, csd->func);
        __this_cpu_write(cur_csd_info, csd->info);
+       /*
+        * Pairs with smp_load_acquire() of cur_csd in
+        * csd_lock_wait_toolong(): publishes cur_csd_func and
+        * cur_csd_info before the non-NULL pointer becomes visible.
+        */
        smp_store_release(this_cpu_ptr(&cur_csd), csd);
 }

The comments look good to me, but I must defer to Alan and Randy.

Thanx, Paul

author
#6 lore raw
Quoted 79 lines · Paul E. McKenney
Quoted 78 lines · Usama Arif
Quoted 64 lines · Randy Dunlap
Quoted 48 lines · Alan Stern
Quoted 47 lines · Usama Arif

__csd_lock_record() publishes per-CPU CSD debug state that is read by csd_lock_wait_toolong() on another CPU. The remote side first reads cur_csd with smp_load_acquire() and, when non-NULL, may then read the matching cur_csd_func and cur_csd_info fields.

Use smp_store_release() when publishing cur_csd so that the preceding cur_csd_func and cur_csd_info stores are ordered before the pointer that csd_lock_wait_toolong() acquires. This replaces the open-coded smp_wmb() plus plain cur_csd store with the release operation that matches the smp_load_acquire() in csd_lock_wait_toolong().

For the clear path, use smp_store_release(&cur_csd, NULL) so that clearing the diagnostic state remains ordered after the preceding callback/unlock work, without requiring a full barrier before the store. On x86 this removes the locked full barrier from the clear path; on weaker memory models it uses the release operation needed by the smp_load_acquire() in csd_lock_wait_toolong().

The old code also had smp_mb() calls around cur_csd updates. Those would only be needed if cur_csd were treated as an exact live-state marker whose publication had to be observed before callback execution or CSD unlock. CSD stall warnings do not currently have RCU-style stall-ended checks, so they already allow the stall to end while diagnostics are being assembled. The cur_csd record is therefore best-effort diagnostic context, not a precise completion/stall boundary.

---
 kernel/smp.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
kernel/smp.c +1 -3
index a0bb56bd8dda..5ba4a20ba77d 100644
@@ -182,16 +182,12 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
 	if (!csd) {
-		smp_mb(); /* NULL cur_csd after unlock. */
-		__this_cpu_write(cur_csd, NULL);
+		smp_store_release(this_cpu_ptr(&cur_csd), NULL);
 		return;
 	}
 	__this_cpu_write(cur_csd_func, csd->func);
 	__this_cpu_write(cur_csd_info, csd->info);
-	smp_wmb(); /* func and info before csd. */
Quoted 8 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 4 lines
kernel/smp.c +1 -3
-	__this_cpu_write(cur_csd, csd);
-	smp_mb(); /* Update cur_csd before function call. */
-		  /* Or before unlock, as the case may be. */
+	smp_store_release(this_cpu_ptr(&cur_csd), csd);

Isn't there a general policy in the kernel that memory barriers should be accompanied by a comment explaining what other memory barriers they synchronize with? Including such comments is a good idea in any case.

in Documentation/process/submit-checklist.rst:

3) All memory barriers {e.g., ``barrier()``, ``rmb()``, ``wmb()``} need a comment in the source code that explains the logic of what they are doing and why.

Quoted 9 lines

in Documentation/process/4.Coding.rst:

Certain things should always be commented. Uses of memory barriers should be accompanied by a line explaining why the barrier is necessary.

but looking in the 3000+ lines of Documentation/memory-barriers.txt won't tell anyone about that.

Thanks!
I will send a v2 with the below diff if there are no objections?

Quoted 15 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 189

Quoted 13 lines
kernel/smp.c +5 -0
index 5ba4a20ba77d..685829875a3e 100644
@@ -182,11 +182,21 @@ static atomic_t csd_bug_count = ATOMIC_INIT(0);
 static void __csd_lock_record(call_single_data_t *csd)
 {
        if (!csd) {
+               /*
+                * Pairs with smp_load_acquire() of cur_csd in
+                * csd_lock_wait_toolong(): orders any preceding CSD
+                * callback/unlock before a remote reader observes NULL.
+                */

Please replace the spaces with tabs. (Probably a copy-pasta issue.)

Yes, its tabs in my commit, looks like the email client messed it up.

Quoted 6 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 190

Quoted 2 lines
kernel/smp.c +0 -0
                smp_store_release(this_cpu_ptr(&cur_csd), NULL);
		smp_store_release(this_cpu_ptr(&cur_csd), NULL); /* ^^^ */

Adding the comment as show above will satisfy tools such as checkpatch.

Will do, Thanks!

Quoted 13 lines

kernel/smp.c static atomic_t csd_bug_count = ATOMIC_INIT(0); · line 201

Quoted 12 lines
kernel/smp.c +5 -0
                return;
        }
        __this_cpu_write(cur_csd_func, csd->func);
        __this_cpu_write(cur_csd_info, csd->info);
+       /*
+        * Pairs with smp_load_acquire() of cur_csd in
+        * csd_lock_wait_toolong(): publishes cur_csd_func and
+        * cur_csd_info before the non-NULL pointer becomes visible.
+        */
        smp_store_release(this_cpu_ptr(&cur_csd), csd);
 }
Quoted 1 line

The comments look good to me, but I must defer to Alan and Randy

Thanks!

Quoted 2 lines

Thanx, Paul