From patchwork Wed Feb 21 09:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 204030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp918974dyc; Wed, 21 Feb 2024 01:09:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7UpFBVyG2GqLLpQZzC474IWottEymME7n1ARaqgDhhdMTP5eMoMxJR4kUG88CJu/3ZcOVJ3l13uxzRcT1ErdPr+S+qA== X-Google-Smtp-Source: AGHT+IFULAWI9YxD5VfJUS51bKbbMXD8LK3vm3BksE5cPxtsLxaq2Bu0pixtLMrJMh8YohKAU8es X-Received: by 2002:a05:6870:7818:b0:21f:1679:d6a4 with SMTP id hb24-20020a056870781800b0021f1679d6a4mr4618604oab.30.1708506542472; Wed, 21 Feb 2024 01:09:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708506542; cv=pass; d=google.com; s=arc-20160816; b=oMaHgR16MvrFpDwo4j6PB1Q5auGLxCGBnrJQGtl9LyBujddg/Bos9xQkueBU6NlU4O IttSDCow6iULTxCawDfKC0VQYEkOfzRsdnLJDV15leNF69ac9bZffDp9MhUYEbShfQ35 Z6p56HEpKVP9BboMNaYmD9ey9ARRZbJL0rX/QY+1OrOsNskfh5ZEhEk8R5pUWy/zoJM4 Fp0nBaC8v2NOPM6i+rypW/tJzVNlD7+TFJfARAlBz8KxI5tb3ns86eRdul2n8VwVKSYj qiZh8lvGefGRcLi3UDxn1fVOJD/UbavzFDggEeshBRWqICUSZqcYKDsvGHWRTKT4qk5t InWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=JNIN8XCUDE1sXjDFOsAqNC/m2dPziZPst5V05kZh90Q=; fh=N5fTIFf2i7nvF8Om7kdprA8Zy2dleTNav/f0ArIISzo=; b=q7jQeTSpBWpkiINXH6oUI3YXYRcVo3N/p00lgUgbfOV1i5DMg3cYXYPmIS7xj2Q178 J2pqO8Vu89zqyH9mW0LYyCkQnV3Aq8z0olFE3jFblVYgBgkw+g0ClCltAFcIf2NZexiO ZmOAzWMjgLxT8EFXVz8IzDwAi/Ii3qgTYOFeXwnE1Az5btgGqJ7M/MRJPE7eF5fNunMS SQgMQK4+XOAfILrmUslNUfBCKSs07l5u5f584JApPtIuiw3seB6gB8wRfploUgAnLEVz mB8rwKFIatgqyJKBcvJO4fv0YYLDiqEgUcOo9ty7TdeRGbaNPNfCUDyrNnf+LlG+O1c2 NWpA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HvRZ57j6; 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-74353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74353-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k6-20020a635a46000000b005dbee5249fcsi7792389pgm.688.2024.02.21.01.09.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:09:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74353-ouuuleilei=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=@linutronix.de header.s=2020 header.b=HvRZ57j6; 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-74353-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74353-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2DA83285069 for ; Wed, 21 Feb 2024 09:09:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79F913FB3D; Wed, 21 Feb 2024 09:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HvRZ57j6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pE7xSGt4" 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 689733D548 for ; Wed, 21 Feb 2024 09:06:18 +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=1708506380; cv=none; b=fZ2uX6U+nPk8Z1pB+ZeGzYjJNtlm4oq/RbIwvegTJQn2bitKvQTAa/g3qid5pudxYbYaLTBkXBDkXOitR5paqSYOgy281D0Wxipm26GM4zg75ChYzeIpK53WbCzflSdzxg/MnNq2gUEsAU4trxpBIJKlPev6CCAgB87gtt1FOFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708506380; c=relaxed/simple; bh=fMnUip/MpnSW36woG3gUZ5/i2vpiyMU5OgA7NkdHqf8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IBiTXXBdCNTcXd0uZNK8AMTVUXcBCX1Hb1Bb8OQxXBgU03Wy6TzB5sKo/MFXQIj9HU/bifO0oEkvt4QkQcQY6DCi8B8rOmvLS6vp9LplcSYhIDIAGfqNS0FUAsLXcK6WPaGQdWrO2Nocy0nf13PF1us7ASJYVHbRnqbkUrU3rNs= 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=HvRZ57j6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pE7xSGt4; 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 From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708506371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JNIN8XCUDE1sXjDFOsAqNC/m2dPziZPst5V05kZh90Q=; b=HvRZ57j6yC35ZAi87VIvPdSqQPxGKA37Fw5X7GMyMMKu1PfClEnNQrcXGlFTP/Ncd5Ggko WkOe7WnAQEIKhr6iCuAE4crKzZew/srk5b/5yAxWmKWIezrXGPmNElWemBRCRijklkzP0C MxrzAFxL+iyYoivIEGQfXV3ztsm5CghxWCE0mjMNz5AnuJZkUsNFb+Ih4DrIAtcnT7Wcj4 SDZL+9mwyIHjckotLCYp3EcOZ8vWvZZcs5fvkfjWfVjL93vqXWZFK91V6kplXSUy5AP2dZ u3BLvRGgA3X6W+1iBKKSNzjnakCsR/+ggBJNTivzCJYbLinCv54nJ2a/laagGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708506371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JNIN8XCUDE1sXjDFOsAqNC/m2dPziZPst5V05kZh90Q=; b=pE7xSGt45DLeitGoDdAVEkrpLrx8syoI2M2zBt+QD+vQJM+h6MjCvTUuyVdQJ8Z904MgQQ 2Renbh2v4LfXzFBw== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak , Christian Loehle , Anna-Maria Behnsen Subject: [PATCH v11 08/20] timers: Ease code in run_local_timers() Date: Wed, 21 Feb 2024 10:05:36 +0100 Message-Id: <20240221090548.36600-9-anna-maria@linutronix.de> In-Reply-To: <20240221090548.36600-1-anna-maria@linutronix.de> References: <20240221090548.36600-1-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791498955901242262 X-GMAIL-MSGID: 1791498955901242262 The logic for raising a softirq the way it is implemented right now, is readable for two timer bases. When increasing numbers of timer bases, code gets harder to read. With the introduction of the timer migration hierarchy, there will be three timer bases. Therefore ease the code. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v5: New patch to decrease patch size of follow up patches --- kernel/time/timer.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index fc4c406c9ec7..793848167852 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2135,16 +2135,14 @@ static void run_local_timers(void) struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); hrtimer_run_queues(); - /* Raise the softirq only if required. */ - if (time_before(jiffies, base->next_expiry)) { - if (!IS_ENABLED(CONFIG_NO_HZ_COMMON)) - return; - /* CPU is awake, so check the deferrable base. */ - base++; - if (time_before(jiffies, base->next_expiry)) + + for (int i = 0; i < NR_BASES; i++, base++) { + /* Raise the softirq only if required. */ + if (time_after_eq(jiffies, base->next_expiry)) { + raise_softirq(TIMER_SOFTIRQ); return; + } } - raise_softirq(TIMER_SOFTIRQ); } /*