Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964784AbbEHR7M (ORCPT ); Fri, 8 May 2015 13:59:12 -0400 Received: from mail-am1on0074.outbound.protection.outlook.com ([157.56.112.74]:6450 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932501AbbEHR7F (ORCPT ); Fri, 8 May 2015 13:59:05 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none; From: Chris Metcalf To: Gilad Ben Yossef , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , "Rik van Riel" , Tejun Heo , Frederic Weisbecker , "Paul E. McKenney" , Christoph Lameter , "Srivatsa S. Bhat" , CC: Chris Metcalf Subject: [PATCH 3/6] dataplane nohz: run softirqs synchronously on user entry Date: Fri, 8 May 2015 13:58:44 -0400 Message-ID: <1431107927-13998-4-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1431107927-13998-1-git-send-email-cmetcalf@ezchip.com> References: <1431107927-13998-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(199003)(189002)(106466001)(104016003)(46102003)(105606002)(2950100001)(229853001)(92566002)(36756003)(33646002)(42186005)(5001960100002)(107886002)(47776003)(6806004)(76176999)(19580395003)(77156002)(19580405001)(62966003)(50466002)(189998001)(87936001)(5001770100001)(50226001)(50986999)(86362001)(85426001)(15975445007)(575784001)(48376002)(60764002)(921003)(1121003)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR02MB0782;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0782; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:VI1PR02MB0782;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0782; X-Forefront-PRVS: 0570F1F193 X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2015 17:59:00.8455 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB0782 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3407 Lines: 105 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/