From patchwork Wed Oct 4 12:34:42 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: 148261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98622vqb; Wed, 4 Oct 2023 05:36:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAgxGg7WnLtcVx7Uvhb5zVHZL9AYHhnnWNi0HPTcDZ/mmHjNBmRJldHmk4Ir9rE2JJ5AbY X-Received: by 2002:a17:902:e74e:b0:1bc:3908:14d with SMTP id p14-20020a170902e74e00b001bc3908014dmr9566772plf.2.1696422999772; Wed, 04 Oct 2023 05:36:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696422999; cv=none; d=google.com; s=arc-20160816; b=lDzh2azn2gWrt+6u1brbh285MfSIxTb1KzWheYgekoGXe/s4qxBJqVc2sUd28RVA3n NDFVrIgZd5x1ivpGWpnO51SMWQdIZK97h0UpXuEuu+Yb75Jhh9WcNXAHraufSk67HExa EDi1iVUptJN8sMj4hEHKw/YIQBUzFIYSVX2rSHVcKlI3ifiv4zpodD7DVt30JuDNePZH rUDYQVY/GSSMsVyM8fBe81s42kCnadGov9mHZ0i7pLpaiRN2Gr3K0sHfT9P+6TsmgYYy qmaThsuem3Uw+fo4+dFcPKU6M2wFj3cSko+p1lOhzGmGKDobBnvfsGsxVeeyhvi8xCgS Z9dw== 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=9vhsM+uCD+bRTV7auZs4wdMq75JFKQoeaDSLzvQWIuw=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=pp8m4VM4670kX2ZqbHpl1Zr1nTe4B//hoQe7FUo41VHuIsVjABnSopaqqhGnZZUb5k +Y565cCp+uWe0bbwK+GrHo3ZUo0C+yPanJAH4EljFnR4jbQa7qzNuqR9qiLDtLoSRCia +S9aa/kfWA+je94WiZassod32zwMsAP9RYwGDtFrfgGB3B4pHHpNxW0gXYFvZ04eHQCl /h7tOK3mCQ/jn2Wac2h/RDPEf0JGIKeRK5s8w/5p9scNIPEdBmvEN7UNQl0pBdZIWlXh RsIe2PR4NV3HXaaLj3UhqmCKI1PzoxxPu1MLDZJ3Dy3XRiV7Tfowd4hRrOWOd+/Jk0jz J2bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AZrpuIUB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d14-20020a170902cece00b001c75866c987si3713358plg.584.2023.10.04.05.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AZrpuIUB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 4A6638213F20; Wed, 4 Oct 2023 05:36:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242353AbjJDMgC (ORCPT + 18 others); Wed, 4 Oct 2023 08:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242398AbjJDMfn (ORCPT ); Wed, 4 Oct 2023 08:35:43 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC939E3 for ; Wed, 4 Oct 2023 05:35:34 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422933; 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=9vhsM+uCD+bRTV7auZs4wdMq75JFKQoeaDSLzvQWIuw=; b=AZrpuIUBupEwhI/vllltdbYxH4NadgULzlfSmoFHxwCreO6WBp4lvLieme4ivLCZ4s9eKz jMv/s3vINkZmsWe6iGANmXnwh8+jqwrcyvbFNtkXRgrmI+U4OluF54NPcQhX+IM0/C4guD WZpGDczq3Xn1JLyxcAzHWlFKL9Rg3NQAISXN0Kr3/Lsb+rFkMMdZVCq8uTHoqPMcswjf26 ZR0ntNmKWnt3MH3ym/xDiSCSuHSvSa0Ghm8I5kiEn2f/HlRK0cVNGhO7kfHSLHuqDHdvo9 jZKrHU+wETRoLbfZ+8e/YnDiYNsk/pfQzV24S3G/OHp/oTNeaEHS+QyDJPtezQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422933; 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=9vhsM+uCD+bRTV7auZs4wdMq75JFKQoeaDSLzvQWIuw=; b=aTFajETp4frynwLO5rtXBAmWDbop9zYbQLoj4X5p5R3VeHN0d6zgHdqNtmphS9NNxh08SO c1dWsIdJFU315qDA== 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 13/25] timer: add_timer_on(): Make sure TIMER_PINNED flag is set Date: Wed, 4 Oct 2023 14:34:42 +0200 Message-Id: <20231004123454.15691-14-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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:36:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828443628535798 X-GMAIL-MSGID: 1778828443628535798 When adding a timer to the timer wheel using add_timer_on(), it is an implicitly pinned timer. With the timer pull at expiry time model in place, TIMER_PINNED flag is required to make sure timers end up in proper base. Add TIMER_PINNED flag unconditionally when add_timer_on() is executed. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 3172b8094097..853a8ee48ffc 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1284,7 +1284,10 @@ EXPORT_SYMBOL(add_timer_global); * @timer: The timer to be started * @cpu: The CPU to start it on * - * Same as add_timer() except that it starts the timer on the given CPU. + * Same as add_timer() except that it starts the timer on the given CPU and + * the TIMER_PINNED flag is set. When timer shouldn't be a pinned timer in + * the next round, add_timer_global() should be used instead as it unsets + * the TIMER_PINNED flag. * * See add_timer() for further details. */ @@ -1298,6 +1301,9 @@ void add_timer_on(struct timer_list *timer, int cpu) if (WARN_ON_ONCE(timer_pending(timer))) return; + /* Make sure timer flags have TIMER_PINNED flag set */ + timer->flags |= TIMER_PINNED; + new_base = get_timer_cpu_base(timer->flags, cpu); /*