From patchwork Wed May 24 07:06:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 98342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2653460vqo; Wed, 24 May 2023 00:16:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5j6hevHoppxL/foWoS4fJ9TRkOFMTJonsV7+gwrOGRjqC/xZWBa9+/KDCgi22QCdjXuwml X-Received: by 2002:a17:90b:1e49:b0:253:4a0e:87da with SMTP id pi9-20020a17090b1e4900b002534a0e87damr15719744pjb.9.1684912572416; Wed, 24 May 2023 00:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684912572; cv=none; d=google.com; s=arc-20160816; b=PKzSw6Z16qcegUCF2LB4eHYY8ty3j3QRpoE50SegkAxWGp9l7nz9yJAIuEzhrV80RZ aUAYQcSNp//186WAOMpemwluv+be78CtJBgy9MKyfsnHldzDMQM7iba4Qw41cPkq0SD/ X/FzRs/U/PzYG4Yt7xTrdmY2QRdMXezpOPnb4NK0IcMtvHLJNcG+acakgIHRolWtHuRd FpuSzjcTXB7FnIpKyz9sGJURth7zus5t9LBeslpRPz4SkbEU0pYE5W7/x2NU3miVaQq5 xwK/zEEvvFxT9Je0lnm85CcehRjoa41CMUPEQpOqScMrkFEUuDvh7vHrBbYlEfrkVYIU 8Oqg== 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=LtOGw35GRW9p2fx5MhyE24mUeYiFRQ6uZYmjDalJe0M=; b=CJTREYnDan8Jv1MyMjc1Mr3uVAUDdoF1yatZQ8tkBOWDyJ4wkusp37aSHt0ogFEaIa 8Eg8+4ShIQkkYVuxf8sg1Tl4zHJ9dLXp0/B0y4sFANUjE9gmi422n8c9ldMEMwvRrdKu SD+Yujrqe3AJC14VB6/HQoPIwklkAVRndBWiNyzRsOMEU73vmUUUfLM7++AlFThKGT2G eyqDeMBrdphGSeVuvlaNSvJ31EZIQI2t84AU63udC4mw8ex/1GJ9HkVZ42lhsUaOqdQS uwzSttHGAAgrXi/aJf4hajLIzmRjYdl1JxS8b2twCRSAekYSqIDxa5uBvLVZ6QXAbc8B s9eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=J1ihm9Qi; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a17090aa11600b00252b824d13esi851940pjp.30.2023.05.24.00.16.00; Wed, 24 May 2023 00:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=J1ihm9Qi; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239917AbjEXHHk (ORCPT + 99 others); Wed, 24 May 2023 03:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239820AbjEXHHF (ORCPT ); Wed, 24 May 2023 03:07:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BAE518C for ; Wed, 24 May 2023 00:07:02 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912020; 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=LtOGw35GRW9p2fx5MhyE24mUeYiFRQ6uZYmjDalJe0M=; b=J1ihm9QiV4eErwTOiXLtydZzQk3ZK591reJ8uJyZTe8PlOFAGOPpxGKB4PK4S9LUjSiXfx s0IHM/t8ILeKVq8J2Tybkwosbf9Waslq6LF0yICYluaiKWz7tzJgBFRbf/7W/Y3nTbtWtL 9iaRJWDGkF7HxumBGNLnzEeO4WIbq8OgJwF+2Nz7dCXTDT9B6t+YWwHb5NnmF8TkvXiOYu IlMVewgLwFHGSEz38RTO15XSCkKlOMz/7gWCG29FxL3bBFZZkVon6pSgeN6kcXdI1i58sv 0/MDRoCchmw1RCJmf2+fR2AhZBj1MrbscuE9ZqlXm0GN5jI5LQ2kMN9hpd4gOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912020; 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=LtOGw35GRW9p2fx5MhyE24mUeYiFRQ6uZYmjDalJe0M=; b=soTl8kB1cMiSPqjYY9ZdsFWoSmHOD953MyBsWjikDlSOk0eXI+4qAvO23ttFYxqFpya9TC 3g5Vrw9Fzpu64oAA== 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" , Anna-Maria Behnsen , Frederic Weisbecker Subject: [PATCH v7 10/21] timers: Ease code in run_local_timers() Date: Wed, 24 May 2023 09:06:18 +0200 Message-Id: <20230524070629.6377-11-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-1-anna-maria@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766758885510414247?= X-GMAIL-MSGID: =?utf-8?q?1766758885510414247?= 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 b7599216d183..749b1570bdcd 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2093,16 +2093,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); } /*