Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753596AbbG1Tu6 (ORCPT ); Tue, 28 Jul 2015 15:50:58 -0400 Received: from mail-am1on0094.outbound.protection.outlook.com ([157.56.112.94]:53431 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752798AbbG1TuQ (ORCPT ); Tue, 28 Jul 2015 15:50:16 -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 , Catalin Marinas , Will Deacon , , CC: Chris Metcalf Subject: [PATCH v5 5/6] cpu_isolated: add debug boot flag Date: Tue, 28 Jul 2015 15:49:39 -0400 Message-ID: <1438112980-9981-6-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1438112980-9981-1-git-send-email-cmetcalf@ezchip.com> References: <1438112980-9981-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD029;1:dsLGKJ44E7/J5fStNPbGyqvvjF782cpqyHzX2FZgDgRbi1mmPU2q8pbTh+SmesOyqybFHVb+sQwlgr2SrmRYX6c778z/OLDjLW67dpK7dJrUsz3BUZzSrTstE4LZx0AOzxFwDHtNPO3bBQZLJ1k0e7f8TBeqOCvd8/7RP12TRz30NYt2a5gIGzVgzoOA2/G9v+ffs9B46cfJYBN4bR1XzaWWrNXmO1nS4VUE9b2+15Bl4PQwAwv0uBPNrCdfzODZK+cFyTXe5kWYOgZMvMoeRTwirBd5YjtLOls7rfHBeKs= X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(339900001)(189002)(199003)(77156002)(36756003)(19580405001)(104016003)(50226001)(87936001)(62966003)(6806004)(46102003)(2950100001)(33646002)(50466002)(50986999)(19580395003)(229853001)(105606002)(86362001)(48376002)(2201001)(47776003)(107886002)(42186005)(5001960100002)(575784001)(189998001)(85426001)(92566002)(106466001)(76176999)(5001770100001)(921003)(4001430100001)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR02MB0784;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;VI1PR02MB0784;2:7ZFUG/VUuvMMxKqbGRajeuqhywsBqKiEGbT5CYZB/WtS7bT2kNe5vT83DNm3PONrjtrhb/pqo8DyfRgIwkYH3iuC1NuYuweYc2v7HO1ptiJxKcjzVze2u2OHyzmwQ++SWZ5yjb6F+ICGeHJTTUbrWdADB/8DMz9tPqJr+hfGRiU=;3:3+l1Er9eaFQ7oO7SkZkMKSxmW/ZX8FLRSvZKjoGSSgiBrDJpKAHemyVOovrucqGhS039fHBpSuBj/7nXnelp67Nbtccb7Yq9/91tbXEncYXYW+UVotf5rl82bBWF4eRV6oZRNrg9szKQjm9s9UZYP7zaLebDjRjAwQP/7o1Vnx3Gns29kPuwymEQcdZVylBKeNUc1PKhAHsynM4H4xAXgOeZSejWrh/oc6+zn3VEi8O+BiVDubY2wmA1/U8TPPLq;25:RXHetBPOz1nidHeBqNI1bjwuxRslY9yKU6Sl819IsnsL0dREI5WNAUpzTycJ2HMTgJQEh7FNDfECCd7lUxkM2XCIxThGyJiBRP9u8eW9aSnam06PB6yxP72syXvfEA3YPMYeBz7ueEIfQdXp5e2Omyyv25fDv4fWkyBE+tYLzMuYa6f3AkdCrKS4ekHaM/aVYstxKm9KjklgEYqqtkT5LTAK9UArqoudHgjfdZGrP1zQVRcrIF01LXzNwj8TYpp05+vnWQdXuesJg1gwdwAG8w==;20:tN9BQzwQnBtd5U+XYhA3anUpAJI+xIC5I6rLEmb+AqUqKgnDnBTd6tMaPTv17B/My0Cnm0Z2NqHU93BM5w/zU73AIJN/mj8K6CD62owzrtmByIF7YyiQByCPLAOU/rXcUae6CQ4bUQX2xOmxMdNoUhi3a2qQOL/7Sjq+zTNNOpA= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0784; VI1PR02MB0784: 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:VI1PR02MB0784;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0784; X-Microsoft-Exchange-Diagnostics: 1;VI1PR02MB0784;4:rV5cpHXNJLNn5fLKNYN4MRSQeS0bdVfhHbGhXjHiBiN03Fcn0cbKE5qvhLEqeOr9Jr7SCjDlZrNGEXzxM4sqa8QMqd+cWUt244BlKaoM5MbeDzhIQ7mLZd47FnqSgHCP3qMBxTJ96uS7I99AzrgsOdHkt7KLeIQhVDZG52GFrYt8cA08LdtBliSC84b/Psku+iTqJS6S/bsRtbkI60j/jlXB6n7pW9hnNMRZtSqMrug72T8PcGEQ9ImH9xZ8R7/aEhIUlZXS/26U3A1Ufp4StreE9XkIdxHMTF1Sz7UIFLE= X-Forefront-PRVS: 06515DA04B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR02MB0784;23:sm4aMYFdnX5mnMuknI31pYvldRxSR0CbhliXkRcic?= =?us-ascii?Q?+WDDt9qNHeiPViiBoI1DHRBG/S8IWu1MQN8wQNePRfRE1Aw5Nj4HTJpcxB1x?= =?us-ascii?Q?NksBjLHE3Eem6dLMHmElcou6jxTANjmuOMwVlldUQgDLMUC6+2h2N9vbrwj/?= =?us-ascii?Q?9orAfw3YvBz90a9dW03IGyDpoXz6xn+sNjd5raFXs4SJXK7PfPRIt5s3rImc?= =?us-ascii?Q?hAF1QE3u4p0n2SeA1aYQF35DkZ2oEiKO9kLe5AUggGtYeAuq5/W1GZ6RxOal?= =?us-ascii?Q?2qRDLoyRk+5WmMAm9sklYoEHn2e18ba7zljgClefgAVxMA/udnVQGVhnfOxE?= =?us-ascii?Q?pDcDutWxT3NYX7YWC5knlioNtBrcCBv3SUJRmPin7+tG3newGZmHbb2T8VFn?= =?us-ascii?Q?BddLx91AHmzl4gFjl4oz8N5gfaHKTFAaIMxH39jQ+Z6uy2kRbKgwu04QMzzv?= =?us-ascii?Q?WbXr8Xrwl8vbCmKxtYfHIyta/1bLiiPEaLhWCWjgfns7U8QG6JMTi1FK50Hi?= =?us-ascii?Q?nJwIhNe5qaN8OMpqAFas4ZtsnsoV7AJt/UeRCWCGHi7a3Q8NXrfEGyPdJijf?= =?us-ascii?Q?nEPd1/lz63coRrJ7pIXLo2jZLZHTq17uZyJD/6p3QVhJ3R2h15hLXXkRoEux?= =?us-ascii?Q?nzo1suf4HL0rOHiaKrwWHgnrdznFKA73PYS4WGmJ1dnrZGWSaueRGZLgieul?= =?us-ascii?Q?+wUv3G7u9hO/Sg4Bl8b65FVAnnwyiB2eeEVUyEFADy2vp/msiQb7kInQIx/K?= =?us-ascii?Q?RRnm3SNKiKEeuZP7vnmKC7jA9rjPY1EhD5qEN1lMHnoZ+DR2b7fCo5A1L+0p?= =?us-ascii?Q?1BFsWsz35EQfDiGoy3pqwyU2TP1IHKAu150zkjfC9WoMBbmtrraSvQxS0BeP?= =?us-ascii?Q?3HQmxcs0detMLlvStqkuvS74ljEIDv/SDLTzde2L0/rvzF2YeZYxxypp2FHs?= =?us-ascii?Q?dLSIq2idCDYZSI/8aNIO2zkaMs1RelB5e4k7C77RphFhB5w1Se6IkxeV7jRt?= =?us-ascii?Q?kleo9LRIpzgrhbLofdjRiRw?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR02MB0784;5:dHCO4REbv6b3CvsyVkPjtdpli79qkuJPHMP4CE4SESrTOnS3p2XKH3SJ7JVbsMkyhCdpCi09tvDwOm5D1tEdp0Hp1Z1oZRJL6hAs+0AwhpdtPzp9RSru8o8GHeRoBMaHVHDONThVW1z+tjKJx5bqEw==;24:daypk9YB6NiGzGl3YOqkhvxgkbu1qeYHLXwUJfd5os7KjUMA+v5kjaAF/9baANxJ9fVEOzr4J3mpwCIap6aoavG3qxrBqTGsJEiqr16FTF0=;20:jm0RiW8dqmtH00GyVaj1UFm6qN6kUbEp6tlEOi1eKAsSOJchj6ykbeVE/LyEk8nSVRuUaSDUY7yL5Hvm7YaNiQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2015 19:50:11.3814 (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: VI1PR02MB0784 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7490 Lines: 230 The new "cpu_isolated_debug" flag simplifies debugging of CPU_ISOLATED 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 | 7 +++++++ arch/tile/mm/homecache.c | 5 ++++- include/linux/cpu_isolated.h | 2 ++ kernel/irq_work.c | 5 ++++- kernel/sched/core.c | 21 +++++++++++++++++++++ kernel/signal.c | 5 +++++ kernel/smp.c | 4 ++++ kernel/softirq.c | 7 +++++++ 8 files changed, 54 insertions(+), 2 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 1d6f0459cd7b..940e4c9f1978 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -749,6 +749,13 @@ 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_CPU_ISOLATED 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 + and is running on a nohz_full core. + 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..fdef5e3d6396 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; + cpu_isolated_debug(cpu); + } } /* diff --git a/include/linux/cpu_isolated.h b/include/linux/cpu_isolated.h index b0f1c2669b2f..4ea67d640be7 100644 --- a/include/linux/cpu_isolated.h +++ b/include/linux/cpu_isolated.h @@ -18,11 +18,13 @@ extern void cpu_isolated_enter(void); extern void cpu_isolated_syscall(int nr); extern void cpu_isolated_exception(void); extern void cpu_isolated_wait(void); +extern void cpu_isolated_debug(int cpu); #else static inline bool is_cpu_isolated(void) { return false; } static inline void cpu_isolated_enter(void) { } static inline void cpu_isolated_syscall(int nr) { } static inline void cpu_isolated_exception(void) { } +static inline void cpu_isolated_debug(int cpu) { } #endif static inline bool cpu_isolated_strict(void) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index cbf9fb899d92..3c08a41f9898 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -75,8 +76,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))) { + 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..647671900497 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -745,6 +746,26 @@ bool sched_can_stop_tick(void) } #endif /* CONFIG_NO_HZ_FULL */ +#ifdef CONFIG_CPU_ISOLATED +/* Enable debugging of any interrupts of cpu_isolated cores. */ +static int cpu_isolated_debug_flag; +static int __init cpu_isolated_debug_func(char *str) +{ + cpu_isolated_debug_flag = true; + return 1; +} +__setup("cpu_isolated_debug", cpu_isolated_debug_func); + +void cpu_isolated_debug(int cpu) +{ + if (cpu_isolated_debug_flag && 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 + void sched_avg_update(struct rq *rq) { s64 period = sched_avg_period(); 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..846e42a3daa3 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... */ + 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) + 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..456149a4a34f 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -24,8 +24,10 @@ #include #include #include +#include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -335,6 +337,11 @@ void irq_enter(void) _local_bh_enable(); } + if (context_tracking_cpu_is_enabled() && + context_tracking_in_user() && + !in_interrupt()) + 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/