From patchwork Thu Feb 22 17:12:15 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: 204878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp84394dyb; Thu, 22 Feb 2024 09:16:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWzQzyjJMR9XLTSbpP1gtnIpHF0oZ//jQkoKslgNJ3WRDclgWwtsOKp+ohGMMfv3UqfryxJBVcFsd59/3cuYAalbO1sOw== X-Google-Smtp-Source: AGHT+IHcmgwBQ+tU7XgEjDS27aN4023fTWCKuQFuljm0hZaHDQruH1nTQVHrfNGN3eotqjjlneQs X-Received: by 2002:a05:620a:b52:b0:787:3820:8d9 with SMTP id x18-20020a05620a0b5200b00787382008d9mr22904223qkg.0.1708622193440; Thu, 22 Feb 2024 09:16:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622193; cv=pass; d=google.com; s=arc-20160816; b=JxG+FWldQJaFTYPfy3bTlMjTrZNmbMmYj8Q/+qxLaKENeHaM/s77qSoVArC4aVCru7 MP7gAq+W2EAl+vnO7e/VMDkAA7wG0zpVnbWVmmveQ+1Re7FqnQrsi+yum7hE23otC9SR tMkYgUKKaBGNL37Dbxd7tF8fUhCxR9UXmzK6LRGbLF9yco7DYYZXLVDIXLBdT22S3BZH TSsJu/0U3aW9tsp9withz8B9Jscz+ndEznVu4HqPzh4uJCxMV9xuobQfL1ivUL/0shy1 PABhlCfoCymLFgLF0lIfB2ka/atyFzg5zo8gDNd1VIHXoE9X4MzObV/g0nGnO04d1FP/ V3jA== 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=vkVvU6QEBG4OfplpO7retMfGa8X9Pg44oLEEEvAMwXI=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=E2SC6+k8KGyfGtXnR96+gstNGRqZ++XiB65HBWqQ/X9FTX6IOtGnUKF9qhMfipt7G4 cImYUqo33bdNbEce2F7gWfdMgMqAMpmxFDl+AehYX2t6KKFm49EznYLqKBsGZKBpMsn6 QJAVGN0uYbaIrB7yajzfan0E+2POwVCQwrT/DfKnEBP9xo5MwPHMGCAJUXur2WmNB0ZR WENOnBSkimev+NkQoaGXZcnjXeoShn9OdvXbRC2QbbnoSVveoQrpT2uqvEvcwcwwhEoQ 6I/72aZnkUKkNSX6GlF5c4t52x5dvk3OPE3QS0whJA4Q5u17FVZRf2tRA6Ql22cEffl1 3fgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wZfxZJ5A; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pEU6xs7W; 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-76948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76948-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 bp44-20020a05620a45ac00b00785d97bdedbsi15155951qkb.186.2024.02.22.09.16.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:16:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76948-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=wZfxZJ5A; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=pEU6xs7W; 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-76948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76948-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 188601C24816 for ; Thu, 22 Feb 2024 17:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9846915B0F3; Thu, 22 Feb 2024 17:12:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wZfxZJ5A"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pEU6xs7W" 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 DEB02158D60; Thu, 22 Feb 2024 17:12:17 +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=1708621940; cv=none; b=XDMowAxHtsFg0mhedUS6eR5wbd+gIQ0rDnb2bU0+j387EtcZMA8T4hDSuqU9OfAbxZENNqhkXVM92tpsHV5+U9rneJ/pHtCQIdCFf+hvbFVNIsLHY3UGYzY9KAuenPfI7KCaSSNfBHcG45ERi08dYTD8goDUAJj9n8XI/5781P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621940; c=relaxed/simple; bh=spfvFpvgZqlevST9g3chJJby3hp1JGyx6xw/6yUN+zg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=bYTDzvK9jpMNw9LVy8DCAYZc+kxmmgBeDqhURoaHG/+bDNpX8k/oBDl6s7VEkmE8YCsRrltG+sPm2MfK/roV1t+Fq8TwAzIQZgCqrSVfS5EJgEpIQxvixyFe6pu4Yfzq3W94vOnciIhnMQXoAUf0Y1u+Y82FEEn54cnI7IE10e0= 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=wZfxZJ5A; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pEU6xs7W; 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:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708621936; 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=vkVvU6QEBG4OfplpO7retMfGa8X9Pg44oLEEEvAMwXI=; b=wZfxZJ5A2Tax5mLdo9lquOskjgFIzwwNjYFyVEHCxhig3gHxLo0rSEpoTMeUatKsVpaLWk h6hohRX+msdWqJN5wjEDlo0SThY4Uj2kU0h93N2PZRxIhmGrtLx1x8xMQVe3aVK24msP5j pd++0Psn9yJf9fRPwanqgGjZZ80fagAGln5xlVn8oLNpH6nd2FCMzRkad5AgYZMXspnD3C 7bkV8fw1khMb1qj05AvoJ0U9YrfsY2CqFpjrYyt1TjQB3v++0P3AaWo2+PQxZSMuTQTRCi EUdesZq5ODXhPjzOMLbzxpiANTkUzvfGR6VN725BjPk7TOcRJlhkIRaCKmG2Vg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708621936; 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=vkVvU6QEBG4OfplpO7retMfGa8X9Pg44oLEEEvAMwXI=; b=pEU6xs7WG/JTgjx3itrGmYe/qc5SRdUS6PHYRruuZ/AnvJnCuuHIkjwTEeI2515GfvKg8P Ff86PfgSF/uuwbCA== 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: Optimization for timer_base_try_to_set_idle() Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221090548.36600-5-anna-maria@linutronix.de> References: <20240221090548.36600-5-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: <170862193530.398.12139687590128589522.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: 1791498874670065018 X-GMAIL-MSGID: 1791620225198634720 The following commit has been merged into the timers/core branch of tip: Commit-ID: 73129cf4b69cd1aaa3dd5eb7900a9c349773f5ae Gitweb: https://git.kernel.org/tip/73129cf4b69cd1aaa3dd5eb7900a9c349773f5ae Author: Anna-Maria Behnsen AuthorDate: Wed, 21 Feb 2024 10:05:32 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 22 Feb 2024 17:52:30 +01:00 timers: Optimization for timer_base_try_to_set_idle() When tick is stopped also the timer base is_idle flag is set. When reentering 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 Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20240221090548.36600-5-anna-maria@linutronix.de --- 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 344b904..f6b6133 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -896,7 +896,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 a4b8a58..74cfe21 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2044,13 +2044,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); }