Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp482669rdb; Thu, 22 Feb 2024 09:28:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXUGuF35BesDEK89PTgeieLYV4EuLbOIFKfTFJqhA85zGqYgyhIllkZiDkcC1obEYXppd5pFViu2qloKxc93m+fFb6vME9ClpsPDY+fJw== X-Google-Smtp-Source: AGHT+IFe00I4Ln8mckM7+/67iWA2QzwNk0QPb3nkuxoPgf0hlUnRBcZZobFKTmUvhtYhBivvxB8R X-Received: by 2002:a62:aa0c:0:b0:6e4:5a6c:957a with SMTP id e12-20020a62aa0c000000b006e45a6c957amr12049693pff.12.1708622919986; Thu, 22 Feb 2024 09:28:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622919; cv=pass; d=google.com; s=arc-20160816; b=FsdtzfrXCrZJQ8zD1cdzTubnDzqUd1+mpxCy3vohwW6gi4dC9fJM1o9A9xH7avNZP7 2OJBTjdrXZjd7FahwWWPU4vwwD/A/wrO73/eEv5VlH+YPZszfEQk3HPyECTSA0axocIi TP2KP56J41h4VNt4VV/tUigDgUrgQQiLjpaKrZiybHLjbrJiFdFgwaQXFMtP9W1VQOvL ETo2rL3xUukSTlj74qppLsCG0Vkj5vN8P0KdF4IswFFIjNYDNe9fM4SXkGtAaKdzrCrp ROzj5Wr7kJH3c6S1CgK5gfCpnHb6zeOW3XkM4aJpjojkkld6JmL2pze3uwsmiAyAaa6Y xqpw== 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=2RK0qYO9+yNFcwFD0u5TmenVmJgzi25sDpsK8zBYC7g=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=pzhBgWFxUp5D2tsCcnhDJTOGLuViO8JMOICNDeKGnaJzIxXLVCYH/A/9vo17gO5YI7 X7AQ6DAG07ILKshomzFI6/Ae61SvPV0eryWcR2nxVHDqwYdVkijBnyxP3KRmCUA5oT2H Tp/m5+78sUmfIU5WdfppSIuo+naPI7tyzH45IYdyRl/i6J9KSe6OG7BqUaurmZ6/0PoA ewn2POMLcE5s4qMXjZ2Ckll06Dk9HWBNSz54QRcw0X3Pskh8en1gXR2kUO9GiUL+rzX1 MWP3q3TIc51F1h5X1imGa95l2lzINk3t9EEYwo0988RdCj5ejxhFXktm7vIi6tXrUx8U f0AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e4RWX3wf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-76947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id cw11-20020a056a00450b00b006e47dac6b71si5384365pfb.299.2024.02.22.09.28.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:28:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e4RWX3wf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-76947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76947-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 48A6BB212DF for ; Thu, 22 Feb 2024 17:14:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD2CB159597; Thu, 22 Feb 2024 17:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="e4RWX3wf"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wq3LoQ+J" 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 40447154437; Thu, 22 Feb 2024 17:12:16 +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=1708621939; cv=none; b=jLkwg5uMQQFFTvTs+FLY6KU7mQQF7/tw2eltam2VdDaHxx95/dTjGDZOtm4e0L1KTOIrUxqAJTY0e39aOU6648thcIBANBjUiPvj9yoOHU/eIuSGxeyS13xwGX0kLN3BP5PaGSF0Map/AlvmyUmQGoqezIiLbn/szwaDLBJkids= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621939; c=relaxed/simple; bh=KyObLGDK1YnMUXhpsfB4N2YAemwv6qOfMW2eFfWrzTA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=EukPEFQ6HZRUydlrqVwdz0LaJBPoSyb+dhid5XRYEvsMOTvsB0gwTzGLC9Pv+tIzZZp2WYXef1EpnPTYpcTHB+dQinr6RPygpGqpkuGiCYjTSIJsJ3+BTmDtD4/YpUa9GPKFL+847UUmzHNqPsC0GOtMjfu0ZK0lF7gkOOHU7Ls= 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=e4RWX3wf; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wq3LoQ+J; 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:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708621935; 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=2RK0qYO9+yNFcwFD0u5TmenVmJgzi25sDpsK8zBYC7g=; b=e4RWX3wff2Inaxj2eVwC+XL0hUbXjJberl0i9k8jBV0rtK2PfWceX8FwpyjKio7NPOaQh9 AcQpchFKS3+COtSzrdGVlJw/2Vl5kzz182Ahac7MtRmuOPSXEBP6xLMxv0YqrM3Q9BImXQ ojIhXbXbDYxWHRZjd00Xcl4ipC3Kd/s6QlQn3jI7rEnu6tWQTaO3+50+Q2On4rwyXv1YX8 xqQG5xCpUOCLsa/RWcbYbfH2Tk7ubDHizRwKR0Fa479nMg7ug0iu7Hky5TX7X6jra7Fbir uKvdnJfxsVO1BJ0By77YX1JFVbu++lVhUPqrGVkm6zh1yCbCFNjFGnoQge7epA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708621935; 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=2RK0qYO9+yNFcwFD0u5TmenVmJgzi25sDpsK8zBYC7g=; b=wq3LoQ+JDDfmhZuomUmbJWpOSdh2z0Z/aKVB/ykdbnvMVb1xSSs+NbZHWn3b0sL28ndUcS rLw29nFqFiMjv4CA== 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: Introduce add_timer() variants which modify timer flags Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240221090548.36600-6-anna-maria@linutronix.de> References: <20240221090548.36600-6-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: <170862193464.398.9124526357138582797.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the timers/core branch of tip: Commit-ID: 8e7e247f64a1e0fee430aba28d9108f7598eb237 Gitweb: https://git.kernel.org/tip/8e7e247f64a1e0fee430aba28d9108f7598eb237 Author: Anna-Maria Behnsen AuthorDate: Wed, 21 Feb 2024 10:05:33 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 22 Feb 2024 17:52:30 +01:00 timers: Introduce add_timer() variants which modify timer flags 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 the TIMER_PINNED flag. To be able to clear/ set the flag when queueing a timer, two variants of add_timer() are introduced. This is a preparatory step and has no functional change. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20240221090548.36600-6-anna-maria@linutronix.de --- 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 f18a2f1..2be8be6 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h @@ -165,6 +165,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 74cfe21..bef8cb8 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1291,6 +1291,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 * @cpu: The CPU to start it on