Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964800AbbEHR7T (ORCPT ); Fri, 8 May 2015 13:59:19 -0400 Received: from mail-db3on0081.outbound.protection.outlook.com ([157.55.234.81]:36643 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964783AbbEHR7N (ORCPT ); Fri, 8 May 2015 13:59:13 -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 , Thomas Gleixner , Frederic Weisbecker , "Paul E. McKenney" , Christoph Lameter , "Srivatsa S. Bhat" , , , CC: Chris Metcalf Subject: [PATCH 5/6] nohz: support PR_DATAPLANE_STRICT mode Date: Fri, 8 May 2015 13:58:46 -0400 Message-ID: <1431107927-13998-6-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)(2950100001)(92566002)(48376002)(5001770100001)(76176999)(2201001)(50466002)(36756003)(106466001)(105606002)(5001960100002)(6806004)(107886002)(50226001)(86362001)(50986999)(62966003)(77156002)(46102003)(47776003)(189998001)(104016003)(19580405001)(575784001)(19580395003)(87936001)(42186005)(229853001)(33646002)(85426001)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR02MB0775;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:DB5PR02MB0775; 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:DB5PR02MB0775;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB0775; X-Forefront-PRVS: 0570F1F193 X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2015 17:59:09.8077 (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: DB5PR02MB0775 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3160 Lines: 88 With QUIESCE mode, the task is in principle guaranteed not to be interrupted by the kernel, but only if it behaves. In particular, if it enters the kernel via system call, page fault, or any of a number of other synchronous traps, it may be unexpectedly exposed to long latencies. Add a simple flag that puts the process into a state where any such kernel entry is fatal. To allow the state to be entered and exited, we add an internal bit to current->dataplane_flags that is set when prctl() sets the flags. That way, when we are exiting the kernel after calling prctl() to forbid future kernel exits, we don't get immediately killed. Signed-off-by: Chris Metcalf --- include/uapi/linux/prctl.h | 2 ++ kernel/sys.c | 2 +- kernel/time/tick-sched.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 8b735651304a..9cf79aa1e73f 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -195,5 +195,7 @@ struct prctl_mm_map { #define PR_GET_DATAPLANE 48 # define PR_DATAPLANE_ENABLE (1 << 0) # define PR_DATAPLANE_QUIESCE (1 << 1) +# define PR_DATAPLANE_STRICT (1 << 2) +# define PR_DATAPLANE_PRCTL (1U << 31) /* kernel internal */ #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index 930b750aefde..8102433c9edd 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2245,7 +2245,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, break; #ifdef CONFIG_NO_HZ_FULL case PR_SET_DATAPLANE: - me->dataplane_flags = arg2; + me->dataplane_flags = arg2 | PR_DATAPLANE_PRCTL; break; case PR_GET_DATAPLANE: error = me->dataplane_flags; diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 69d908c6cef8..22ed0decb363 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -436,6 +436,20 @@ static void dataplane_quiesce(void) (jiffies - start)); dump_stack(); } + + /* + * Kill the process if it violates STRICT mode. Note that this + * code also results in killing the task if a kernel bug causes an + * irq to be delivered to this core. + */ + if ((task->dataplane_flags & (PR_DATAPLANE_STRICT|PR_DATAPLANE_PRCTL)) + == PR_DATAPLANE_STRICT) { + pr_warn("Dataplane STRICT mode violated; process killed.\n"); + dump_stack(); + task->dataplane_flags &= ~PR_DATAPLANE_QUIESCE; + local_irq_enable(); + do_group_exit(SIGKILL); + } } /* @@ -464,6 +478,9 @@ void tick_nohz_dataplane_enter(void) if ((current->dataplane_flags & PR_DATAPLANE_QUIESCE) != 0) dataplane_quiesce(); + /* Clear the bit set by prctl() when it updates the flags. */ + current->dataplane_flags &= ~PR_DATAPLANE_PRCTL; + /* * Disable interrupts again since other code running in this * function may have enabled them, and the caller expects -- 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/