From patchwork Wed Oct 4 12:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 148267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98706vqb; Wed, 4 Oct 2023 05:36:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2oRfmz10NXB3Julqt4baKOqQlqIdijD/Mxda0V1DoznarPTBfrAw0Z0fbPTD20l1C2cIT X-Received: by 2002:a05:6a21:a101:b0:164:e94b:d3ad with SMTP id aq1-20020a056a21a10100b00164e94bd3admr1830100pzc.28.1696423006781; Wed, 04 Oct 2023 05:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423006; cv=none; d=google.com; s=arc-20160816; b=F+C0Jb/8nRtCIukkovfZR6q1xr3bSnAsa1exWqDG9BpEPV7okKNjLPk64yh67KgXlL 6kgQiprZI+TJJ+jZBNa/akcejkhTbsDofes7w+f0BnPEOSDSKohO/wtpx2OupzAAGqDF bGXHsifta9vuOfTQ+HgvcZRfFBuhC9nNUOw/1RE3ndY28wbP6Of0U/syZWQ2Qcm2xtHc DyzfiiH//+O29IdxbmkRcYAEEOQ49yMw0YaztPWesA9Sxd0SfSA8zB4dm2S7oscq5943 btgL/BubvVnWgqhov2ydE0JiP7xUhVzRdM4567KCoEnAxn77UfCPFD/3Q1teLjGRvg0n VLeA== 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=R6p91zzmcTgFtBegVAgz86f9rPOZl2ESGLLtaCGNKmE=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=bMtJnRabRXSOPwfZ9BTDHMizbBKQy2H4XekIntnFMskzfP3vV/6dyHStNg2prWFojI wYFzwTW6DrBTsFRHnQ4ko+xWCLww1Bw4YeVrOxlciCiBxREuyYngeRVkbtJCGzkq7o72 up2/tz8zxe5TEakNK2WJ0Olh+W1SCrSuWyn6anhCUiD+ZUvtXNbY/F8LgVmYp7Niq3NO 0vTgCiKnnp9FUFChZbhL9COq0M2og3GaQFwfd5zz7gyTA/0xV7gZEBFoOJtLE7+86lqf eczuAY0kNefu+jjVzgvLTouTwNdyL1sW4Q+0pL0amW0j0CJoJtoFaXHxJ9ascpuoq0tJ hYOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tD5J+oia; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p4HI0Tmi; 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 bv130-20020a632e88000000b00577723d24b0si3475339pgb.46.2023.10.04.05.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:46 -0700 (PDT) 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=tD5J+oia; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=p4HI0Tmi; 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 701A2834822A; Wed, 4 Oct 2023 05:36:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242628AbjJDMgb (ORCPT + 18 others); Wed, 4 Oct 2023 08:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242393AbjJDMfn (ORCPT ); Wed, 4 Oct 2023 08:35:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FB6D9 for ; Wed, 4 Oct 2023 05:35:33 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422932; 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=R6p91zzmcTgFtBegVAgz86f9rPOZl2ESGLLtaCGNKmE=; b=tD5J+oiaWrqrU1ELhMzwRcDVY01AqSqRWzluw0BE0LA9bqRLkpt/mTPfu/6X5qYIQm7/6r azGNPmxrTGX7M2KTsSaEQRGMORPVKnsrDvvFjl+6VtmnFZkZxfhv0EHg11C43a9GDqIK8v hObFc6IZs5xltBwsQNQqQdhb+2tQyhVnb2M8nZ9EOzfOPwZT9WKv38d4wGpGPnyYvdfBa4 haJBSp9CEa4z2BOe6Gn/QavcG2GTsHfKTbAklvgqN2PhubiqwOBTL4eEuIe42UwiNbHReY QIK0UzjalspQk7MYaH2vRt2OIs8Hy+joCll0qaReQlsAc9J9mxb6NkTJmI3QmA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422932; 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=R6p91zzmcTgFtBegVAgz86f9rPOZl2ESGLLtaCGNKmE=; b=p4HI0TmibWqsmsZsVt86GITKCM8Cm5JkQzQKKPtx1yqL/g4yCL49TSeheoAImYhl51+X6o DFLUUenUA6uxCwAw== 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 v8 11/25] timers: Introduce add_timer() variants which modify timer flags Date: Wed, 4 Oct 2023 14:34:40 +0200 Message-Id: <20231004123454.15691-12-anna-maria@linutronix.de> In-Reply-To: <20231004123454.15691-1-anna-maria@linutronix.de> References: <20231004123454.15691-1-anna-maria@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Wed, 04 Oct 2023 05:36:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828450978212787 X-GMAIL-MSGID: 1778828450978212787 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 --- 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 9162f275819a..6f96661480dd 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -180,6 +180,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 8518f7aa7319..3172b8094097 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