From patchwork Mon Jan 15 14:37:31 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: 188186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1743548dyc; Mon, 15 Jan 2024 06:40:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IH97oNJTecAHjz8Jdb718GkSb+RexTYSWHKxaR/6OklcK/qqMSOav/dGBtN+jiyBPLC+YQe X-Received: by 2002:a05:6214:1243:b0:67a:a721:b1b5 with SMTP id r3-20020a056214124300b0067aa721b1b5mr8103130qvv.112.1705329612970; Mon, 15 Jan 2024 06:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705329612; cv=none; d=google.com; s=arc-20160816; b=ThxT1nlebP8zZCXgj97ovhX2QzbagNI+ei7ga4vaKwsXFQTBp7TGI+DjHUne3T+p// iFiu9dhQpshCc52oateLZqsSxbwKBIIwo7mbmmGdfpOx9FH/vfwma0ocBogmRku14Eay pSphumpOFmNBQVGFGejj/fXn+m7fyb/MEWfI4fChHXYzZvTybX4wLmlHHYtA1YcDL37u 66LW4UsRrwtLvTynQGzFYRhshwuxSokiTtVROLbBMhSldRILYo4cwTqcgpmBo8xihbpj 55Xf2qKLjGSFARAfJCWAkjxvinV3RrCow9S8flL9hoDcgglUAIznTPgVY/H/C+uMAruh FWtg== ARC-Message-Signature: i=1; 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=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=QRl9bsgrm2/Z3NpMddYIe4IdlsRsgfApHihxcCMeQvaDONvqUzXQgRGzAJrMDVAS5r 3YojjwJyA0eyB7ywD7kY7WsQaiixbnIvIvM6oTJDx8b7o6QTLzr31LAZBxmQWXTkn/Hz mF4+wrdEB32UYed/FVOVBnHcr3jt2oS5p8ztR0zN/owTaEhlr0EZIgSNeA7Ylo4UphXy Nc6zc60ohWqJRw4o5mtZOY84ndOQPJzW3vRejqv/Zh0eArgS2dodPNR1jZ9gtjiTOPHs PJvaWqdw9FvCVwO2kes6cGX4Qh88ShIexoFGVODHZ5VCIc9MWAFdvMPXiqhJ2z5rRHO4 3iAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xLLcLooz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-26104-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26104-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j10-20020a0c9cca000000b0067f65b3857bsi7939259qvf.15.2024.01.15.06.40.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:40:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26104-ouuuleilei=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=xLLcLooz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-26104-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26104-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id BDCE11C2088C for ; Mon, 15 Jan 2024 14:40:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 082AB18AED; Mon, 15 Jan 2024 14:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xLLcLooz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="p1SCOwxx" 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 9C678179BC for ; Mon, 15 Jan 2024 14:38:08 +0000 (UTC) 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=1705329487; 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=xLLcLoozEBINigPBjKzXzLZqUlO4iXEH+bnYjLA8s9NsrzOM8ZdRuhFAooFDJdtoI7/Xzd aMwRjpebAWtxtl0NSl3/wnCFU5Ygagq0zg7hqzyyLeWBLhxnc7oI8qMYJECx97wGadrptu 2No2XTcbRpniHVJ/O7Y3cWbkSpPu94dyWNhFVcuKzWxOLIKy1iC3GjlBq05Gpm0YtRe+Sc PqmExnHcc5n0fOTTQfGChQssf8GUqb7mMsQLGnHw+MkWLLxGOCZ0Mi3dgw+PO3q3ix/y29 gP6fOiahz/2/xp5AP4hSrJTKmKsvnOH4KlAkHk01BLejV5ImgxJd8CUaozruLw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705329487; 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=p1SCOwxxFeN90cEaCj5jTm16QNT7JNWHQUUHeBYm8MRqtexuXM2Hn/RJJ7TY6rd4sgZiTK WJpMEkxX9GZiTdAg== 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 v10 08/20] timers: Ease code in run_local_timers() Date: Mon, 15 Jan 2024 15:37:31 +0100 Message-Id: <20240115143743.27827-9-anna-maria@linutronix.de> In-Reply-To: <20240115143743.27827-1-anna-maria@linutronix.de> References: <20240115143743.27827-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: 1788167704159799925 X-GMAIL-MSGID: 1788167704159799925 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); } /*