From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992547AbbEOV2K (ORCPT ); Fri, 15 May 2015 17:28:10 -0400 Received: from mail-am1on0074.outbound.protection.outlook.com ([157.56.112.74]:16381 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2992495AbbEOV16 (ORCPT ); Fri, 15 May 2015 17:27:58 -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 , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , , , CC: Chris Metcalf Subject: [PATCH v2 3/5] nohz: cpu_isolated strict mode configurable signal Date: Fri, 15 May 2015 17:27:29 -0400 Message-ID: <1431725251-20943-3-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1431725251-20943-1-git-send-email-cmetcalf@ezchip.com> References: <1431725178-20876-1-git-send-email-cmetcalf@ezchip.com> <1431725251-20943-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD050;1:8NqkhPLo8hdOOK2BkzErmegYMmCaYBZgmZdmQZchiXF1EIOHv0ew4s4CMrgTjR4a8ROpXl7NQVFYQgoS9sx3S1rIyB/rXA7OSgyE3s5ImeCeSNTxii29APc+E+u6EktiuEACjA1iU8r86qljD5NbItDTfiLZXEgIcp79WtEhumJ02NDHHWi0+LRPt3NdaYzprPJ/tR9vOKBX50IoVG01vY7OpOWKQ5DH4Xrjpfw/CSljX+P3cZupfPWDSrOoVrR++hgvzK4c/SyrUKdexGFh1fpITQCZwxhmADVCMlLxprw= X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(189002)(199003)(2201001)(86362001)(106466001)(6806004)(42186005)(104016003)(33646002)(50466002)(87936001)(46102003)(229853001)(48376002)(107886002)(5001960100002)(189998001)(19580405001)(85426001)(5001770100001)(47776003)(2950100001)(19580395003)(50226001)(36756003)(92566002)(105606002)(77156002)(62966003)(76176999)(50986999)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM2PR02MB0418;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0418; 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:AM2PR02MB0418;BCL:0;PCL:0;RULEID:;SRVR:AM2PR02MB0418; X-Forefront-PRVS: 0577AD41D6 X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2015 21:27:54.1862 (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: AM2PR02MB0418 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow userspace to override the default SIGKILL delivered when a cpu_isolated process in STRICT mode does a syscall or otherwise synchronously enters the kernel. In addition to being able to set the signal, we now also pass whether or not the interruption was from a syscall in the si_code field of the siginfo. Signed-off-by: Chris Metcalf --- include/uapi/linux/prctl.h | 2 ++ kernel/time/tick-sched.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 0c11238a84fb..ab45bd3d5799 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -195,5 +195,7 @@ struct prctl_mm_map { #define PR_GET_CPU_ISOLATED 48 # define PR_CPU_ISOLATED_ENABLE (1 << 0) # define PR_CPU_ISOLATED_STRICT (1 << 1) +# define PR_CPU_ISOLATED_SET_SIG(sig) (((sig) & 0x7f) << 8) +# define PR_CPU_ISOLATED_GET_SIG(bits) (((bits) >> 8) & 0x7f) #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 273820cd484a..772be78f926c 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -441,11 +441,18 @@ void tick_nohz_cpu_isolated_enter(void) } } -static void kill_cpu_isolated_strict_task(void) +static void kill_cpu_isolated_strict_task(int is_syscall) { + siginfo_t info = {}; + int sig; + dump_stack(); current->cpu_isolated_flags &= ~PR_CPU_ISOLATED_ENABLE; - send_sig(SIGKILL, current, 1); + + sig = PR_CPU_ISOLATED_GET_SIG(current->cpu_isolated_flags) ?: SIGKILL; + info.si_signo = sig; + info.si_code = is_syscall; + send_sig_info(sig, &info, current); } /* @@ -464,7 +471,7 @@ void tick_nohz_cpu_isolated_syscall(int syscall) pr_warn("%s/%d: cpu_isolated strict mode violated by syscall %d\n", current->comm, current->pid, syscall); - kill_cpu_isolated_strict_task(); + kill_cpu_isolated_strict_task(1); } /* @@ -475,7 +482,7 @@ void tick_nohz_cpu_isolated_exception(void) { pr_warn("%s/%d: cpu_isolated strict mode violated by exception\n", current->comm, current->pid); - kill_cpu_isolated_strict_task(); + kill_cpu_isolated_strict_task(0); } #endif -- 2.1.2 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Metcalf Subject: [PATCH v2 3/5] nohz: cpu_isolated strict mode configurable signal Date: Fri, 15 May 2015 17:27:29 -0400 Message-ID: <1431725251-20943-3-git-send-email-cmetcalf@ezchip.com> References: <1431725178-20876-1-git-send-email-cmetcalf@ezchip.com> <1431725251-20943-1-git-send-email-cmetcalf@ezchip.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1431725251-20943-1-git-send-email-cmetcalf-d5a29ZRxExrQT0dZR+AlfA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Gilad Ben Yossef , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , Rik van Riel , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Chris Metcalf List-Id: linux-api@vger.kernel.org Allow userspace to override the default SIGKILL delivered when a cpu_isolated process in STRICT mode does a syscall or otherwise synchronously enters the kernel. In addition to being able to set the signal, we now also pass whether or not the interruption was from a syscall in the si_code field of the siginfo. Signed-off-by: Chris Metcalf --- include/uapi/linux/prctl.h | 2 ++ kernel/time/tick-sched.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index 0c11238a84fb..ab45bd3d5799 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -195,5 +195,7 @@ struct prctl_mm_map { #define PR_GET_CPU_ISOLATED 48 # define PR_CPU_ISOLATED_ENABLE (1 << 0) # define PR_CPU_ISOLATED_STRICT (1 << 1) +# define PR_CPU_ISOLATED_SET_SIG(sig) (((sig) & 0x7f) << 8) +# define PR_CPU_ISOLATED_GET_SIG(bits) (((bits) >> 8) & 0x7f) #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 273820cd484a..772be78f926c 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -441,11 +441,18 @@ void tick_nohz_cpu_isolated_enter(void) } } -static void kill_cpu_isolated_strict_task(void) +static void kill_cpu_isolated_strict_task(int is_syscall) { + siginfo_t info = {}; + int sig; + dump_stack(); current->cpu_isolated_flags &= ~PR_CPU_ISOLATED_ENABLE; - send_sig(SIGKILL, current, 1); + + sig = PR_CPU_ISOLATED_GET_SIG(current->cpu_isolated_flags) ?: SIGKILL; + info.si_signo = sig; + info.si_code = is_syscall; + send_sig_info(sig, &info, current); } /* @@ -464,7 +471,7 @@ void tick_nohz_cpu_isolated_syscall(int syscall) pr_warn("%s/%d: cpu_isolated strict mode violated by syscall %d\n", current->comm, current->pid, syscall); - kill_cpu_isolated_strict_task(); + kill_cpu_isolated_strict_task(1); } /* @@ -475,7 +482,7 @@ void tick_nohz_cpu_isolated_exception(void) { pr_warn("%s/%d: cpu_isolated strict mode violated by exception\n", current->comm, current->pid); - kill_cpu_isolated_strict_task(); + kill_cpu_isolated_strict_task(0); } #endif -- 2.1.2