Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756147AbbHYT4o (ORCPT ); Tue, 25 Aug 2015 15:56:44 -0400 Received: from mail-db3on0092.outbound.protection.outlook.com ([157.55.234.92]:4767 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751315AbbHYT4j (ORCPT ); Tue, 25 Aug 2015 15:56:39 -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 v6 5/6] task_isolation: add debug boot flag Date: Tue, 25 Aug 2015 15:55:54 -0400 Message-ID: <1440532555-15492-6-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1440532555-15492-1-git-send-email-cmetcalf@ezchip.com> References: <1440532555-15492-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD004;1:z3lCVJVeyRPZe/TWSk+mI+K9qgcbTgkF4+RiZbj5OAb+aHnDTUBDq+xEGbBGVlk4WDQYqbfSMUyP0JX8cwyLCMNTRODq4HBefV6eELoqAltU3Z4iXZL5T61QsRCtk4HFQoRKLsFrAikofJrmxCVKDZS1JLng2H/2Q4XPvjIG7yMtzuw88oX4KTZjaWnmpUP3WzJ1KPxL6iiiFLF1rZQLx/Hf76/xJNFPDbfbfE8qGCukGo5QokJImikotIZlr1KSyRTnGIDtAVC56w6ujPrgpENJMF/+GbrQa7Ygq9cAqX59ClvjzqjXcQE9GJMEPAnl0pZYIhEOapQFWzvbrxDon2mnQJBEAUj+8gYASdP+MfY= X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(339900001)(3050300001)(199003)(189002)(5001830100001)(76176999)(68736005)(5001860100001)(19580405001)(86362001)(50226001)(5001770100001)(107886002)(87936001)(2950100001)(4001540100001)(48376002)(46102003)(5007970100001)(62966003)(6806004)(47776003)(19580395003)(5003940100001)(575784001)(97736004)(2201001)(64706001)(50466002)(106476002)(104016003)(33646002)(50986999)(85426001)(189998001)(81156007)(106466001)(5001960100002)(92566002)(36756003)(106356001)(77156002)(42186005)(229853001)(9376005)(921003)(1121003)(4001430100001);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR02MB0780;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-Exchange-Diagnostics: 1;HE1PR02MB0780;2:Qsn0FaVkEiDUW4vgO32BSBAtsh2RxtY83Vi7xhw+b2IBE7guA2gXl3IxlEQ4kqcUUl2r0UTvPtEzTTRTMrwYzbJPdhzp9zrOBM8fhXc8uCxWGdJXGpBzaaZ2Ws24zPovh36QC+tk8qIjHbB82CcinXj7aTRgNstk4sDw/hLuPy4=;3:qST/aNzFhh1WFJNRGN94t/HG4GNFPLQQ1dVkvNKU6CP8ZOoJnQ+XlmaZ1m+khhuHUtd1ExhTPLtF3sz85XRHNQKHxhaGVgMa2gDngDxeGHHZJv2Kaz4NHyz6E5fHOPGdri8IffGlHWSymeVY7FBbHB1vShX6bthDMhVHwuVblmcDrVG2Hs1BvnndNKHIWnNkKdvDvqCqlj1Mq/zRPTMHsTKsbRe8TBQTYNgX2uSTZbJhBMiEExxqHJwlYa+HkDAv;25:ZecRhrSnWqTjzprYlgaacbD4m3ThEm6lllGvXImI0Dyx4HLJjU9dNyWPYGtcRtytsp0J+aX/fZ8SmpJmdHLvv/BDeh1xNu3LhwsSftMlUIN+GdmS1imR40TpyqaIcJw/4UD0MnlaxV/sEX7bKj8FCEuR46fexaDAXC8bzc3RhDBsPO/zqyhvHpVNiAiHVwn81f7wqgoVKdX8F0YJoYCgrQpQ8lACEdcBhIRZj5iOwJJkozgYj5LvsSjF17kvkIpuzeZbLO60Kjwh/NARFwQM7A==;20:ZmJPLzrPWYVeBb97oEpgB+hfuaPWWjljWaMNQ1tnPQbZxrkckZwsOlNtmDEu3zpJrjpSE6dKD8Pb+upJZScVQuw4jYYonw0cGjo+sTxnCg8Qxrza6mhvESIt2QOq+L4kL6ygea3N9L17GH2XKKcZKmYF6bMrq2CVgJ3QaEiM0Jk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0780; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:HE1PR02MB0780;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB0780; X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB0780;4:SZAQL3l2WHSWBkLiisTTqDDltYDgsXJrurjEUayFk6Hxf3u1VbDwmboYjE1b/riLUgVmd9LsZwSxgWhbL4yXeNHDUKQ+AKa4dLXVJ8VMeRDU2xzVCA4mfoTx0SpDDdQsoleUY7DSYn3CP2DlKMGlA5RaxAcyUZJyl7ELrXeNqt4imM1I97LzMYs5AgUBp/ewIkg+avySTf1qxJ1YhU3VFgJJ5SVURuUJibNqrjkttxkMvwBQpKKXJ5xU0u/TYE+30zV+c6peEg4va3ewXgWtjmjY0kkhulTmODgmdhVOKnst85SnOQnqQ2KCkzCf1dAsCrQlMFlndyg1VUz0Aqb9wA== X-Forefront-PRVS: 06793E740F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR02MB0780;23:LZOQpFBaI6xI+Rd2HiscnF29GN/4Fi6E+o4EoJK9A?= =?us-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ofR5JcZLxdOB12P+IM?= =?us-ascii?Q?APHt2+CV15ECBgWOc/pq2JPmG+c391yL4X5dviL078DDxzL2Kj97T73T07iW?= =?us-ascii?Q?AToR/smhzCTzrPM81Z+6Ec9a/y2mfA9ndQN4BrEUNguEr5TzqjMgA/LTlDor?= =?us-ascii?Q?9C1/7FB6zbPgQqocLu5FA12w+BasStTylDrhoN65XaGrRUNM5PRKta5oWYjC?= =?us-ascii?Q?agb76nPPsocL6VVr9oq8Ed+69I6oTpPGOoToHFJwp0KWcO7ji8xe+FeAED92?= =?us-ascii?Q?C1gI2+Y6Fcf/eBQyZL7/aOJiHWAime5C7pPMp2YKL3GOXs1U9yE5SIB7DJTq?= =?us-ascii?Q?wuBRTstbIitcub6dzQM/dsHIR4MPZGYsBvFiQIM3heRJky/7zh3R38JGHEDv?= =?us-ascii?Q?lNE0Du/kc766/UiEuA/NHNFCSN0l5XIxZ/FtoDpGC/j?= X-Microsoft-Exchange-Diagnostics: 1;HE1PR02MB0780;5:vrQYXxOkk//AKVNoD0OdKJraCvvHQcUcw5FqxjdlnofpUl4m+RLN6sBiSUVg/Wx84mlPDR0DeRmEPLJdufwpHTOV4rzi1dfMh3/qyQsJZrG/4iRZ2YL/LIRPeYtrGWTGTGsZhT5Ji8RBRQgBR/xVtw==;24:MYNEAFVkqyFHnjQebLWQu0MIWtJ06B8x8Xpj52ouqJZcYTKZirIazSVmte9tgBlN1kXSynENId0xO29hmDS/JvNWht+nLidK1K5uPXFwJ+s=;20:KvbXuIxflORSvCTKH9Oodffc++9JHa4nNuqMMPrzctnEvr3XsOcnP3rh1SiVR2JsqspyQjuQ0fFl699ovUbM4Q== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2015 19:56:33.2395 (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: 7613 Lines: 230 The new "task_isolation_debug" flag simplifies debugging of TASK_ISOLATION kernels when processes are running in PR_TASK_ISOLATION_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 task_isolation 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 task_isolation 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/isolation.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..934f172eb140 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3595,6 +3595,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. neutralize any effect of /proc/sys/kernel/sysrq. Useful for debugging. + task_isolation_debug [KNL] + In kernels built with CONFIG_TASK_ISOLATION 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_TASK_ISOLATION_ENABLE + and is running on a nohz_full core. + tcpmhash_entries= [KNL,NET] Set the number of tcp_metrics_hash slots. Default value is 8192 or 16384 depending on total diff --git a/arch/tile/mm/homecache.c b/arch/tile/mm/homecache.c index 40ca30a9fee3..a79325113105 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; + task_isolation_debug(cpu); + } } /* diff --git a/include/linux/isolation.h b/include/linux/isolation.h index 27a4469831c1..9f1747331a36 100644 --- a/include/linux/isolation.h +++ b/include/linux/isolation.h @@ -18,11 +18,13 @@ extern void task_isolation_enter(void); extern void task_isolation_syscall(int nr); extern void task_isolation_exception(void); extern void task_isolation_wait(void); +extern void task_isolation_debug(int cpu); #else static inline bool task_isolation_enabled(void) { return false; } static inline void task_isolation_enter(void) { } static inline void task_isolation_syscall(int nr) { } static inline void task_isolation_exception(void) { } +static inline void task_isolation_debug(int cpu) { } #endif static inline bool task_isolation_strict(void) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index cbf9fb899d92..745c2ea6a4e4 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))) { + task_isolation_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..0c4e4eba69b1 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_TASK_ISOLATION +/* Enable debugging of any interrupts of task_isolation cores. */ +static int task_isolation_debug_flag; +static int __init task_isolation_debug_func(char *str) +{ + task_isolation_debug_flag = true; + return 1; +} +__setup("task_isolation_debug", task_isolation_debug_func); + +void task_isolation_debug(int cpu) +{ + if (task_isolation_debug_flag && tick_nohz_full_cpu(cpu) && + (cpu_curr(cpu)->task_isolation_flags & PR_TASK_ISOLATION_ENABLE)) { + pr_err("Interrupt detected for task_isolation 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..60e15e835b9e 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_TASK_ISOLATION + /* If the task is being killed, don't complain about task_isolation. */ + if (state & TASK_WAKEKILL) + t->task_isolation_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..b0bddff2693d 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... */ + task_isolation_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) + task_isolation_debug(cpu); arch_send_call_function_ipi_mask(cfd->cpumask); if (wait) { diff --git a/kernel/softirq.c b/kernel/softirq.c index 479e4436f787..ed762fec7265 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()) + task_isolation_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/