Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759657AbcDERlg (ORCPT ); Tue, 5 Apr 2016 13:41:36 -0400 Received: from mail-db3on0099.outbound.protection.outlook.com ([157.55.234.99]:23513 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759397AbcDERj1 (ORCPT ); Tue, 5 Apr 2016 13:39:27 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=fail action=none header.from=mellanox.com; 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 , Andy Lutomirski , , CC: Chris Metcalf Subject: [PATCH v12 07/13] task_isolation: add debug boot flag Date: Tue, 5 Apr 2016 13:38:36 -0400 Message-ID: <1459877922-15512-8-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> References: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(104016004)(6806005)(11100500001)(575784001)(47776003)(189998001)(106466001)(19580405001)(105606002)(19580395003)(50466002)(48376002)(85426001)(86362001)(5001770100001)(107886002)(42186005)(2201001)(76176999)(87936001)(36756003)(5001970100001)(4001430100002)(5008740100001)(4326007)(2906002)(92566002)(33646002)(1220700001)(2950100001)(586003)(50986999)(1096002)(229853001)(5003940100001)(50226001)(921003)(83996005)(2101003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR05MB1685;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11OLC002;1:+gOB3mJv/AKnhX929IlImUYKw99nzn3HOyngT+MeYpHZcHDPoS/eBlcXMhB5C4+FViCg8AzdBr1GkhO2z2Kg2D0Edw6znFQzKwZvdOH1xtGuVyAX+l4MiOXJXC/sMoTAMpnt6UM3S1e+tvNnYy9rfoqaBPpdy+r2TqyEepaP/Sefxrv7u/W+3V0k5/8/EDQToAobEXs3FrApN0b69De2yF67zS6/Vm1ln+vBH0bQnDZI8pRhRxGv3RqSYXp8hx86oHYlcJqtAzIPXBJstII/5XT+N1Z5UF6gPqOAS2sQi1QNSWXUEfiWEM7c7zmuuB6vmtzYCUwTrKcLew5bOp0icFaE8++iFQGc1q1MEO+1mhxsUbsJ7ZzKqIhrLMLcmrZSiCusAWfzV6Y81thizdiFoYDhceQ1NuXNZkJrP4SyCFQToHf1UHYfMBVvz1HVr9N8xDUn/Yl5CZy1/PDdCPeWe99bJ6HqcXikyAWOy1mIWU7vxfXFBabC72XbuKm21BOFl/qnC1fpI0G+A80LrOPah0XXFvjt4UIuvOpYZyBpqoyLpgn1QegkgNLd1GIposP39Lt7eZcPIDpVX68sJMn9AJZ88eqV4PAznhkqNwpr2iE0oCJc8+w8fDJltKsNhPKs MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5e00000a-63f0-4d14-481c-08d35d793634 X-Microsoft-Exchange-Diagnostics: 1;DB5PR05MB1685;2:7pRIoErvKQKmYkoioBN4fqTznXhlj6lMHHsRsZTMtJYnvpEbhn6Gn//ZF9MxHfF/gRfjanhPe6IL0U2EZ9pD/nikZLNYepa2D1jpNKdSVOkPoHHdySiQEjeXWR0Bjf5BgLdmi/xd0bFRmvsJfHDA9VvcpKJ3LeNUoHbSuarEN58rOgbD5Oegmj8ldrBo4524;3:Zre/fbQL8z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;20:T2jb78vrS19MvCS5N1L6QmTFWj5j013aOmd/WPGpXu6m7vW5T6ONgXx7oA2Jzsnpz/slMef9PtAWDJ0kOGSJgkZNauGMW3i+7En/0FHUUx+iGf8w5RUC4J/YOAnu4lYxod7SmD+weIFaplltRblc/irMXFVAZu9CooknkCUmVqwZG7QgLXajvvOZzxtoRQMm9101uFp3IzQL+ydSgItMFxQAZTdRyJJQw0KZao52L8oBKu6VJ6v7uErVhdqXy5pLd/wGUY5GuV9xT6YfHGNNysGUtIHc5zsfZEPOfmBhuMfWbvn3Mt/33arOPpFUr5fJHYy0yLjkn5W4PKpukL/TJDtT/xPikYBhK0611UWr6p5mxvPsTd+yS7BC0wqUt6MDmhD0/Hpp46r8DWCgbe0Bx7hT2bxfBO0edWYeCA0ppHQAyBXB/7uUMUKiU8Tnlkbtz/TCF28Iw6Mvf7MGqJhMoH+/JEUVgrj9PP2M7A2i6Qc8J6gh9Z/pElj6yg18p2bG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(13018025)(13015025)(13023025)(13024025)(8121501046)(13017025)(10201501046)(3002001);SRVR:DB5PR05MB1685;BCL:0;PCL:0;RULEID:;SRVR:DB5PR05MB1685; X-Microsoft-Exchange-Diagnostics: 1;DB5PR05MB1685;4:qEPgu4UlJvvk3qtRTTJhMVZrgFdzGZrgOhcbsNDn63MWqGKCdeo1WSF5C6ySttLx+7yQ/1i+woXfDnQYFxnvglT1A3MPj4h6rJrzQGjbXQNxFkPN8MEUjfuRdacn6XSSieTRgoxKi16U5ewhK6grV3e0FFtQ/w00bRGeUPrpPSwmKo5/tFMR9BnXECACQDiKgJF1dsD3JAQkZEI5yAWSW0IQJ3AE73OoY0fIFNQEpUR/cV7j/zCnmKeTMPy3Wp0Z0enYPb34LpJcnTrjaBdKCyNFXpuPlaDIrPi6lEGZaitHWILVyk2DJO7SATEQQYzcsL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=?us-ascii?Q?bR/4kY+4zPf1taqzIw2xf1MbU2BJq2uKCHYzLRtIRfG4jb2UquME/4sFzRXi?= =?us-ascii?Q?FgP4j4RgNRcRZe2VYOSwIcA6AZhQREm8bFXQZGbEzsTafw4unWw4lbYwmiLQ?= =?us-ascii?Q?2Jt8vLm/n9gX7PFdjimaH0h6+IDzcjiZZtFRJqJ1YPd9tAzTaDpazYluk+oq?= =?us-ascii?Q?1mKMGlcC1x85qwFOgwL+Ig4pShPpFJFU15jJjZ/bEV89ZJ2cSPscCpsoK7Fh?= =?us-ascii?Q?dDyrz+g+H6TUP0xtv5fME7iZzuEi86fwT2UE1fuS4/tHYJAGmwGk5XmmHgoi?= =?us-ascii?Q?zM9aGSG3QUl88UXVITt17DfCknfG5VRJMT4Pt7JaBdHWCe5OcGZqKyyZOdov?= =?us-ascii?Q?82XnQ9gtp44q1YTn1ftBeweOsUHD+KAmxKWODp7yqsmQfjylZkb9opmCblhm?= =?us-ascii?Q?Ny4cEBOFuWu5PIENod0bNPKnfqOefE+yQi19qPDaCV7wDKKjaqry/A5XWQlS?= =?us-ascii?Q?n/VuuN1HpFI8Hdp+QomZ3GKR/a//NM7LmSTolFOXqsF288mipLy3t/g7w=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB5PR05MB1685;5:z3tsfZiw6g9uojXeZl1B27/ZtIUNzR5GpACIcxl6da94IzJVIel/OixW0ttk9XSoJL+CmuIfAFJwtNgyZMPamroGK0XIev7xZi1yDh2RJQi5A7PQe+TY9gQ02KY59NfdGbl7lJBsycqH0mnJ4R8KnA==;24:7HBGn0wnhnuPS3FABrsRit+NZloN/u8JrlarriHKERfn9a0Q0sXyQHP8vCWWZS/M2eof9YLDLNOFrj4Y+sZQitfImNCz/xdhW43Zcn9iQ1A= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 17:39:16.6981 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR05MB1685 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 11557 Lines: 349 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, we notify either the process (if STRICT mode is set and the interrupt is not an NMI) or with a kernel stack dump on the console (otherwise). 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. Additionally, delivering a signal to the process in STRICT mode allows applications to report up task isolation failures into their own application logging framework. Signed-off-by: Chris Metcalf --- Documentation/kernel-parameters.txt | 8 ++++ include/linux/context_tracking_state.h | 6 +++ include/linux/isolation.h | 5 +++ kernel/irq_work.c | 5 ++- kernel/isolation.c | 77 ++++++++++++++++++++++++++++++++++ kernel/sched/core.c | 18 ++++++++ kernel/signal.c | 4 ++ kernel/smp.c | 6 ++- kernel/softirq.c | 33 +++++++++++++++ 9 files changed, 160 insertions(+), 2 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 9bd5e91357b1..7884e69d08fa 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -3816,6 +3816,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted. also sets up nohz_full and isolcpus mode for the listed set of cpus. + task_isolation_debug [KNL] + In kernels built with CONFIG_TASK_ISOLATION + and booted in task_isolation= 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 task_isolation 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/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h index 1d34fe68f48a..4e2c4b900b82 100644 --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -39,8 +39,14 @@ static inline bool context_tracking_in_user(void) { return __this_cpu_read(context_tracking.state) == CONTEXT_USER; } + +static inline bool context_tracking_cpu_in_user(int cpu) +{ + return per_cpu(context_tracking.state, cpu) == CONTEXT_USER; +} #else static inline bool context_tracking_in_user(void) { return false; } +static inline bool context_tracking_cpu_in_user(int cpu) { return false; } static inline bool context_tracking_active(void) { return false; } static inline bool context_tracking_is_enabled(void) { return false; } static inline bool context_tracking_cpu_is_enabled(void) { return false; } diff --git a/include/linux/isolation.h b/include/linux/isolation.h index eb78175ed811..f04252c51cf1 100644 --- a/include/linux/isolation.h +++ b/include/linux/isolation.h @@ -44,6 +44,9 @@ extern void _task_isolation_exception(const char *fmt, ...); _task_isolation_exception(fmt, ## __VA_ARGS__); \ } while (0) +extern void task_isolation_debug(int cpu); +extern void task_isolation_debug_cpumask(const struct cpumask *); +extern void task_isolation_debug_task(int cpu, struct task_struct *p); #else static inline void task_isolation_init(void) { } static inline bool task_isolation_possible(int cpu) { return false; } @@ -53,6 +56,8 @@ extern inline void task_isolation_set_flags(struct task_struct *p, unsigned int flags) { } static inline int task_isolation_syscall(int nr) { return 0; } static inline void task_isolation_exception(const char *fmt, ...) { } +static inline void task_isolation_debug(int cpu) { } +#define task_isolation_debug_cpumask(mask) do {} while (0) #endif #endif diff --git a/kernel/irq_work.c b/kernel/irq_work.c index bcf107ce0854..a9b95ce00667 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/isolation.c b/kernel/isolation.c index f44e90109472..1c4f320a24a0 100644 --- a/kernel/isolation.c +++ b/kernel/isolation.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "time/tick-sched.h" @@ -230,3 +231,79 @@ int task_isolation_syscall(int syscall) return 0; } + +/* 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_task(int cpu, struct task_struct *p) +{ + static DEFINE_RATELIMIT_STATE(console_output, HZ, 1); + bool force_debug = false; + + /* + * Our caller made sure the task was running on a task isolation + * core, but make sure the task has enabled isolation. + */ + if (!(p->task_isolation_flags & PR_TASK_ISOLATION_ENABLE)) + return; + + /* + * Ensure the task is actually in userspace; if it is in kernel + * mode, it is expected that it may receive interrupts, and in + * any case they don't affect the isolation. Note that there + * is a race condition here as a task may have committed + * to returning to user space but not yet set the context + * tracking state to reflect it, and the check here is before + * we trigger the interrupt, so we might fail to warn about a + * legitimate interrupt. However, the race window is narrow + * and hitting it does not cause any incorrect behavior other + * than failing to send the warning. + */ + if (!context_tracking_cpu_in_user(cpu)) + return; + + /* + * If the task was in strict mode, deliver a signal to it. + * We disable task isolation mode when we deliver a signal + * so we won't end up recursing back here again. + * If we are in an NMI, we don't try delivering the signal + * and instead just treat it as if "debug" mode was enabled, + * since that's pretty much all we can do. + */ + if (p->task_isolation_flags & PR_TASK_ISOLATION_STRICT) { + if (in_nmi()) + force_debug = true; + else + task_isolation_interrupt(p, "interrupt"); + } + + /* + * If (for example) the timer interrupt starts ticking + * unexpectedly, we will get an unmanageable flow of output, + * so limit to one backtrace per second. + */ + if (force_debug || + (task_isolation_debug_flag && __ratelimit(&console_output))) { + pr_err("Interrupt detected for task_isolation cpu %d, %s/%d\n", + cpu, p->comm, p->pid); + dump_stack(); + } +} + +void task_isolation_debug_cpumask(const struct cpumask *mask) +{ + int cpu, thiscpu = get_cpu(); + + /* No need to report on this cpu since we're already in the kernel. */ + for_each_cpu(cpu, mask) + if (cpu != thiscpu) + task_isolation_debug(cpu); + + put_cpu(); +} diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d8465eeab8b3..00649f7ad567 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -605,6 +606,23 @@ bool sched_can_stop_tick(struct rq *rq) } #endif /* CONFIG_NO_HZ_FULL */ +#ifdef CONFIG_TASK_ISOLATION +void task_isolation_debug(int cpu) +{ + struct task_struct *p; + + if (!task_isolation_possible(cpu)) + return; + + rcu_read_lock(); + p = cpu_curr(cpu); + get_task_struct(p); + rcu_read_unlock(); + task_isolation_debug_task(cpu, p); + put_task_struct(p); +} +#endif + void sched_avg_update(struct rq *rq) { s64 period = sched_avg_period(); diff --git a/kernel/signal.c b/kernel/signal.c index 53e4e62f2778..9c0be099fcd9 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -639,6 +639,10 @@ 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) { + /* If the task is being killed, don't complain about task_isolation. */ + if (state & TASK_WAKEKILL) + task_isolation_set_flags(t, 0); + 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 74165443c240..586a1309053b 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "smpboot.h" @@ -177,8 +178,10 @@ 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... */ - if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) + if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) { + task_isolation_debug(cpu); arch_send_call_function_single_ipi(cpu); + } return 0; } @@ -456,6 +459,7 @@ void smp_call_function_many(const struct cpumask *mask, } /* Send a message to all CPUs in the map */ + task_isolation_debug_cpumask(cfd->cpumask); arch_send_call_function_ipi_mask(cfd->cpumask); if (wait) { diff --git a/kernel/softirq.c b/kernel/softirq.c index 17caf4b63342..a96da9825582 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -26,6 +26,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -319,6 +320,37 @@ asmlinkage __visible void do_softirq(void) local_irq_restore(flags); } +/* Determine whether this IRQ is something task isolation cares about. */ +static void task_isolation_irq(void) +{ +#ifdef CONFIG_TASK_ISOLATION + struct pt_regs *regs; + + if (!context_tracking_cpu_is_enabled()) + return; + + /* + * We have not yet called __irq_enter() and so we haven't + * adjusted the hardirq count. This test will allow us to + * avoid false positives for nested IRQs. + */ + if (in_interrupt()) + return; + + /* + * If we were already in the kernel, not from an irq but from + * a syscall or synchronous exception/fault, this test should + * avoid a false positive as well. Note that this requires + * architecture support for calling set_irq_regs() prior to + * calling irq_enter(), and if it's not done consistently, we + * will not consistently avoid false positives here. + */ + regs = get_irq_regs(); + if (regs && user_mode(regs)) + task_isolation_debug(smp_processor_id()); +#endif +} + /* * Enter an interrupt context. */ @@ -335,6 +367,7 @@ void irq_enter(void) _local_bh_enable(); } + task_isolation_irq(); __irq_enter(); } -- 2.7.2