Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753776AbbHXBph (ORCPT ); Sun, 23 Aug 2015 21:45:37 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:36933 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbbHXBpg (ORCPT ); Sun, 23 Aug 2015 21:45:36 -0400 Date: Mon, 24 Aug 2015 03:45:30 +0200 From: Frederic Weisbecker To: Ingo Molnar Cc: Peter Zijlstra , LKML , Vatika Harlalka , Chris Metcalf , Thomas Gleixner , Preeti U Murthy , Christoph Lameter , "Paul E . McKenney" Subject: Re: [PATCH RESEND] sched/nohz: Affine unpinned timers to housekeepers Message-ID: <20150824014528.GC20044@lerouge> References: <1439516774-4614-1-git-send-email-fweisbec@gmail.com> <20150823054032.GA28133@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150823054032.GA28133@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3137 Lines: 84 On Sun, Aug 23, 2015 at 07:40:32AM +0200, Ingo Molnar wrote: > So I almost applied this yesterday, but had the following question: what ensures > that housekeeping_mask isn't empty? If it's empty then housekeeping_any_cpu() > returns cpumask_any_and() of an empty cpumask - which returns an out of range > index AFAICS - which will crash and burn in: > > kernel/time/hrtimer.c: return &per_cpu(hrtimer_bases, get_nohz_timer_target()); > kernel/time/timer.c: return per_cpu_ptr(&tvec_bases, get_nohz_timer_target()); > > housekeeping_mask itself is derived from tick_nohz_full_mask (it's the inverse of > it in essence), and tick_nohz_full_mask is set via two methods, either via a boot > parameter: > > if (cpulist_parse(str, tick_nohz_full_mask) < 0) { > > in tick_nohz_full_setup(). What ensures here that tick_nohz_full_mask is not > completely full - making housekeeping_mask empty? > > The other method is via CONFIG_NO_HZ_FULL_ALL: > > cpumask_setall(tick_nohz_full_mask); > > here it's fully set - triggering the bug I'm worried about. So what am I missing, > what prevents CONFIG_NO_HZ_FULL_ALL from crashing? Legitimate worry and I should have explained that in the changelog. Like Paul replied, we make sure that at least the boot CPU is excluded from tick_nohz_full_mask in tick_nohz_init(). Then housekeeping_mask, by reverse effect, contains that boot CPU at least. And we also make sure that the boot CPU can't get offline (tick_nohz_cpu_down_callback()). Now we should really document and check that assumption so here is a second patch below. The sched patch depends on tip:sched/core (to avoid conflicts with sched changes) and the following one is based on tip:timer/nohz but should be applicable to sched/core without conflict. Both are standalone anyway. Thanks! --- From: Frederic Weisbecker Date: Sun, 23 Aug 2015 19:34:31 +0200 Subject: [PATCH] nohz: Assert existing housekeepers when nohz full enabled The code ensures that at least the boot CPU serves as a housekeeper. Let's assert this assumption to make sure that we have CPUs to handle unbound jobs like workqueues and timers while nohz full CPUs run undisturbed. Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3319e16..cc9884f 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -370,6 +370,12 @@ void __init tick_nohz_init(void) cpu_notifier(tick_nohz_cpu_down_callback, 0); pr_info("NO_HZ: Full dynticks CPUs: %*pbl.\n", cpumask_pr_args(tick_nohz_full_mask)); + + /* + * We need at least one CPU to handle housekeeping work such + * as timekeeping, unbound timers, workqueues, ... + */ + WARN_ON_ONCE(cpumask_empty(housekeeping_mask)); } #endif -- 2.1.4 -- 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/