From patchwork Tue Oct 25 13:58:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 10808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1026077wru; Tue, 25 Oct 2022 07:05:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM56+2Fr6uHn2B+Vd6aLC6cZ91k3ZAzTeCGnYPvAbYlwNxPrvAwoqX02ZQbSTdI38JJb+0jg X-Received: by 2002:a17:903:1d1:b0:17f:6494:f8c3 with SMTP id e17-20020a17090301d100b0017f6494f8c3mr38518604plh.157.1666706700561; Tue, 25 Oct 2022 07:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666706700; cv=none; d=google.com; s=arc-20160816; b=m1fcDGMG7rffj3AnKkTaxyVtsnGmLqe2SPtwLLu5PaZxAnTpsvXaPIrpGnto/rsBvf gE747ztd5ohQ6HKz4XKgtTjiwFP7ap/2WpU49N77xb7v6T8IhqXXR6qDCTtQ71Z1XwWP rBjn5qSRoQ+xnhgcr9kAPouGk/LuK/Mn+rAIlB0rX90SCIOhk+75D0XIkr/TA82Ojd9C wb1PpX6wP2Y1pzHB9OeG9snIOEKaxhiAspszXZqip7PE7G08u8L0GCXi+IWJT7evHawJ FlnukLlP/cbwnx8ghSCw+sEeBfpBHsWVMLibEnaWr6hUkl2j5zJoKwvbyPofm67KwkKJ cuYg== 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=t38ZOSk7RADUS9yQPx+jhxDPVyx+Ww7vTN6ZsN90lKg=; b=lKkytLj5m0MWQVqN0vSv9fXr4StV4cST2IH5Oc6HDfkoLihTS9Wm3WQlnKNJwPbMiJ znSgeDy/odnTEf7RA70wgT2BdqHIgbPRXFFQKppQUaT4yqVwyMWvYwmWHNBjMi4Hurds j8DmtMSS2wAmvgKmLvq6MxHGrahPNIt4xS2pKg2sZQi3CIhWT916ybHiWjMkwZO3pmt9 EZAc1519x4VyVP2+9/7EPi9gH/W/xA8vf/0vFevH+2lkzo0eseuaZyp2eDXf9+n42+xI qr5CmXvYRMW+FrdP8du7e/RaGRNN81aMw82mOUtmjQUJyiscNuJWhLBtNZnEDEFQTHkH E5jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bEwlhGzp; dkim=neutral (no key) header.i=@linutronix.de header.b=WydopO46; 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 m7-20020a656a07000000b00438e839828bsi3461125pgu.72.2022.10.25.07.04.39; Tue, 25 Oct 2022 07:05:00 -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=bEwlhGzp; dkim=neutral (no key) header.i=@linutronix.de header.b=WydopO46; 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 S232786AbiJYOBD (ORCPT + 99 others); Tue, 25 Oct 2022 10:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232169AbiJYN7h (ORCPT ); Tue, 25 Oct 2022 09:59:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C446FAC9; Tue, 25 Oct 2022 06:59:31 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666706370; 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=t38ZOSk7RADUS9yQPx+jhxDPVyx+Ww7vTN6ZsN90lKg=; b=bEwlhGzpXpX8hMG8IqtPZmhlQRTQikKxqNs+gbQgfv3WFD96OO3tUpQT4EGa3g/BzQnubQ YJSxR22rP/7t7RYGTs+tiAigsONu+jLzODJiGTM/3aFyR1hciqB+lBSGwaCnd2Th7JbGQq uwSOnET8vkJWh2fJdQx7Pue1BuPsppC5/Vnq2Kf4G1QWNwkR7MP7bc6yZ3yGh4vYfD9AGW NcMkYkdYIzu/1fLOmu4BzSl8JZJExpqx06XXG7SZsxGs6MycZ4DWUgN6eLrtxp1JzRVe61 FhrUh86UP3a4VJCA0facxuPBjkZB5p26oaplpC/jxnH/cB37pSiJfUs6KLYmgQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666706370; 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=t38ZOSk7RADUS9yQPx+jhxDPVyx+Ww7vTN6ZsN90lKg=; b=WydopO46wwu45sP+yRfKw5ZwrGNEVisF1hJAUAO3vVDu9Yj/PohrKCIGU8fAEgVTpFn5D9 G2QbL4hSwWjxuBDg== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Eric Dumazet , Thomas Gleixner , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Arjan van de Ven , "Paul E. McKenney" , Frederic Weisbecker , Rik van Riel , Anna-Maria Behnsen Subject: [PATCH v3 16/17] add_timer_on(): Make sure callers have TIMER_PINNED flag Date: Tue, 25 Oct 2022 15:58:49 +0200 Message-Id: <20221025135850.51044-17-anna-maria@linutronix.de> In-Reply-To: <20221025135850.51044-1-anna-maria@linutronix.de> References: <20221025135850.51044-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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747668645328186052?= X-GMAIL-MSGID: =?utf-8?q?1747668645328186052?= The hierachical timer pull model at expiry time is now in place. Timers which should expire on a dedicated CPU needs the TIMER_PINNED flag. Otherwise they will be queued on the dedicated CPU but in global timer base and those timers could also expire on other CPUs. Only timers with TIMER_PINNED flag will end up in local timer base Therefore add the missing TIMER_PINNED flag for those who use add_timer_on() without the flag. Signed-off-by: Anna-Maria Behnsen --- arch/x86/kernel/tsc_sync.c | 3 ++- kernel/time/clocksource.c | 2 +- kernel/workqueue.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c index 9452dc9664b5..eab827288e0f 100644 --- a/arch/x86/kernel/tsc_sync.c +++ b/arch/x86/kernel/tsc_sync.c @@ -110,7 +110,8 @@ static int __init start_sync_check_timer(void) if (!cpu_feature_enabled(X86_FEATURE_TSC_ADJUST) || tsc_clocksource_reliable) return 0; - timer_setup(&tsc_sync_check_timer, tsc_sync_check_timer_fn, 0); + timer_setup(&tsc_sync_check_timer, tsc_sync_check_timer_fn, + TIMER_PINNED); tsc_sync_check_timer.expires = jiffies + SYNC_CHECK_INTERVAL; add_timer(&tsc_sync_check_timer); diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 8058bec87ace..f8c310e62758 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -523,7 +523,7 @@ static inline void clocksource_start_watchdog(void) { if (watchdog_running || !watchdog || list_empty(&watchdog_list)) return; - timer_setup(&watchdog_timer, clocksource_watchdog, 0); + timer_setup(&watchdog_timer, clocksource_watchdog, TIMER_PINNED); watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL; add_timer_on(&watchdog_timer, cpumask_first(cpu_online_mask)); watchdog_running = 1; diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 7cd5f5e7e0a1..a0f7bf7be6f2 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1670,10 +1670,13 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq, dwork->cpu = cpu; timer->expires = jiffies + delay; - if (unlikely(cpu != WORK_CPU_UNBOUND)) + if (unlikely(cpu != WORK_CPU_UNBOUND)) { + timer->flags |= TIMER_PINNED; add_timer_on(timer, cpu); - else + } else { + timer->flags &= ~TIMER_PINNED; add_timer(timer); + } } /**