Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753136AbcCGJ5r (ORCPT ); Mon, 7 Mar 2016 04:57:47 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:51137 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752108AbcCGJtH (ORCPT ); Mon, 7 Mar 2016 04:49:07 -0500 Date: Mon, 7 Mar 2016 10:48:52 +0100 From: Peter Zijlstra To: Chris Metcalf Cc: Daniel Thompson , Russell King , Thomas Gleixner , Ingo Molnar , Andrew Morton , linux-kernel@vger.kernel.org, Aaron Tomlin , "Rafael J. Wysocki" , Daniel Lezcano Subject: Re: [PATCH 2/4] nmi_backtrace: generate one-line reports for idle cpus Message-ID: <20160307094852.GA6356@twins.programming.kicks-ass.net> References: <1456782024-7122-1-git-send-email-cmetcalf@ezchip.com> <1456782024-7122-3-git-send-email-cmetcalf@ezchip.com> <56D5A5E6.9050206@linaro.org> <56D5BCE6.3010300@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56D5BCE6.3010300@mellanox.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1392 Lines: 43 On Tue, Mar 01, 2016 at 11:01:42AM -0500, Chris Metcalf wrote: > +++ b/kernel/sched/idle.c > @@ -52,15 +52,25 @@ static int __init cpu_idle_nopoll_setup(char *__unused) > __setup("hlt", cpu_idle_nopoll_setup); > #endif > +static DEFINE_PER_CPU(bool, cpu_idling); > + > +/* Was the cpu was in the low-level idle code when interrupted? */ > +bool in_cpu_idle(void) > +{ > + return this_cpu_read(cpu_idling); > +} > + > static inline int cpu_idle_poll(void) > { > rcu_idle_enter(); > trace_cpu_idle_rcuidle(0, smp_processor_id()); > local_irq_enable(); > stop_critical_timings(); > + this_cpu_write(cpu_idling, true); > while (!tif_need_resched() && > (cpu_idle_force_poll || tick_check_broadcast_expired())) > cpu_relax(); > + this_cpu_write(cpu_idling, false); > start_critical_timings(); > trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); > rcu_idle_exit(); > @@ -89,7 +99,9 @@ void default_idle_call(void) > local_irq_enable(); > } else { > stop_critical_timings(); > + this_cpu_write(cpu_idling, true); > arch_cpu_idle(); > + this_cpu_write(cpu_idling, false); > start_critical_timings(); > } > } No, we're not going to add random crap here. This is actually considered a fast path for some workloads. There's already far too much fat in the whole going to idle and coming out of idle. We should be trimming this, not adding to it.