lkml.org 
[lkml]   [2015]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] dataplane nohz: run softirqs synchronously on user entry
Date
For tasks which have elected dataplane functionality, we run
any pending softirqs for the core before returning to userspace,
rather than ever scheduling ksoftirqd to run. The problem we
fix is that by allowing another task to run on the core, we
guarantee more interrupts in the future to the dataplane task,
which is exactly what dataplane mode is required to prevent.

This may be an alternate approach to what Mike Galbraith
recently proposed in e.g.:

https://lkml.org/lkml/2015/3/13/11

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
---
kernel/softirq.c | 14 +++++++++++++-
kernel/time/tick-sched.c | 26 +++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index 479e4436f787..bc9406337f82 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -291,6 +291,15 @@ restart:
--max_restart)
goto restart;

+ /*
+ * For dataplane tasks, waking ksoftirqd because the
+ * softirqs are slow is a bad idea; we would rather
+ * synchronously finish whatever is interrupting us,
+ * and then be able to cleanly enter dataplane mode.
+ */
+ if (tick_nohz_is_dataplane())
+ goto restart;
+
wakeup_softirqd();
}

@@ -410,8 +419,11 @@ inline void raise_softirq_irqoff(unsigned int nr)
*
* Otherwise we wake up ksoftirqd to make sure we
* schedule the softirq soon.
+ *
+ * For dataplane tasks, we will handle the softirq
+ * synchronously on return to userspace.
*/
- if (!in_interrupt())
+ if (!in_interrupt() && !tick_nohz_is_dataplane())
wakeup_softirqd();
}

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 25fdd6bdd1eb..fd0e6e5c931c 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -398,8 +398,26 @@ void __init tick_nohz_init(void)
*/
void tick_nohz_dataplane_enter(void)
{
+ /*
+ * Check for softirqs as close as possible to our return to
+ * userspace, and run any that are waiting. We need to ensure
+ * that we can safely avoid running softirqd, which will cause
+ * interrupts for nohz_full tasks. Note that interrupts may
+ * be enabled internally by do_softirq().
+ */
+ do_softirq();
+
/* Drain the pagevecs to avoid unnecessary IPI flushes later. */
lru_add_drain();
+
+ /*
+ * Disable interrupts again since other code running in this
+ * function may have enabled them, and the caller expects
+ * interrupts to be disabled on return. Enabling them during
+ * this call is safe since the caller is not assuming any
+ * state that might have been altered by an interrupt.
+ */
+ local_irq_disable();
}

#endif
@@ -771,7 +789,13 @@ static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
if (need_resched())
return false;

- if (unlikely(local_softirq_pending() && cpu_online(cpu))) {
+ /*
+ * If we are running dataplane for this process, don't worry
+ * about pending softirqs; we will force them to run
+ * synchronously before returning to userspace.
+ */
+ if (unlikely(local_softirq_pending() && cpu_online(cpu) &&
+ !tick_nohz_is_dataplane())) {
static int ratelimit;

if (ratelimit < 10 &&
--
2.1.2


\
 
 \ /
  Last update: 2015-05-08 20:21    [W:0.469 / U:48.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site