Message ID | 20231201092654.34614-18-anna-maria@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp991893vqy; Fri, 1 Dec 2023 01:28:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6vQsK/d5oQFqQBpbn/Wi3di68sKB9tg3AgZyf++JPXXb7rfL8Z+oT1YIHXfQbu2lXy338 X-Received: by 2002:a17:90b:1bd0:b0:285:ba0a:1c9d with SMTP id oa16-20020a17090b1bd000b00285ba0a1c9dmr18080461pjb.6.1701422900927; Fri, 01 Dec 2023 01:28:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422900; cv=none; d=google.com; s=arc-20160816; b=oQ7/Zz/KTmrKUZP8sxp65z8NwLWSa0vASafJTOS7qGr5SoWzVcEHBqp2mz32qPtrsL ewXtaVIe/Uk5AoXlud54jKFTQi7p4kpZumktISPFweDKClWUTemcrgGd3Ls9Iq3hmAFn Ozg73jCv3ZFF7xYq4cF22r6ewXYTTTCEM6J2uMmwoLjWeYseweK0QVUKc0Mpa290L3ND Zj+b5umvE3iJKrKv7XxYrdEYDet4+TC5eshwFSihfrxnymYZi901MTECMi8G9Dtuj/mV TEksMyrIUw378a64Cl/7qmgI+OJD5dGw4L6GZYIWgcWZXWmPZh39MB2zADiCHN3U5oHC 5czQ== 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=2ndzPV+KTt0XzydVGeObWOLfmNe4sV+QpfiiUpyraAg=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=0OIInY+Jp9PzBvtwexCatAf1A+H3Y6z568ji+PNLEZzZbYSxWlWylf0g/Qn9FtNT1f /tLx7PHFweu25YloIQWCwCuZBKJiyvGOrUnikU0bnC7de8qQjJ1VZWsJAhGIsUStxkgo 47EyzNr7Cyb9KiJq0IvZQ7fSTSdMnt6V10gRJkVVK8XpGTU/GKrl5TLyVo5LkuS3003+ C2CQC8rVtZQU1NFRmCADj8JL/X4HUhjGy4vBZ61X9zhm/DJK97p4udPZK4q6AEI1G3eG Yf+SnIwMAfAS2potoqG+zusGloqsdzivyyGBJCegkjsSqAe0W7uZPMn1PvOrVZi7s1oc xK5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DdWrzuSI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h24-20020a17090aa89800b00285b3f6bb57si5240740pjq.60.2023.12.01.01.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:28:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DdWrzuSI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 041C980BD4EC; Fri, 1 Dec 2023 01:28:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378028AbjLAJ2B (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Fri, 1 Dec 2023 04:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378092AbjLAJ13 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 1 Dec 2023 04:27:29 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E43B9198E for <linux-kernel@vger.kernel.org>; Fri, 1 Dec 2023 01:27:19 -0800 (PST) From: Anna-Maria Behnsen <anna-maria@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422838; 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=2ndzPV+KTt0XzydVGeObWOLfmNe4sV+QpfiiUpyraAg=; b=DdWrzuSIaDLRs7yzIx91ENx015zY+Bmvcwzkws9SsYYR3IPive1ZN/YjvXz5AIRcb3lUQJ 1eaFD55Yp/84jZkuy4xRdsDKlqi5dUG53CUAHvUuV54SW87J2P5dxCDkXn3pw2SM+IHA+m oliEtTzAMLz+4sI8FKcuCJKbwTxCuIWJgldOAhjkWo/A9xAV+u20RPxcVr6+JQyO5/lN/N eHQB8YWgHLehL8GusjKbxBsc60KV3OMVRv5+KyaETXeoUXX9j4McyXCEaPkbXT+pAVneeI QIo8xmTScm772bnbBNl5nHwoqorRETkJKffNZ6f40vJ/4UY22exgyqwM/wyewQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422838; 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=2ndzPV+KTt0XzydVGeObWOLfmNe4sV+QpfiiUpyraAg=; b=gEaTy8k+UeiLTYq8M4pK9aVOhsiw88tdR3F5jM7tqK3wQRMcl5vQgHp9XLAOw+1WTVDKxw WN8aKGqD4x3gUABw== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra <peterz@infradead.org>, John Stultz <jstultz@google.com>, Thomas Gleixner <tglx@linutronix.de>, Eric Dumazet <edumazet@google.com>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, Arjan van de Ven <arjan@infradead.org>, "Paul E . McKenney" <paulmck@kernel.org>, Frederic Weisbecker <frederic@kernel.org>, Rik van Riel <riel@surriel.com>, Steven Rostedt <rostedt@goodmis.org>, Sebastian Siewior <bigeasy@linutronix.de>, Giovanni Gherdovich <ggherdovich@suse.cz>, Lukasz Luba <lukasz.luba@arm.com>, "Gautham R . Shenoy" <gautham.shenoy@amd.com>, Srinivas Pandruvada <srinivas.pandruvada@intel.com>, K Prateek Nayak <kprateek.nayak@amd.com>, Anna-Maria Behnsen <anna-maria@linutronix.de> Subject: [PATCH v9 17/32] timers: Introduce add_timer() variants which modify timer flags Date: Fri, 1 Dec 2023 10:26:39 +0100 Message-Id: <20231201092654.34614-18-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:28:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784071220017540179 X-GMAIL-MSGID: 1784071220017540179 |
Series |
timers: Move from a push remote at enqueue to a pull at expiry model
|
|
Commit Message
Anna-Maria Behnsen
Dec. 1, 2023, 9:26 a.m. UTC
Timer might be used as pinned timer (using add_timer_on()) and later on as
non pinned timers using add_timer(). When the NOHZ timer pull at expiry
model is in place, TIMER_PINNED flag is required to be used whenever a
timer needs to expire on a dedicated CPU. Flag must no be set, if
expiration on a dedicated CPU is not required.
add_timer_on()'s behavior will be changed during the preparation patches
for the NOHZ timer pull at expiry model to unconditionally set TIMER_PINNED
flag. To be able to reset/set the flag when queueing a timer, two variants
of add_timer() are introduced.
This is a preparatory patch and has no functional change.
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
v9: Update documentation to match kernel-doc style (missing brackets after
function names)
New in v6
---
include/linux/timer.h | 2 ++
kernel/time/timer.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
Comments
On 2023-12-01 10:26:39 [+0100], Anna-Maria Behnsen wrote: > Timer might be used as pinned timer (using add_timer_on()) and later on as > non pinned timers using add_timer(). When the NOHZ timer pull at expiry > model is in place, TIMER_PINNED flag is required to be used whenever a > timer needs to expire on a dedicated CPU. Flag must no be set, if > expiration on a dedicated CPU is not required. Slightly reworded. | A timer might be used as a pinned timer (using add_timer_on()) and later | on as non-pinned timer using add_timer(). When the "NOHZ timer pull at | expiry model" is in place, the TIMER_PINNED flag is required to be used | whenever a timer needs to expire on a dedicated CPU. Otherwise the flag | must not be set if expiration on a dedicated CPU is not required. > add_timer_on()'s behavior will be changed during the preparation patches > for the NOHZ timer pull at expiry model to unconditionally set TIMER_PINNED > flag. To be able to reset/set the flag when queueing a timer, two variants > of add_timer() are introduced. and here. | add_timer_on()'s behavior will be changed during the preparation patches | for the "NOHZ timer pull at expiry model" to unconditionally set | TIMER_PINNED flag. To be able to clear/ set the flag when queueing a | timer, two variants of add_timer() are introduced. I let you be judge of this. Sebastian
Sebastian Siewior <bigeasy@linutronix.de> writes: > On 2023-12-01 10:26:39 [+0100], Anna-Maria Behnsen wrote: >> Timer might be used as pinned timer (using add_timer_on()) and later on as >> non pinned timers using add_timer(). When the NOHZ timer pull at expiry >> model is in place, TIMER_PINNED flag is required to be used whenever a >> timer needs to expire on a dedicated CPU. Flag must no be set, if >> expiration on a dedicated CPU is not required. > > Slightly reworded. > > | A timer might be used as a pinned timer (using add_timer_on()) and later > | on as non-pinned timer using add_timer(). When the "NOHZ timer pull at > | expiry model" is in place, the TIMER_PINNED flag is required to be used > | whenever a timer needs to expire on a dedicated CPU. Otherwise the flag > | must not be set if expiration on a dedicated CPU is not required. > >> add_timer_on()'s behavior will be changed during the preparation patches >> for the NOHZ timer pull at expiry model to unconditionally set TIMER_PINNED >> flag. To be able to reset/set the flag when queueing a timer, two variants >> of add_timer() are introduced. > > and here. > > | add_timer_on()'s behavior will be changed during the preparation patches > | for the "NOHZ timer pull at expiry model" to unconditionally set > | TIMER_PINNED flag. To be able to clear/ set the flag when queueing a > | timer, two variants of add_timer() are introduced. > > I let you be judge of this. I will take your reworded version. Thanks, Anna-Maria
diff --git a/include/linux/timer.h b/include/linux/timer.h index 26a545bb0153..404bb31a95c7 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -179,6 +179,8 @@ extern int timer_reduce(struct timer_list *timer, unsigned long expires); #define NEXT_TIMER_MAX_DELTA ((1UL << 30) - 1) extern void add_timer(struct timer_list *timer); +extern void add_timer_local(struct timer_list *timer); +extern void add_timer_global(struct timer_list *timer); extern int try_to_del_timer_sync(struct timer_list *timer); extern int timer_delete_sync(struct timer_list *timer); diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 177bcde8a2c0..0ce0e6b25482 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1245,6 +1245,40 @@ void add_timer(struct timer_list *timer) } EXPORT_SYMBOL(add_timer); +/** + * add_timer_local() - Start a timer on the local CPU + * @timer: The timer to be started + * + * Same as add_timer() except that the timer flag TIMER_PINNED is set. + * + * See add_timer() for further details. + */ +void add_timer_local(struct timer_list *timer) +{ + if (WARN_ON_ONCE(timer_pending(timer))) + return; + timer->flags |= TIMER_PINNED; + __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); +} +EXPORT_SYMBOL(add_timer_local); + +/** + * add_timer_global() - Start a timer without TIMER_PINNED flag set + * @timer: The timer to be started + * + * Same as add_timer() except that the timer flag TIMER_PINNED is unset. + * + * See add_timer() for further details. + */ +void add_timer_global(struct timer_list *timer) +{ + if (WARN_ON_ONCE(timer_pending(timer))) + return; + timer->flags &= ~TIMER_PINNED; + __mod_timer(timer, timer->expires, MOD_TIMER_NOTPENDING); +} +EXPORT_SYMBOL(add_timer_global); + /** * add_timer_on - Start a timer on a particular CPU * @timer: The timer to be started