Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp904890rdb; Fri, 1 Dec 2023 01:28:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxsF5KX4+DnlduSitlmvRLrRHvbAjNMF9dOkOJUNTg3EyUq/Bq4Rqirt8I2nNFb4m4MYP/ X-Received: by 2002:a05:6358:94a9:b0:16e:5deb:1df6 with SMTP id i41-20020a05635894a900b0016e5deb1df6mr8092928rwb.31.1701422935256; Fri, 01 Dec 2023 01:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422935; cv=none; d=google.com; s=arc-20160816; b=noUQFdA0963tc9s1l/CtEFKgvGMCPCnWNX+hTA0El7N6ESso+hSc+F9VuCuBwUpTmm u2wprtERFSBbRZrLPkrcDwKmL4AoolBwBbbJtqphOS7LjB24L8iHnxcV/mGeXxnBVGzh L0Tt/pUTbZaKDZeqa7n0d+GwPPUMeERAQQIIUpmOiSwh1pfh3E8xX19jqd1ZWMZU20HF /S/6+NsqNV839HQW1CBFDd2Y3MFVjm9y6tFiFFxryqjwWyAXSxGFTG8lWfMW8t7X0FLQ iXvuabLErJVaXIeZCOHLEkeG4FS9PgnaEC00232aWvrax5Hl4FVfN6zXNSJyoX98W1fk 21Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=HptRrZ5M792iqw/iN2UweCexRRIRvwfiQKQYLI/3wHc=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=wZIMc+8uHJ+wWSwNrNzhNJfE1DEWLZ2ntiqzk3Qo+KKA2phP1aRYk2E+uhifQHyruz MeKVpEm1YRIhOo3vQNyc62t6Mm8PJEJS5G4KAkKxpe8vXxR8bcgBw9MLeiYE68shNlLU yKzdN7tb4/3Jri6PUHaz+bZVwkafW88vSCZiXS7/oPf4eVMkUHQO8MkL/PSPPAwzCDsp xNP518I7Fi28OPmYdpq123kTtieW/X7go9Jfc0LayBbxTu5PvOAmxJhiJM7GAtT/rUY2 8g01b5geGqF0jWY2qwZYz5GTuLCBIu3/Uhf0zH1OtNZqPsffwZSZMrmoUpaEqkHjJEaf qpEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="yTBAHA/p"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b15-20020a056a000a8f00b006cde67e5101si3148103pfl.55.2023.12.01.01.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:28:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="yTBAHA/p"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id F13AE80EA97B; Fri, 1 Dec 2023 01:28:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378227AbjLAJ2V (ORCPT + 99 others); Fri, 1 Dec 2023 04:28:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378144AbjLAJ1x (ORCPT ); Fri, 1 Dec 2023 04:27:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A161BC0 for ; Fri, 1 Dec 2023 01:27:22 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422840; 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=HptRrZ5M792iqw/iN2UweCexRRIRvwfiQKQYLI/3wHc=; b=yTBAHA/pD9Zi3YxjUh/mQPwH80wDQzu4NBOMSc/YlI4oybqc9oa+avtTTMz8Kf+WValTlA dlgISBVCf286D9fbca7mOEhZHUF/fAFl+SrOGDRZtFGcwqMIAvDyHD2cBjo+ebBS1CLvEY BXKYL4sowwjTmrKc4/uWkT8jC/FBfRqYPQGcgHMkXH8GrcgMASx+z1ttb8dMp23D7Ifp86 dwNPYPaYfxtbVjvmKlyr213mfH7G4EKdLJTnLXs1a3ogr5IK4ts3I8LmE4F7Oh8nBih1j6 8/itFyFnOyam5q9D2UY7ueoJkVx4/vtYSK3ZE08jUy2PONXP1WmfA9cIoISLVw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422840; 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=HptRrZ5M792iqw/iN2UweCexRRIRvwfiQKQYLI/3wHc=; b=L5L6rigwBQq2b2USGQ9rEjf9ZzpKMx4OAE8/3HInusvYXAisr+mmjXdoDjX4CVFp3WP+ma yfayh02N64lbiAAw== 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 , Anna-Maria Behnsen Subject: [PATCH v9 20/32] timers: Ease code in run_local_timers() Date: Fri, 1 Dec 2023 10:26:42 +0100 Message-Id: <20231201092654.34614-21-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:28:49 -0800 (PST) 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 ea94479ee7e2..b14d84f1fe50 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2132,16 +2132,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); } /* -- 2.39.2