Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp380264lqp; Thu, 21 Mar 2024 04:25:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNCrSWD7o/DW3PaKwh49jyJQh+SllxDZcjJYkgO1sMx4U/QfXKA88Kehc0jY02hh53PLK64BosjdL6bjlrcvGs/lJnqoJaY7Maern9jQ== X-Google-Smtp-Source: AGHT+IFefiTEfwKeWl+uiNtQ9Z1cSXanrob5WhhBWmwDn93ecyvO7dfNx0KgFbDzpJA+cEt56BLq X-Received: by 2002:a05:620a:201c:b0:789:cb4b:5437 with SMTP id c28-20020a05620a201c00b00789cb4b5437mr1649074qka.20.1711020308116; Thu, 21 Mar 2024 04:25:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711020308; cv=pass; d=google.com; s=arc-20160816; b=Lmg7HIsNDEzyJHpqThRDt2/yTJYARN/iKCSFBoZWH354fJq4tGnHQazCbKRT6G3eo6 WbuF35eo8VY1nDVE2uWhHe254/mhYoiraDKBMFRSyFwPrefZdAwdTCNuvnZntV25q0l1 fEK8O8RVRQOawC+q1WU12h6meYalLniJo5V8Zy6f1gYuMTVmiJuket83LdLOBVjgu0Tg N37j+k8V2AUVjlSUROMq1nKghtNHnf6odf8/XUm34t0IkyC/IlsKblYtuc0ToNY74Z68 i+aUr14KxF9NzWQnx/IDjpQzVEw1nk1OZIHNpdPjq43UXPL8rghgyQRU9AY9Blievqy6 a9XA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=DB3NZ8/yiTaLUxCgKAXvKDAwe8/HCjA6a2zA8+1znnM=; fh=CjUNxBNPw+RuzJ1mPi0nM8olErqW6eSI1zNACgzR+B0=; b=ZdlWUFynSsvoVrPvDCAhWJYQzN5VpPKpRn7G7NAOfgEL6nPUBN4XS6E479izkweO/M 2OFI7M5gqA4bwVPwdZ5wTDvnuMAYLrEM16YFrGiIEBImKwksML3L5YdxrbPoadf3JFqk WUhvgM6PjuUbuOCRn6L3cCu1YnLldMY9KQiQkwq+xf2kyrK9UZH4jW17INBQe25ViC0R St4XvnXuotbtFx6lw0rmfwlyBN49f3WshKojfG4JMvkcddbYfkDtHHuOy8wO2QlXSq6Q CTFN1Juu4eMPVgUzBtwHYfIh3W6T2DFqT7wWyzWoHD5r6xJB0KpqQDzX6+F3rBsKMw8U 5qgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gKqs2UKr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-109960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109960-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bk38-20020a05620a1a2600b00789efda569esi12388645qkb.22.2024.03.21.04.25.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 04:25:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gKqs2UKr; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-109960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109960-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F08401C227C8 for ; Thu, 21 Mar 2024 11:25:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0E8958ACE; Thu, 21 Mar 2024 11:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="gKqs2UKr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0IediqO2" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 4D1F958129; Thu, 21 Mar 2024 11:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711020297; cv=none; b=Q3z9pOzGdUa08lCdMDRao0WvyqPvTtNz+3hmqxeDpD4n8RsaWy0JWE2NyLqChO8US0xlLYhtGyC+xBn7XXCRGDBsTZktlvTXZwSE8yPeGWBboOlq9pAx3kCOrA91TpQmT/1y4D2YYeABqn/gBywYXkFAgmkpWHYTaN8jqFg78fk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711020297; c=relaxed/simple; bh=3ILvGA3dlGIwDdBbVnww9/UjWTQFT0UfP6FD0k71DxY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=AHPGtsiqumqt4iJhUwCvcV+DsZNaK1V485oNyTnpCfKmi8X/hvFwE2/ciLed1Q/7l0QBESrBn8KzU9HM914mVdC3av6BryUWSvqxJthXUOaaf3uOrBUBj841Z4RbT+j3xcpqTX4PK1XoBsue7gtrvqX9SzgRpOnQkrHZ5ovP+5M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=gKqs2UKr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0IediqO2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Thu, 21 Mar 2024 11:24:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711020294; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DB3NZ8/yiTaLUxCgKAXvKDAwe8/HCjA6a2zA8+1znnM=; b=gKqs2UKrCIylI+dIm1SULPrulvoxlsBckxEzczWPpmyt/gYqLz1WTAwIkO7XRCPWgOwg17 U3ztddeKcRx4BMubgNZ637zcBvNAxEf9xo/h3aPY62nbbydAppv2rV60Dbm6ndTeY0E55R xyPdjTxKljU34JWqMlwJHELKYF812cC+fMXvp/RWNzhfMa65VHVHvlnUsTE7lXZxeE1NN6 QCccgJ8ktwz3YSsSt3Zg7H/kSvHMqds7xvwby6Di4roAImi4Y4pzkxLWIVj6o8ZRQLdJ7p AVMhabEXsobzAUV5ZYPD18ZDfftkZ3H10LCc7yRhJgRsRopGQvxJrxtjvATx3g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711020294; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DB3NZ8/yiTaLUxCgKAXvKDAwe8/HCjA6a2zA8+1znnM=; b=0IediqO2vzc8U9VHATBsHFn4Ut+0XpvBNsLzp+sNPkIhnmSIY51Q+jfzgV/QI2iNypxpDO jYfbpWCguTJ6gaCg== From: "tip-bot2 for Frederic Weisbecker" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/urgent] timers: Fix removed self-IPI on global timer's enqueue in nohz_full Cc: "Paul E. McKenney" , Frederic Weisbecker , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240318230729.15497-3-frederic@kernel.org> References: <20240318230729.15497-3-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171102029326.10875.6622636119030507753.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the timers/urgent branch of tip: Commit-ID: 03877039863be021a19fda307136657bb6d61f75 Gitweb: https://git.kernel.org/tip/03877039863be021a19fda307136657bb6d61f75 Author: Frederic Weisbecker AuthorDate: Tue, 19 Mar 2024 00:07:29 +01:00 Committer: Thomas Gleixner CommitterDate: Tue, 19 Mar 2024 10:14:55 +01:00 timers: Fix removed self-IPI on global timer's enqueue in nohz_full 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. Fixes: b2cf7507e186 ("timers: Always queue timers on the local CPU") Reported-by: Paul E. McKenney Signed-off-by: Frederic Weisbecker Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20240318230729.15497-3-frederic@kernel.org --- 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 e69e75d..dee29f1 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 */