Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753134AbbGMT6f (ORCPT ); Mon, 13 Jul 2015 15:58:35 -0400 Received: from mail-am1on0088.outbound.protection.outlook.com ([157.56.112.88]:20988 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753081AbbGMT6a (ORCPT ); Mon, 13 Jul 2015 15:58:30 -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 v4 4/5] nohz: add cpu_isolated_debug boot flag Date: Mon, 13 Jul 2015 15:58:00 -0400 Message-ID: <1436817481-8732-5-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1436817481-8732-1-git-send-email-cmetcalf@ezchip.com> References: <1436817481-8732-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD033;1:ulEj3ekwuklCaUW5GbiJz81xYo5ZEYmnpHTYAk2X+Og5ja3aAcDXKE9sQDGetHxCszIUemqpdY/wSW/xv3RQpuvW+6/DnVkqDC1sv4+ti4mUB6ofZ9tz4ixVaf8gYckvvBYna+WYIeJv2kuzP4wzZO88114+5WAFdG/EbC5oB37ie6kpAsdOY+fWAqUuXFk3OdmTjjWNIGi4p9eW738JU3LdckPvhzSoP9COYKDhi3RE4Zo3g8O7QwU5FERXrshXfHMvbxt6HpcQjMUwo09fCfkdsJMGP5f+hgd86NPyrUXJQwZz4SWHuuLDHEwAn66FW8jGPCB/yHbHYiF3fvY7cxAuo13GJvZaMkBFfV5lbe81vcQFL+NNxD+jWaRzVGV/Mq86UMdoH3qcwrtXLauyow== X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(339900001)(189002)(199003)(92566002)(46102003)(87936001)(62966003)(2201001)(77156002)(19580405001)(19580395003)(76176999)(5001770100001)(575784001)(50986999)(6806004)(47776003)(85426001)(33646002)(104016003)(50466002)(86362001)(2950100001)(105606002)(48376002)(229853001)(42186005)(189998001)(5001960100002)(106466001)(36756003)(50226001)(107886002)(5003940100001)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR02MB0780;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-Exchange-Diagnostics: 1;HE1PR02MB0780;2:/LzyWRVZJxznb2K57uG/lNtu9EV6sRIBFQG+F68yiI9bKmuOV/Xh0CdlqZRS6kDy;3:SvXs6kccOpvPNbNw7LeJ2iI56YZrEr023y/wLslPtseBfs2HXBLGvJzv1YQwlb2tC40QqUEw1e/H0FDSmzQuJGd5hmVvDIo8+f/BkQjxFM3yCjlHj6ejjluCA01G2SRsBMaQoLguITF0RFLUYdRsWdPKcqvo/FCY/E0R9NmQ4eosV6hQmLR/rFxgIZbNBDqE8AfWMjMEMyl2gBpknyKN55/NEyuCVGTEbQ3iGFtohR1Av4//MI668xRQrMnLof0q;25:BhOddIpZqz+sP3E4ODU11gW8HphQ2EFJTLETUIyDqDJMUHnt3Jmbz8d2dxAO3Y0CIb/wsTHFNqJp5afFLTWwDaIiNFwkPCNhNtyqSEiKKqNCCGuSQHJVzu/0ZEgMluDANqhIgXIN7RDLTdscgzQ3ywg26wyJD+GMaZ/Cmk/S8HAYx4av3gpJIa2ibaMcQQIw1JgKfuak8j92drSVYfv3oYclUcSnK5hHQtjnVq1LstWUsT6AQtpatQJ8r85J41lUbdTthyeYSuzj1ufr1O79kQ==;20:9mN4HcwcFdPumlIZogu4PrE2+EVTl/s6CTpRJlOrlEXaye3lfUpBA7aOhrRPP/aGCkPXEoKNdFZYWHmGvtPqBztvPcj9C7TzmOfowEYOFsr8tC1/1xgoJtmdrQx+VE8wDYirf0eOwOFGS0Y9pzLl8EomoOsf5veGCCyDA+aH3Kw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0780; HE1PR02MB0780: X-MS-Exchange-Organization-RulesExecuted 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:HE1PR02MB0780;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0780; X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB0780;4:BJpw9utnJy4lPbZUxVYAonGLiR2has0+4mwSDP1o6LS7WoZEtftuzPHWgMRoPHNA06phCNQekA5WvPo19O/ZVz8k1QgFc/9yvTEaTW4OK5A3ZmkSL3AhZxhg06fCkbhuxQCJbbzOqgmil+DahnZcRvM7ZG4+vD4BnCy1gLw0pRHqBAMsO6SvqZ81mfAYJi31XnoYtMZo+uaFCsNTbFTpVORRXPEzS06xmc9WsphOZi/xI3PYUDZwhsY6g3uDE/5KKOwI880MrAGrUk1JjCQfEKfchtkhd70fWxW9DwhiIAk= X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR02MB0780;23:IAogL5sfbcdPN2mhwtli3TvB5ZRk8uDwUPCdR8909?= =?us-ascii?Q?/lWVihTMKAmVi0Mx5OAOxucqFBh2hiH8LduDs3HOtwlbqrDzJRoiXstuNbJp?= =?us-ascii?Q?lv0GeJVqD12hHirGcEhbpA4HWCbSB35aMz+LR4nUTyqjIRBvsyLGVqxWH7XM?= =?us-ascii?Q?30doBEqxx4mwprcAW5MEApaP3mWc3/0sGgML/pW16nJqAMX+g32OXNAskALw?= =?us-ascii?Q?o4GLGipU5pHhMEKspDB1Kyt0xtk4linqrnhd5RGHblst5G2B5Q5xP5b+Sczh?= =?us-ascii?Q?3X+KiEfz0UZ7PydFDzDm3m9fzfVhuFqoNetQbdfiqV0E/OdtgCryV9DCOYNR?= =?us-ascii?Q?H0e8PFmDOEzbRKN9j1KaHxjqwhZGTAVMZlSqEMFlnK+qE5Z95nQ5EDWl+7ar?= =?us-ascii?Q?mPNzK6JaN/VQ9IfXbYvk/xgSnqCSzSshGEZE4a8TUfqgjvzI7PDl6YTHvXjq?= =?us-ascii?Q?m+MVn2WBgViWVPZUkKYq0kU7RlqecG9GDYN6eAcnkGl6W01/hRS5tfcYbC9f?= =?us-ascii?Q?jyAeVf9dxaaEvh7/a94H+8g8K47iopkfF98qaBhFHDnUxxLVtcSjoed2DN+h?= =?us-ascii?Q?GFq7SBpdme7R4jLRvsllmsWci+DMosFmdiQkQ83sYEfZl8dR68PYtEfhvegC?= =?us-ascii?Q?53Vukbm5zYA2r5h5yVHzsd1cQE42z020A40kKlGxbw50V7hHMuM7SI5+GbMK?= =?us-ascii?Q?YAWXOeKdMNbVYfsMNsuTqK8AP8rl8jyyGQDq2ctga1CDnTorWZd34cGDeBZu?= =?us-ascii?Q?pRd0NJ2jAfqCWm47bkapXhfnBeB+1QnCcdwLrnwPl98ldWIg1ounBAV9JzT8?= =?us-ascii?Q?uLOb7crWTzhdgjI25uhuUZKQrm+1AN/tlC6BZBVd1KGy5VmVqw4P/f7R4wZ2?= =?us-ascii?Q?lFPh6tl9WTWHXBEKjjFkMp6vFJdi15vGSVdyXhr/6W26t83aiPDPmG9hNucT?= =?us-ascii?Q?zZiguYNUQAYLa+oQiX2r8Zxx1UQNNzdeFe66dW3kfmEQOeRf0AaHeRwEASwd?= =?us-ascii?Q?Tfxc1Fj0am8s1js8eDhyurf1svPu3AsriIawWZIxxWKAA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB0780;5:ZTT0CJO1wnopZjVY58N9iw8bHJ3zgqrBhrOrMMqSpt/4IzGOK5yvhhn1xXEqHH5UqoFjqhBMTktbJ0fDys36+UOwCXTp3Vaxxw7rXbndPhj5qgZBfKlLP7UAyouPIE3Leir54K9Pi+6D59n4UbUmbA==;24:XSuy0zWpbe6SiFelE8X6iXaDunoXgKTYaMZ8RHH8NmmCIipXE7+/NHLBLLv8XsptmMTarE7nGj67YWtCHS0D/mr9zJkK6EweQhyrylH2JIE=;20:0Say4INrud6huryHkXOSVV24qQCwPvQkF2VLgYx2ZfKbe30M7fpZv5g0GLIUVIr5/ym/VyW+WGwYEuG5Pq6xww== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 19:58:26.0343 (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: HE1PR02MB0780 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7176 Lines: 209 This flag simplifies debugging of NO_HZ_FULL kernels when processes are running in PR_CPU_ISOLATED_ENABLE mode. Such processes should get no interrupts from the kernel, and if they do, when this boot flag is specified a kernel stack dump on the console is generated. It's possible to use ftrace to simply detect whether a cpu_isolated core has unexpectedly entered the kernel. But what this boot flag does is allow the kernel to provide better diagnostics, e.g. by reporting in the IPI-generating code what remote core and context is preparing to deliver an interrupt to a cpu_isolated core. It may be worth considering other ways to generate useful debugging output rather than console spew, but for now that is simple and direct. Signed-off-by: Chris Metcalf --- Documentation/kernel-parameters.txt | 6 ++++++ arch/tile/mm/homecache.c | 5 ++++- include/linux/tick.h | 2 ++ kernel/irq_work.c | 4 +++- kernel/sched/core.c | 18 ++++++++++++++++++ kernel/signal.c | 5 +++++ kernel/smp.c | 4 ++++ kernel/softirq.c | 6 ++++++ 8 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 1d6f0459cd7b..76e8e2ff4a0a 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -749,6 +749,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. /proc//coredump_filter. See also Documentation/filesystems/proc.txt. + cpu_isolated_debug [KNL] + In kernels built with CONFIG_NO_HZ_FULL and booted + in nohz_full= mode, this setting will generate console + backtraces when the kernel is about to interrupt a + task that has requested PR_CPU_ISOLATED_ENABLE. + cpuidle.off=1 [CPU_IDLE] disable the cpuidle sub-system diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c index 40ca30a9fee3..f336880e1b01 100644 --- a/arch/tile/mm/homecache.c +++ b/arch/tile/mm/homecache.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -83,8 +84,10 @@ static void hv_flush_update(const struct cpumask *cache_cpumask, * Don't bother to update atomically; losing a count * here is not that critical. */ - for_each_cpu(cpu, &mask) + for_each_cpu(cpu, &mask) { ++per_cpu(irq_stat, cpu).irq_hv_flush_count; + tick_nohz_cpu_isolated_debug(cpu); + } } /* diff --git a/include/linux/tick.h b/include/linux/tick.h index f79f6945f762..ed65551e2315 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -159,6 +159,7 @@ extern void __tick_nohz_task_switch(struct task_struct *tsk); extern void tick_nohz_cpu_isolated_enter(void); extern void tick_nohz_cpu_isolated_syscall(int nr); extern void tick_nohz_cpu_isolated_exception(void); +extern void tick_nohz_cpu_isolated_debug(int cpu); #else static inline bool tick_nohz_full_enabled(void) { return false; } static inline bool tick_nohz_full_cpu(int cpu) { return false; } @@ -172,6 +173,7 @@ static inline bool tick_nohz_is_cpu_isolated(void) { return false; } static inline void tick_nohz_cpu_isolated_enter(void) { } static inline void tick_nohz_cpu_isolated_syscall(int nr) { } static inline void tick_nohz_cpu_isolated_exception(void) { } +static inline void tick_nohz_cpu_isolated_debug(int cpu) { } #endif static inline bool is_housekeeping_cpu(int cpu) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index cbf9fb899d92..7f35c90346de 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -75,8 +75,10 @@ bool irq_work_queue_on(struct irq_work *work, int cpu) if (!irq_work_claim(work)) return false; - if (llist_add(&work->llnode, &per_cpu(raised_list, cpu))) + if (llist_add(&work->llnode, &per_cpu(raised_list, cpu))) { + tick_nohz_cpu_isolated_debug(cpu); arch_send_call_function_single_ipi(cpu); + } return true; } diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 78b4bad10081..c8388f9206b2 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -743,6 +743,24 @@ bool sched_can_stop_tick(void) return true; } + +/* Enable debugging of any interrupts of cpu_isolated cores. */ +static int cpu_isolated_debug; +static int __init cpu_isolated_debug_func(char *str) +{ + cpu_isolated_debug = true; + return 1; +} +__setup("cpu_isolated_debug", cpu_isolated_debug_func); + +void tick_nohz_cpu_isolated_debug(int cpu) +{ + if (cpu_isolated_debug && tick_nohz_full_cpu(cpu) && + (cpu_curr(cpu)->cpu_isolated_flags & PR_CPU_ISOLATED_ENABLE)) { + pr_err("Interrupt detected for cpu_isolated cpu %d\n", cpu); + dump_stack(); + } +} #endif /* CONFIG_NO_HZ_FULL */ void sched_avg_update(struct rq *rq) diff --git a/kernel/signal.c b/kernel/signal.c index 836df8dac6cc..90ee460c2586 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -684,6 +684,11 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) */ void signal_wake_up_state(struct task_struct *t, unsigned int state) { +#ifdef CONFIG_NO_HZ_FULL + /* If the task is being killed, don't complain about cpu_isolated. */ + if (state & TASK_WAKEKILL) + t->cpu_isolated_flags = 0; +#endif set_tsk_thread_flag(t, TIF_SIGPENDING); /* * TASK_WAKEKILL also means wake it up in the stopped/traced/killable diff --git a/kernel/smp.c b/kernel/smp.c index 07854477c164..6b7d8e2c8af4 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "smpboot.h" @@ -178,6 +179,7 @@ static int generic_exec_single(int cpu, struct call_single_data *csd, * locking and barrier primitives. Generic code isn't really * equipped to do the right thing... */ + tick_nohz_cpu_isolated_debug(cpu); if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) arch_send_call_function_single_ipi(cpu); @@ -457,6 +459,8 @@ void smp_call_function_many(const struct cpumask *mask, } /* Send a message to all CPUs in the map */ + for_each_cpu(cpu, cfd->cpumask) + tick_nohz_cpu_isolated_debug(cpu); arch_send_call_function_ipi_mask(cfd->cpumask); if (wait) { diff --git a/kernel/softirq.c b/kernel/softirq.c index 479e4436f787..333872925ff6 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -335,6 +336,11 @@ void irq_enter(void) _local_bh_enable(); } + if (context_tracking_cpu_is_enabled() && + context_tracking_in_user() && + !in_interrupt()) + tick_nohz_cpu_isolated_debug(smp_processor_id()); + __irq_enter(); } -- 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/