[PATCH 19/37] softirq: Convert softirq_pending_*() to set/clear mask scheme

From: Frederic Weisbecker
Date: Thu Feb 28 2019 - 12:15:50 EST


We are going to need a nand version of softirq_pending_or() in order
to clear specific bits from the pending mask.

But instead of naming the mutators after their implementation, rather
name them after their high level purpose.

Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Reviewed-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab+samsung@xxxxxxxxxx>
Cc: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Pavan Kondeti <pkondeti@xxxxxxxxxxxxxx>
Cc: Paul E . McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
Cc: David S . Miller <davem@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
---
arch/s390/include/asm/hardirq.h | 4 ++--
include/linux/interrupt.h | 5 +++--
kernel/softirq.c | 4 ++--
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/s390/include/asm/hardirq.h b/arch/s390/include/asm/hardirq.h
index 3103680487cf..54e81f520175 100644
--- a/arch/s390/include/asm/hardirq.h
+++ b/arch/s390/include/asm/hardirq.h
@@ -14,8 +14,8 @@
#include <asm/lowcore.h>

#define local_softirq_pending() (S390_lowcore.softirq_data)
-#define softirq_pending_set(x) (S390_lowcore.softirq_data = (x))
-#define softirq_pending_or(x) (S390_lowcore.softirq_data |= (x))
+#define softirq_pending_clear_mask(x) (S390_lowcore.softirq_data &= ~(x))
+#define softirq_pending_set_mask(x) (S390_lowcore.softirq_data |= (x))

#define __ARCH_IRQ_STAT
#define __ARCH_HAS_DO_SOFTIRQ
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a5dec926531b..c402770ae45b 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -472,6 +472,7 @@ enum
};

#define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
+#define SOFTIRQ_ALL_MASK (BIT(NR_SOFTIRQS) - 1)

#ifndef local_softirq_pending

@@ -480,8 +481,8 @@ enum
#endif

#define local_softirq_pending() (__this_cpu_read(local_softirq_data_ref))
-#define softirq_pending_set(x) (__this_cpu_write(local_softirq_data_ref, (x)))
-#define softirq_pending_or(x) (__this_cpu_or(local_softirq_data_ref, (x)))
+#define softirq_pending_clear_mask(x) (__this_cpu_and(local_softirq_data_ref, ~(x)))
+#define softirq_pending_set_mask(x) (__this_cpu_or(local_softirq_data_ref, (x)))

#endif /* local_softirq_pending */

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 2137c54baf98..5f167fc43ab9 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -268,7 +268,7 @@ asmlinkage __visible void __softirq_entry __do_softirq(void)

restart:
/* Reset the pending bitmask before enabling irqs */
- softirq_pending_set(0);
+ softirq_pending_clear_mask(SOFTIRQ_ALL_MASK);

local_irq_enable();

@@ -449,7 +449,7 @@ void raise_softirq(unsigned int nr)
void __raise_softirq_irqoff(unsigned int nr)
{
trace_softirq_raise(nr);
- softirq_pending_or(1UL << nr);
+ softirq_pending_set_mask(1UL << nr);
}

void open_softirq(int nr, void (*action)(struct softirq_action *))
--
2.21.0