Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757498AbbFCPb3 (ORCPT ); Wed, 3 Jun 2015 11:31:29 -0400 Received: from mail-am1on0074.outbound.protection.outlook.com ([157.56.112.74]:64784 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757073AbbFCPaB (ORCPT ); Wed, 3 Jun 2015 11:30:01 -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 v3 4/5] nohz: add cpu_isolated_debug boot flag Date: Wed, 3 Jun 2015 11:29:24 -0400 Message-ID: <1433345365-29506-5-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1433345365-29506-1-git-send-email-cmetcalf@ezchip.com> References: <1433345365-29506-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD006;1:PTr3CvnfK68fjfeqJXTmPPwjJg40TDKjn8pwt3Vw2jWVLOxemZT10a/SwU/f8pAWsShHBXyYi7ETusKtIbV46iXTYN4k6Ic5Z7+9Uh3sUyxDlYuZMfxT76E7CbOtWyi5V0+Djpr74YGfzK1ueQIXjY6RLE846J3lYjAL0Ot2qmztiqQBEZk7BPjM2tiFMfUu5wH4c/8Viop2y8uBWjFT8M5h6cIbSa0Bv02cvzXkMm8ojLx1f1DZfvF/gGiUNLfTtwRCauMh77zctquSE2d+FvC3gHjM3dOMPo2iGx0daRA= X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(339900001)(199003)(189002)(106356001)(19580405001)(6806004)(19580395003)(81156007)(76176999)(97736004)(4001540100001)(50226001)(2950100001)(5001770100001)(77156002)(5001860100001)(5001960100002)(36756003)(104016003)(48376002)(64706001)(189998001)(106476002)(33646002)(50466002)(575784001)(5001830100001)(47776003)(229853001)(42186005)(46102003)(68736005)(62966003)(85426001)(87936001)(2201001)(107886002)(105606002)(50986999)(106466001)(92566002)(86362001)(9376004)(921003)(1121003)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR02MB0428;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;PTR:InfoNoRecords;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB0428; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:DB3PR02MB0428;BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB0428; X-Forefront-PRVS: 05961EBAFC X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2015 15:29:56.1934 (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: DB3PR02MB0428 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 f6befa9855c1..2b4c89225d25 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -743,6 +743,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 b7ffb10337ba..0b0d76106b8c 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -149,6 +149,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; } @@ -161,6 +162,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 f9123a82cbb6..7315e7272e94 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -719,6 +719,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 d51c5ddd855c..1a810ac2656e 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -689,6 +689,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/