[RFC PATCH 06/30] softirq: Introduce disabled softirq vectors bits
From: Frederic Weisbecker
Date: Wed Oct 10 2018 - 19:12:54 EST
Disabling the softirqs is currently an all-or-nothing operation: either
all softirqs are enabled or none of them. However we plan to introduce a
per vector granularity of this ability to improve latency response and
make each softirq vector interruptible by the others.
The first step carried here is to provide the necessary APIs to control
the per-vector enable bits.
Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---
arch/s390/include/asm/hardirq.h | 7 +++++-
include/linux/interrupt.h | 54 +++++++++++++++++++++++++++++++++++++----
2 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/arch/s390/include/asm/hardirq.h b/arch/s390/include/asm/hardirq.h
index 84ad789..5a6c5c7 100644
--- a/arch/s390/include/asm/hardirq.h
+++ b/arch/s390/include/asm/hardirq.h
@@ -13,7 +13,12 @@
#include <asm/lowcore.h>
-#define local_softirq_pending() (S390_lowcore.softirq_data)
+#define local_softirq_data() (S390_lowcore.softirq_data)
+#define local_softirq_pending() (local_softirq_data() & SOFTIRQ_PENDING_MASK)
+#define local_softirq_disabled() (local_softirq_data() & ~SOFTIRQ_PENDING_MASK)
+#define softirq_enabled_nand(x) (S390_lowcore.softirq_data &= ~((x) << SOFTIRQ_ENABLED_SHIFT))
+#define softirq_pending_or(x) (S390_lowcore.softirq_data |= ((x) << SOFTIRQ_ENABLED_SHIFT))
+#define softirq_pending_set(x) (S390_lowcore.softirq_data = ((x) << SOFTIRQ_ENABLED_SHIFT))
#define softirq_pending_nand(x) (S390_lowcore.softirq_data &= ~(x))
#define softirq_pending_or(x) (S390_lowcore.softirq_data |= (x))
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a577a54..4882196 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -468,19 +468,63 @@ enum
#define SOFTIRQ_STOP_IDLE_MASK (~(1 << RCU_SOFTIRQ))
#define SOFTIRQ_ALL_MASK (BIT(NR_SOFTIRQS) - 1)
-#ifndef local_softirq_pending
+#define SOFTIRQ_ENABLED_SHIFT 16
+#define SOFTIRQ_PENDING_MASK (BIT(SOFTIRQ_ENABLED_SHIFT) - 1)
+
+
+#ifndef local_softirq_data
#ifndef local_softirq_data_ref
#define local_softirq_data_ref irq_stat.__softirq_data
#endif
-#define local_softirq_pending() (__this_cpu_read(local_softirq_data_ref))
-#define softirq_pending_nand(x) (__this_cpu_and(local_softirq_data_ref, ~(x)))
-#define softirq_pending_or(x) (__this_cpu_or(local_softirq_data_ref, (x)))
+static inline unsigned int local_softirq_data(void)
+{
+ return __this_cpu_read(local_softirq_data_ref);
+}
+static inline unsigned int local_softirq_enabled(void)
+{
+ return local_softirq_data() >> SOFTIRQ_ENABLED_SHIFT;
+}
+
+static inline unsigned int local_softirq_pending(void)
+{
+ return local_softirq_data() & SOFTIRQ_PENDING_MASK;
+}
+
+static inline void softirq_enabled_nand(unsigned int enabled)
+{
+ enabled <<= SOFTIRQ_ENABLED_SHIFT;
+ __this_cpu_and(local_softirq_data_ref, ~enabled);
+}
+
+static inline void softirq_enabled_or(unsigned int enabled)
+{
+ enabled <<= SOFTIRQ_ENABLED_SHIFT;
+ __this_cpu_or(local_softirq_data_ref, enabled);
+}
+
+static inline void softirq_enabled_set(unsigned int enabled)
+{
+ unsigned int data;
+
+ data = enabled << SOFTIRQ_ENABLED_SHIFT;
+ data |= local_softirq_pending();
+ __this_cpu_write(local_softirq_data_ref, data);
+}
+
+static inline void softirq_pending_nand(unsigned int pending)
+{
+ __this_cpu_and(local_softirq_data_ref, ~pending);
+}
+
+static inline void softirq_pending_or(unsigned int pending)
+{
+ __this_cpu_or(local_softirq_data_ref, pending);
+}
#endif /* local_softirq_pending */
-
/* map softirq index to softirq name. update 'softirq_to_name' in
* kernel/softirq.c when adding a new softirq.
*/
--
2.7.4