From patchwork Wed Feb 21 09:05:32 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: 204027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp918434dyc; Wed, 21 Feb 2024 01:07:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWN61rP8Hs6o+81US6ScHVYXqyxzXXEBKKva4ck3hLkhB4rp8OKRE/jWs1AAO/BK+g/gct82yLuOU5ma+n0TSzlwRl+SQ== X-Google-Smtp-Source: AGHT+IFp318GK1mfCI61KXzizq9vMRPit86BohABoDx4fAdZhFTcRWmo+EjenmznEfymKkRVNzWa X-Received: by 2002:a17:906:ca59:b0:a3e:48bd:93ed with SMTP id jx25-20020a170906ca5900b00a3e48bd93edmr6902135ejb.61.1708506464622; Wed, 21 Feb 2024 01:07:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708506464; cv=pass; d=google.com; s=arc-20160816; b=UjScY01mjT0HWIA2ZtKa6/eo5nOby2L15c4Ro1948vD9DWWikAOnkYSw/4a9BMWCxq PQ/OagcV12OTAxMqrDGuX67pDa8VZBtPNu2pTaDKZirRTN1OTiOc76tZAH2qs9DCWx4T /pa53oHJ5fBUvGgX4ULM0U1DkzlsOGNZWMdHuc1RBs2CtCCITL4B4jOzH5DDQtxIGjjB UXMDyCSwhWtGQAnK5ZC5a0dPMiiqNIPRytlAQ6FI9B/ueEHu9SXqj+AtDeoLfVWPRO51 zVpWDC4gSXqeBvBuqHeXoXsqIC/d5c80IhtY1mdzL6smUBT6K37VY9/+q8tQn+oMz8hg JuAw== 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=8x8V66oedAQdLiHPaHBR+VdwFWZt1XkVYVwYivWxpoM=; fh=N5fTIFf2i7nvF8Om7kdprA8Zy2dleTNav/f0ArIISzo=; b=kETjzURQT3UmdP2w/fkdq4GpeVAZwDmlSeSDyR/R/g/wornhkfLgqohGE2fFt3HTYH dzNapjCRmSD2CnTLsYflbn9clpQx0x8yN7cc1T3jxuGIR7kv3IBrRVd0q9aGlrYiZHtJ peTXDWhJmfpJlD/hwiPxltYn5fm3U1zCHgKHiCkSQ86nhF1uczqMWIX/u3rNRx0cytm2 A1Jr/Q6dYXOZtN6sO+Ch2xDikObq7gBH7HH+NrQVU3NPRXlSdLlczyTjLq4jIGU/AXis 6dDVlvAfe6Ac76EjCKdHy3TcI2GHvtbXuUNzr5PGUYfvzRAjUMiwEjaVzYsR0ciF0yia sSoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hx8+Knr8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tf7n+Sll; 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-74349-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74349-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kq2-20020a170906abc200b00a3e461d567asi3413507ejb.666.2024.02.21.01.07.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 01:07:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74349-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Hx8+Knr8; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=tf7n+Sll; 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-74349-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74349-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3BD011F21D20 for ; Wed, 21 Feb 2024 09:07:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B29833EA71; Wed, 21 Feb 2024 09:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Hx8+Knr8"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tf7n+Sll" 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 8D68D3D0B4 for ; Wed, 21 Feb 2024 09:06:16 +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=1708506378; cv=none; b=MWgKu9LMEJHDy6uRQxViUyLk7zV59o+EpAJxujkbQ0yL8Tiw+liT7MSGT3jbzTR0BeOPW+hjoPr/ybLtjKZ/uz5SGoHibore1PqBxnYb341eA+WpaSoLv7rWQn/LEMA4Zm/4D349nKrLQoDjHd0lzRioqN+XZkjzOzN07o2ubZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708506378; c=relaxed/simple; bh=ws4UsvqTVPEJwlRcuRRnPZASwZHWSXxgj2cFVwZJl0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VuhR7wKrB2ogeC8svnWDZA969Ac2KTroZ9zaZxUSqhD/zPTgReGocAlYgXsB2FPfvRyMyOKjN3YyYLWNJyRGrCjqI509gY6Np/VOOhsZt5Iq9ReenyFPbEDEA677Kzc3GLDKLcfy/aG2YgTShYpR82yoMmmIE+0PVr3D01Lb1I0= 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=Hx8+Knr8; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tf7n+Sll; 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=1708506369; 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=8x8V66oedAQdLiHPaHBR+VdwFWZt1XkVYVwYivWxpoM=; b=Hx8+Knr8Z4dJ4chBC2NafZksHEPbKTCpR5IGhR5LRCe/JaVTRP1EVRAFVm/VJOl7MBivfe CPlw95EYEMRha70OszFXL+AVP8hFXZvntTYUYhybEgjSL5i3kmhQp7jFVcIZXwns/6tYGk q41Akso+7a0DWowVMQ3bmFU9ahEdtwN0UzW39j5mrSGuZrYeWnqnaMPlbWS3/e5rMXTftv vUPeQ9XL5zaV5IPOK+3s4AZJH2yqCvgWtbAoJ8ZbUQf2ROC3DW22hZe2oqukjmo/F3ggA6 Tncb3XnmNgp98CMmz3BrCv7Q9FsIO9MNd7eAnYKhhIOGIRlWbnXmRRiLeltMkw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708506369; 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=8x8V66oedAQdLiHPaHBR+VdwFWZt1XkVYVwYivWxpoM=; b=tf7n+SllvBHbEQu6a0UoCrngxBM8lQ8i8OnvMAJYCfZztbbKhMtwZZwKcgArYXicK4Ufuj Q4BGYcmQOmDy/TAw== 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 04/20] timers: Optimization for timer_base_try_to_set_idle() Date: Wed, 21 Feb 2024 10:05:32 +0100 Message-Id: <20240221090548.36600-5-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: 1791498874670065018 X-GMAIL-MSGID: 1791498874670065018 When tick is stopped also the timer base is_idle flag is set. When reentering the timer_base_try_to_set_idle() with the tick stopped, there is no need to check whether the timer base needs to be set idle again. When a timer was enqueued in the meantime, this is already handled by the tick_nohz_next_event() call which was executed before tick_nohz_stop_tick(). Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 2 +- kernel/time/timer.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 72c80f6e7bed..384723314c1f 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -886,7 +886,7 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu) struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); unsigned long basejiff = ts->last_jiffies; u64 basemono = ts->timer_expires_base; - bool timer_idle; + bool timer_idle = ts->tick_stopped; u64 expires; /* Make sure we won't be trying to stop it twice in a row. */ diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 3a668060692e..2f69a485a070 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1999,13 +1999,18 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem) * timer_base_try_to_set_idle() - Try to set the idle state of the timer bases * @basej: base time jiffies * @basem: base time clock monotonic - * @idle: pointer to store the value of timer_base->is_idle + * @idle: pointer to store the value of timer_base->is_idle on return; + * *idle contains the information whether tick was already stopped * - * Returns the tick aligned clock monotonic time of the next pending - * timer or KTIME_MAX if no timer is pending. + * Returns the tick aligned clock monotonic time of the next pending timer or + * KTIME_MAX if no timer is pending. When tick was already stopped KTIME_MAX is + * returned as well. */ u64 timer_base_try_to_set_idle(unsigned long basej, u64 basem, bool *idle) { + if (*idle) + return KTIME_MAX; + return __get_next_timer_interrupt(basej, basem, idle); }