From patchwork Wed May 24 07:06:17 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: 98346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2654048vqo; Wed, 24 May 2023 00:17:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5RvL+eTW+7WJOtLOdSRWUVnkyGNMabzEIOtKKxqDAHHKv7Ewg90x9+wdr1LMj7N51hnRuZ X-Received: by 2002:a05:6a20:258c:b0:10c:89cc:bc5f with SMTP id k12-20020a056a20258c00b0010c89ccbc5fmr4730320pzd.20.1684912650235; Wed, 24 May 2023 00:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684912650; cv=none; d=google.com; s=arc-20160816; b=rKyBpp+vR5snhxQlPV/prUIjVp4PoNIahLJLZb/QEpk5dgJgtJf0GqYxkcKt2HpWao VsEDhNLAEXqfspyNy8NtqMb3RNcBUyT2gTDh/E5xXEHx1qzkFhMnru4Rvn0i3KopQ0Dm g1BuojffLXr0YHOCbS2wYqDM/z0KQ6jiqY/+E6IWXMSWN2nnp2jMurc3GFc2K8AGds+S xcrM8RNwbeLvBPkbTtXAAHhhL+wXO3unH2gOq2EVVdA3rBnv9PV2GUWC8dgsbegAc+g9 55yh4T6sWPiUFyYQIlit+Sdo04SKBX+suyr7ZX539bov415ey/n6wjW83L0+yYC6pjeE MyPw== 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=lT6/GGqloCM8AGirZHb7HkPsMCoi/5vNo/Me8IGb/1s=; b=IjJRNUe+vAjN/a2WFazWKCBcJYXemaEZSomtJOiXQIky4ZBAzLn/jJ2IgjPofvDFxD fZwdIK+rsWavsLD9GhxR0HVdbL0ehVX4rcq0kprgX23NunCIEpdvSyk4RicFnbxWBnf0 w7ZtyCNB8itAUkZaNr7mu6pX1O3yrVci66wHyXeogDlNFxv8RR6joQp7Cu74zYQLTS8A tf/dQrvmhP1aAl6aK6CYSbWQBq+qXZ88Ut2V8XzxI9gjbv/wyu5hUejFfvMB8sGlO2wS wH0wKVXqvBVqv+fCG8m9SX3UW5KZclu/HHAieH9Acdo49Ab579n2PQ3s2sjsB7bvQH0M zxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eDOksZ3M; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020aa79f44000000b006281ec442absi61846pfr.309.2023.05.24.00.17.17; Wed, 24 May 2023 00:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eDOksZ3M; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239903AbjEXHHh (ORCPT + 99 others); Wed, 24 May 2023 03:07:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239807AbjEXHHF (ORCPT ); Wed, 24 May 2023 03:07:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A717597 for ; Wed, 24 May 2023 00:07:01 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912020; 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=lT6/GGqloCM8AGirZHb7HkPsMCoi/5vNo/Me8IGb/1s=; b=eDOksZ3MxO3qy4i6Bs04pCvfZX2q4ptoyUl8Gz9gFNZZ62vh9WtXJ8X/Gwz3WGaoJI1T0+ HxRoMNjSX9N28K3ON3+VFKnTlTVLQHXOyo0WCYhiqAwhFYDt07vDucYIUREQ6R5/L9eaZD hJrojJXN0AiogwBML0Z6TJMUZLfblqsmGlGSt7JxsIT8DTS4BB00hEVHniXIDTUWtZB2SQ 0PHEJlfhLLOd7D5QHqrRrK5Q/xs+piZGI6AK4rQkFzTcH0Al1IU35AQHSZsCZrApPVfPNp ZIX1EJrj/BRqoTiD1Ycru7o0IyAyGkrIjwdTfDSlEtP1rQjiaCAyT6Xl3StEpw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912020; 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=lT6/GGqloCM8AGirZHb7HkPsMCoi/5vNo/Me8IGb/1s=; b=rpUktC55F0DExnhjdnVJx9htvbxzw/S5B8SGXzwmH03itM5CtNS4u5pdK8Skp2dwzk6wOa c91OzWG/HZ3IZlDQ== 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" , Anna-Maria Behnsen Subject: [PATCH v7 09/21] timer: add_timer_on(): Make sure TIMER_PINNED flag is set Date: Wed, 24 May 2023 09:06:17 +0200 Message-Id: <20230524070629.6377-10-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-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,T_SCC_BODY_TEXT_LINE 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766758966932385191?= X-GMAIL-MSGID: =?utf-8?q?1766758966932385191?= 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 ab9a8bb11a8a..b7599216d183 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1281,7 +1281,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. */ @@ -1295,6 +1298,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); /*