Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2573990rdb; Wed, 4 Oct 2023 05:37:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEA6J3VOSdBB6kjrp4YCik645hai+UWDUpaioet853BG0XEBoRdNboazXtf2Y/hFBcHLawJ X-Received: by 2002:a17:902:d382:b0:1c1:fe87:f550 with SMTP id e2-20020a170902d38200b001c1fe87f550mr2236866pld.7.1696423057646; Wed, 04 Oct 2023 05:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423057; cv=none; d=google.com; s=arc-20160816; b=S8T3z2+T9F4b+ytC4uhoP1zYAZ/GbLpdxgY0ltI2vjWO6c5dZCfFPNHuO2sBlkcHHp yjiOS1bkS6Apl1LMmdOd6lwsbF6XaLfyIkG+UFP7z8HXtGlwf+ez//1PJGsX+Kh27+tL r1lT4JPQMuuj3RdD47njOXy+Kc4l/FZqPjdCM4p0jEbOiJWSV1mYmouX4ZlUtTyOru8c ODWA+DYfK1r5KbnkPUpZQeq8NDsLf7ZLzUEAZnB1K63TlA1ct0sYAkNthpcEHo2La6Ti jY0yGMUCrDWS+EcK3zIGxqNTJxbxPY0sAEOwYe2hjO6H6/ZP0PM6m5QKBHTtx/eJCa8Q Y1cw== 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h5-20020a170902680500b001bf2437b876si3441836plk.305.2023.10.04.05.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; 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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id ADA36819E4F3; Wed, 4 Oct 2023 05:37:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242622AbjJDMga (ORCPT + 99 others); Wed, 4 Oct 2023 08:36:30 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:37:25 -0700 (PDT) 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 -- 2.39.2