Skip to contentSkip to conversation

softirq: Replace this_cpu_write with __this_cpu_write if irq is disabled

PATCH In review Muchun Song 3 participants 3 messages Jun 18, 2019 – Jun 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 softirq: Replace this_cpu_write with __this_cpu_write if irq is disabled

Irq is disabled before this_cpu_write(), so we can Replace this_cpu_write() with __this_cpu_write().

---
 kernel/softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/softirq.c +1 -1
index 2c3382378d94..eaf3bdf7c749 100644
@@ -650,7 +650,7 @@ static int takeover_tasklets(unsigned int cpu)
 	/* Find end, append list for that CPU. */
 	if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) {
 		*__this_cpu_read(tasklet_vec.tail) = per_cpu(tasklet_vec, cpu).head;
-		this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
+		__this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
 		per_cpu(tasklet_vec, cpu).head = NULL;
 		per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head;
 	}
Signature · 1 line
2.17.1
#1 lore raw

[tip:irq/core] softirq: Use __this_cpu_write() in takeover_tasklets()

softirq: Use __this_cpu_write() in takeover_tasklets()
Commit-ID:  8afecaa68df1e94a9d634f1f961533a925f239fc
Gitweb:     https://git.kernel.org/tip/8afecaa68df1e94a9d634f1f961533a925f239fc
Author:     Muchun Song <[email protected]>
AuthorDate: Tue, 18 Jun 2019 22:33:05 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Sun, 23 Jun 2019 18:14:27 +0200

softirq: Use __this_cpu_write() in takeover_tasklets()

The code is executed with interrupts disabled, so it's safe to use __this_cpu_write().

[ tglx: Massaged changelog ]

---
 kernel/softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/softirq.c +1 -1
index 2c3382378d94..eaf3bdf7c749 100644
@@ -650,7 +650,7 @@ static int takeover_tasklets(unsigned int cpu)
 	/* Find end, append list for that CPU. */
 	if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) {
 		*__this_cpu_read(tasklet_vec.tail) = per_cpu(tasklet_vec, cpu).head;
-		this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
+		__this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
 		per_cpu(tasklet_vec, cpu).head = NULL;
 		per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head;
 	}
Tested-by on v1 1/1
#2 lore raw
In reply to Muchun Song
Quoted 4 lines · Muchun Song

Irq is disabled before this_cpu_write(), so we can Replace this_cpu_write() with __this_cpu_write().

This passes light rcutorture testing, and looks rather low risk.

Quoted 20 lines
---
 kernel/softirq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/softirq.c +1 -1
index 2c3382378d94..eaf3bdf7c749 100644
@@ -650,7 +650,7 @@ static int takeover_tasklets(unsigned int cpu)
 	/* Find end, append list for that CPU. */
 	if (&per_cpu(tasklet_vec, cpu).head != per_cpu(tasklet_vec, cpu).tail) {
 		*__this_cpu_read(tasklet_vec.tail) = per_cpu(tasklet_vec, cpu).head;
-		this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
+		__this_cpu_write(tasklet_vec.tail, per_cpu(tasklet_vec, cpu).tail);
 		per_cpu(tasklet_vec, cpu).head = NULL;
 		per_cpu(tasklet_vec, cpu).tail = &per_cpu(tasklet_vec, cpu).head;
 	}
Signature · 1 line
2.17.1