Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1438817lqt; Wed, 20 Mar 2024 04:17:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvbERR7kP8HlpPcf4U6+QADZX+AduyzZFIPwCr7BE58Si4tAG3lfSZUG22WhNayb32SGC4IAtoyoqG8xMGEMgkEOFZx6e62ckd/BI8iQ== X-Google-Smtp-Source: AGHT+IF57O92CC7Ns/1zqHbpk8ZI4HYoH7Oyym8cIY4sPu+L+jfKVeud1IkFnnsbot0u61zMVvxh X-Received: by 2002:a05:6a00:190b:b0:6e9:268d:dddd with SMTP id y11-20020a056a00190b00b006e9268dddddmr134949pfi.23.1710933429764; Wed, 20 Mar 2024 04:17:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710933429; cv=pass; d=google.com; s=arc-20160816; b=neMl0e5h5EckUQRe7g5m0ONoE84Sbc/JKfmPj/TarFRA3gjqTAzR02bqS5JhmEM5E2 SUsUUNvxKTw43AtqT6ihNZ6LFvuAi388Zal+EzIbhGOFMXcgpisYlT19iEZKoJoFkCPh bT5v7U7CER58Poo8ztP+LzyKdq/dJbe0YOm4gqx0zdu3pgMvy2NgbIpPcuI8mDrVHhN/ BJ7FTHJuNW4kb5gmQT9YEnEbACWwHfPQt+qPVkzsCJJYgdAijiERYOnRR7y/5GYFX3tJ AXzkZ8MGeofl4fYRtIeRMSyj3PweefpREKGgl9O5oih4uXSQCJ1vT76cQFRgDthJq3Mh W8Nw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=NG6bvsNJd4Ega2erkxMmTb1pI5mYmeYGfxbP0uc93Kg=; fh=Vzoq0nVshxERZBL4pLZ68yhgpR1mmqRekZaurNon2Tg=; b=vmYY6mDWrZ6d3zzCW5+tVJaZ5JiOO7nPoDzoZ9WDmL1uQxyDKF2yg7A4itb2ChmlP+ iwn5yI4/kdZ3ib2pojzSeScEEkPmZPa74CNshDMXKTGIoYI6uiuczCSeRFNSGyPyBClg ylUGUzMrW5cmTOtioK1yZ3dS1nkDCi40ArtJBXDU0G+Z5ttWeB+0Va16P/qQDsrMcn6K LTAcItNa2QIxNJw1tyGDlvbNY+ZD1bVOgdWQ0+cbXeqAw3sJCsWKGbDmEEiM8ozt1Tdg iraWJLOXQb7plJ9BoB3MO0nqbaKwjUdvktD/IB+eSUH3PMqHO276Vab8GHdzeAN5JE7G oqgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fj5aKgi6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t24-20020a62d158000000b006e69f482eccsi9975710pfl.316.2024.03.20.04.17.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 04:17:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fj5aKgi6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 597A4285434 for ; Wed, 20 Mar 2024 11:17:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B57603EA62; Wed, 20 Mar 2024 11:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fj5aKgi6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD3013DB8C for ; Wed, 20 Mar 2024 11:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710933264; cv=none; b=My+g4OF+/1e9/d66x+mj1qgCJRnQJYPHfkaYGaBZz4rMk++n0LZzI44mofYtmSK0HBl4kiLIgVbEPkYvqje8deZ8iz6EAwWdeM6tRT1rY43qm8kC2aJpmK4Z+kLiRn1NaxqAxK4V7cpSNzVJzZyI0y/StL1oQXkl1zq3Gck4wJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710933264; c=relaxed/simple; bh=f93gNh9P3wLWOA4ykU7okGdefFzZJd7zYhZkTfDnz4U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=naIkTV4SocAy1bcLdIUj6LakNebXw8n9qR/PnE0B8avXNtU57llS4k83+ZjyU4z4zlk2bcE1a72sevsIMgtLre6Vs9ml9CErGSYP4FvQVL3M0sg5/epnbIzLK8UvHLi95AQqeEEcENLdbrFTFF4SgFOuBPKUOl2Ii4ozn0FvlbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fj5aKgi6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D41DC433C7; Wed, 20 Mar 2024 11:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710933264; bh=f93gNh9P3wLWOA4ykU7okGdefFzZJd7zYhZkTfDnz4U=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Fj5aKgi65aIHaS3d8ORiOpHAN3UYX6iaVlDuNr53RextcA6m/ygwVvKnEcu4ubm5W dKS3uf4UyDZxERnoF1O4T44onEZG/vOojjWzg3hfOivxktVBFKv8rdqWdafIWQHwaK kLPME4eeASh+8yZHWzLKLIp6dm6TWKKTRBuqfIiTfXVSw1LqM4Udgr+KMH8hKIVuMv tOWIJ6wGgjQJmp73QRQwBL4YDEFu3eYgmgUMvGCFL/4xuGOaj069jvZEYaXD/sV/ve AydlLPLwTd8+JJ/AqMxcQolmpecY6kq7vALHK70UdXdbSHQhh4ILGS9WgZkT9QuE21 /0LQggvFYUpYw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 17299CE0F92; Wed, 20 Mar 2024 04:14:24 -0700 (PDT) Date: Wed, 20 Mar 2024 04:14:24 -0700 From: "Paul E. McKenney" To: Frederic Weisbecker Cc: Thomas Gleixner , LKML , Ingo Molnar , Anna-Maria Behnsen Subject: Re: [PATCH 2/2] timers: Fix removed self-IPI on global timer's enqueue in nohz_full Message-ID: <1b5752c8-ef32-4ed4-b539-95d507ec99ce@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240318230729.15497-1-frederic@kernel.org> <20240318230729.15497-3-frederic@kernel.org> <464f6be2-4a72-440d-be53-6a1035d56a4f@paulmck-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <464f6be2-4a72-440d-be53-6a1035d56a4f@paulmck-laptop> On Tue, Mar 19, 2024 at 02:18:00AM -0700, Paul E. McKenney wrote: > On Tue, Mar 19, 2024 at 12:07:29AM +0100, Frederic Weisbecker wrote: > > While running in nohz_full mode, a task may enqueue a timer while the > > tick is stopped. However the only places where the timer wheel, > > alongside the timer migration machinery's decision, may reprogram the > > next event accordingly with that new timer's expiry are the idle loop or > > any IRQ tail. > > > > However neither the idle task nor an interrupt may run on the CPU if it > > resumes busy work in userspace for a long while in full dynticks mode. > > > > To solve this, the timer enqueue path raises a self-IPI that will > > re-evaluate the timer wheel on its IRQ tail. This asynchronous solution > > avoids potential locking inversion. > > > > This is supposed to happen both for local and global timers but commit: > > > > b2cf7507e186 ("timers: Always queue timers on the local CPU") > > > > broke the global timers case with removing the ->is_idle field handling > > for the global base. As a result, global timers enqueue may go unnoticed > > in nohz_full. > > > > Fix this with restoring the idle tracking of the global timer's base, > > allowing self-IPIs again on enqueue time. > > Testing with the previous patch (1/2 in this series) reduced the number of > problems by about an order of magnitude, down to two sched_tick_remote() > instances and one enqueue_hrtimer() instance, very good! > > I have kicked off a test including this patch. Here is hoping! ;-) And 22*100 hours of TREE07 got me one run with a sched_tick_remote() complaint and another run with a starved RCU grace-period kthread. So this is definitely getting more reliable, but still a little ways to go. Thanx, Paul > > Reported-by: Paul E. McKenney > > Fixes: b2cf7507e186 ("timers: Always queue timers on the local CPU") > > Signed-off-by: Frederic Weisbecker > > --- > > kernel/time/timer.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/time/timer.c b/kernel/time/timer.c > > index e69e75d3858c..dee29f1f5b75 100644 > > --- a/kernel/time/timer.c > > +++ b/kernel/time/timer.c > > @@ -642,7 +642,8 @@ trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) > > * the base lock: > > */ > > if (base->is_idle) { > > - WARN_ON_ONCE(!(timer->flags & TIMER_PINNED)); > > + WARN_ON_ONCE(!(timer->flags & TIMER_PINNED || > > + tick_nohz_full_cpu(base->cpu))); > > wake_up_nohz_cpu(base->cpu); > > } > > } > > @@ -2292,6 +2293,13 @@ static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem, > > */ > > if (!base_local->is_idle && time_after(nextevt, basej + 1)) { > > base_local->is_idle = true; > > + /* > > + * Global timers queued locally while running in a task > > + * in nohz_full mode need a self-IPI to kick reprogramming > > + * in IRQ tail. > > + */ > > + if (tick_nohz_full_cpu(base_local->cpu)) > > + base_global->is_idle = true; > > trace_timer_base_idle(true, base_local->cpu); > > } > > *idle = base_local->is_idle; > > @@ -2364,6 +2372,8 @@ void timer_clear_idle(void) > > * path. Required for BASE_LOCAL only. > > */ > > __this_cpu_write(timer_bases[BASE_LOCAL].is_idle, false); > > + if (tick_nohz_full_cpu(smp_processor_id())) > > + __this_cpu_write(timer_bases[BASE_GLOBAL].is_idle, false); > > trace_timer_base_idle(false, smp_processor_id()); > > > > /* Activate without holding the timer_base->lock */ > > -- > > 2.44.0 > >