Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp904756rdb; Fri, 1 Dec 2023 01:28:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgWmR7LkW3M7EuWoZnbLZPX4Hu7SJ/8al1xGXIres/HcU1evyosEYVNmZX6GLyVo2HXBDc X-Received: by 2002:a05:6870:468e:b0:1fa:fa0a:bb40 with SMTP id a14-20020a056870468e00b001fafa0abb40mr49821oap.18.1701422918629; Fri, 01 Dec 2023 01:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422918; cv=none; d=google.com; s=arc-20160816; b=rPVcoV4XJFrnCTygm3UxXuTGn6qjLYqqEg4elo6l3NxkktqLf9hhRnqOvi++IP4x81 SjwASavglmhLYw2oGZt9p76brJRolOZ0KBiwb9HOcOYtQ07+obxte6LNz92BhdrSC3e8 k4rrcUiWw1Vp7uWmJOw9PIrAns4lIwzbq2H/aIiNvP/I+NRVTed/WNr/KsB5DV+qdv22 mi8s66R7Cv9jXmsuKrvD4aGrGvm24FN8b6wEPTVQ+v/CbsiAq6tMBf245p/g1Vex6W4U Xpsl5VU+xxB8yi6jZTN40UcsxB1YLfpEwig7H+JaywstdFyNhpdOfBHQJ2wB+fYumq9P kNRg== 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 header.s=2020e header.b=gEaTy8k+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id cm15-20020a056a020a0f00b005ac9ae1aaa6si3116634pgb.334.2023.12.01.01.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:28:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; 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 header.s=2020e header.b=gEaTy8k+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 D867080BD4CB; Fri, 1 Dec 2023 01:28:27 -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 + 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 ); 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 ; Fri, 1 Dec 2023 01:27:19 -0800 (PST) From: Anna-Maria Behnsen 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 , 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 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=unavailable 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: 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:28 -0800 (PST) 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 --- 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(+) 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 -- 2.39.2