From patchwork Thu Feb 22 17:12:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 204898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp91925dyb; Thu, 22 Feb 2024 09:28:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU3po3OM2tCQZ8NpAH1EtB9tQAoHK8MFFzFNzqgN2MjKdnBx92D5icX9h0bf/uKQync5bmaWwGjrDz5v3i991zbXqpeZQ== X-Google-Smtp-Source: AGHT+IEyFclqXqyhPpaE/5mUuF5VITta2UIXp9wQ8EGZfxNYHikTDYMAwPeXRguWn5es7DSz4NBp X-Received: by 2002:a05:6a20:c990:b0:1a0:ce21:7888 with SMTP id gy16-20020a056a20c99000b001a0ce217888mr4436536pzb.16.1708622929653; Thu, 22 Feb 2024 09:28:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622929; cv=pass; d=google.com; s=arc-20160816; b=ZSxIa/uyTgeocD/wb/UviC7fGxBC2wYamSdicUUeatb8QGN2+YS/F0731IgBn0Ci+4 Pd2EI2RRciCZcpNggDGIiJR4nvVey7hh2wfCFYzG7SwbiIF9QIz3MS9eFwet5hr3ewju efGEplEuE4rOlIYUWRKY78kyi616Bw+si86LOPWOWVvGvEWK4tMnWoyhnU4qTudbc5Ar JSm5iIwpZexbYBdefitRJQGaqQB1Zpq1GSTJV2SrdCp+cGaLPsFh2R82NAY9P9DmYTJF zQOraEPFXflsRo+4TwXIw+oXz7FPFXzOaSfJRTnTXhdmmGdty6KJgbO4oYGHQJcif/GU 7V5g== 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=aPuKscbLmQCwJejxlBLH7lYZEv+GBgNpH9gNdQbiykI=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=P/FJWQxzdn8WMYX7BhSBCq/VcJFPS4BWbkKeokq5JBsCaebuiy8LbTZ+eqETf6rXDu fYS/LQhYx7Li8PIsLaSKXjmAz+awO3XFoyoUZKOlX72FzpwePgXdSn2JQjeZeca/YAPb 95sQVowT2XU2td+xb+ahQMyDQ9ObgD/cDH6mwDQy39wG+/SrfSL09GAKSWQ2lJZQuatQ i7j8k4n9CFanP/bOZXg+ICmM7N7qjHWdmb4Nfq4evY+471uoEGkNKntWldJINrzJiado MSvVTjT1HoQJgqsDpKyE8DtTUA8LLw9AlGCTNNGCVcFrNLOR5qzKEF+O78FvltElOhTc PoOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iqU4AIn6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ySaNGDEz; 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-76943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76943-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k6-20020a635a46000000b005c69365abc9si10660619pgm.687.2024.02.22.09.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:28:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iqU4AIn6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ySaNGDEz; 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-76943-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76943-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E633AB26161 for ; Thu, 22 Feb 2024 17:14:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FE8B15A4A9; Thu, 22 Feb 2024 17:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iqU4AIn6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ySaNGDEz" 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 45220156998; Thu, 22 Feb 2024 17:12:14 +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=1708621937; cv=none; b=A/2Ab8ZYUn0N4fAviSZYolTROnjtbXWTYKqYZCo/JXtOHfApMW20JWq75fFZeJqHqbz0cWqAIaYrjrtDWWfMIjUhu6EImgzY6nWBYR29rRaLu7rp3oTPN5UJ3jYy53W6fCve8tH7uvsuQN2OXK2zwb8qSVqndND43RmytfxqIQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621937; c=relaxed/simple; bh=MfWuiBK/m+NRYyBOunvmpucUCdyGR+jmSrElFB303iI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GBG6Y4W/FRhSTu6OMsPtH98+6tRKLyuQexFl1K7o+kE9dI2PrDP6PkGER/d0M8bQqTTtkEsxm4qBavHOMr1sLBz6qoaA4xMEk1th7R/2FBWzQNb0ft3OLXE4qqR9GbXRrt12tafPOMvjB0Wd15sYeyGm/fRaln+vjt/4DLGO9uU= 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=iqU4AIn6; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ySaNGDEz; 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, 22 Feb 2024 17:12:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708621933; 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=aPuKscbLmQCwJejxlBLH7lYZEv+GBgNpH9gNdQbiykI=; b=iqU4AIn6NrLUDRh/XraKAdf7e4doCPx/ac0uermHBSDG5Ik0R24oRtIszDX97NTVsaM9Mn Lhfr1zFX0W8uRU4yOVKe4ld0aXxlpVqJBnH/BwY+ojpTn5oR5ooT+isz/YQOHi+ednpM8G gKzVOln8GZpQ7GPTYRcUp3WOMku5oKcm6wob8nujiJ8hVg5czFj7q458IHtfrsZKadd3ce CkvesNCibWWdkINlVOjY87vsd6MZG3Ao10fHlMxeEOBtKpThkWo17TEbg0IURESoF6dsEx LZNa74rT/G/vxQ91ZK/q5xVRY7x/ebQnEHDjvF9VVHn2fo9mM8li5fFdRu09SA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708621933; 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=aPuKscbLmQCwJejxlBLH7lYZEv+GBgNpH9gNdQbiykI=; b=ySaNGDEzo81eZ42r64yUiksG6+9V7Kqect3ydlvByKdoKhbYUqH7ZUEgxR1iKqLo79xZCl JYGgEdR3HQyYbrDA== From: "tip-bot2 for Anna-Maria Behnsen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Simplify code in run_local_timers() Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221090548.36600-9-anna-maria@linutronix.de> References: <20240221090548.36600-9-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170862193261.398.16190156400027177660.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791620997182989871 X-GMAIL-MSGID: 1791620997182989871 The following commit has been merged into the timers/core branch of tip: Commit-ID: af68cb3fc736e13e66fc8202ea94c3aff7299f39 Gitweb: https://git.kernel.org/tip/af68cb3fc736e13e66fc8202ea94c3aff7299f39 Author: Anna-Maria Behnsen AuthorDate: Wed, 21 Feb 2024 10:05:36 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 22 Feb 2024 17:52:31 +01:00 timers: Simplify code in run_local_timers() The logic for raising a softirq the way it is implemented right now, is readable for two timer bases. When increasing the number of timer bases, code gets harder to read. With the introduction of the timer migration hierarchy, there will be three timer bases. Therefore restructure the code to use a loop. No functional change. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20240221090548.36600-9-anna-maria@linutronix.de --- 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 121f5b9..9c8443d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2180,16 +2180,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); } /*