From patchwork Tue Sep 12 10:44:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 138132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp359470vqx; Tue, 12 Sep 2023 05:10:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTZJ2ezn6SKNfHisW0+g3XjDRPTyivtIdYE5qbQH4s5DtEOwUVOQVyHoC3p0USmcWNxqZP X-Received: by 2002:a05:6a21:99a9:b0:14c:a53c:498e with SMTP id ve41-20020a056a2199a900b0014ca53c498emr12477458pzb.42.1694520654786; Tue, 12 Sep 2023 05:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694520654; cv=none; d=google.com; s=arc-20160816; b=TRbInkzTmsetR+viZ+XkN/iHAaUwcS/nza04GY8ZKMK0f0aSFz8YZ11DXbE/FqE5Vq MbyPkF6c6xzTIRTul7J4vlnsZi/m0v1c3TJ2YbCXLBhlsCb0+DipAnOQ85SKqVuhjHAt 6jk+RbKz+Oe+rkERAQONXb7Kog0uvg+F4Ovp6uHynVzhN4iCoU+vN5LvaUMfDYOFvxjD soihTmnaNXa6md0itMAwAnKvxa03ADJyJkkDOtpocjJPXjT1E9pbpTLgjkA3aHITLlEu w1iWy025hXNZXYBq28Qi2UI1oTGy2BOIHQ4CnP2Td0YlKK71ngxS8A/mC3ySPJ2I11Wa W+Jg== 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:from :dkim-signature; bh=+sNU5btn82inKJegHqCbCVsHN1/5junWteoyMUIaalY=; fh=CGeRqfKKrYaxvvhOGObLHRUUue/LLUSLAzhwrHrEV+s=; b=Y3FE30rcxY8lDMYdz87hWLuyoTZLA5lUWtdMijGbgNTtLwOumvU6Co6E3vliZzXE7G q3AHQ8Y/tBPAOroPTow4d2fXiXk8VF78c7q47gZQD+3Ae+mVxNRFHocoowXUenjstfYZ pVPsr7WFdG+/Vucm5MLCx6dOVUoNBDm5UZCgnawDmmp+UxxE7r1DwbGIHOgzhc+Np2tY Q20khoQXTqdMHjASwr4jC/I1sTWgMYI6ZF3P6w3BGNXNXToAHk/B0I8GO7vXwUxR2wFm cKNj2wiHerbNZH9tmdI5rtYutq78nxwu+PQdg0iSdryMcHsT8/Pn3kFsEB2QPl03rfmu 6c/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KXoO/Z54"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id cm16-20020a056a00339000b0068fe0f08608si1565328pfb.156.2023.09.12.05.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:10:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KXoO/Z54"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 845B380BB3C8; Tue, 12 Sep 2023 03:45:08 -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 S234297AbjILKpB (ORCPT + 37 others); Tue, 12 Sep 2023 06:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234213AbjILKos (ORCPT ); Tue, 12 Sep 2023 06:44:48 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813E31719 for ; Tue, 12 Sep 2023 03:44:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3BD4C433C9; Tue, 12 Sep 2023 10:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515457; bh=DfGb/oQJpcnc2u0v4QarnLBwZAczc4rgBDguNVZFTUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXoO/Z54oTmdIbTn/COSHP50p6mFZ74ZsOEqTt/SgXMpYrv3qZJ+G2IcSoTrR9coG mbmlKCu2Lzzlj/V4fPzzEHS9iYkvDULa0ns+igEzbqmMdjj5klRN073QGxcvOwHWOh I0vcGz3UPmCm0UUXthSuJbWp+cXNm8vMFnspmBTUPCl6GQHy41pDiyICuy3x8vrPEr b7l/WsrfaqHoSq27xeAcCEFiqmqV1tKDUFyZLuGFr/NbAdjcucEXwFzU5+82kBLkpW Cb5b8iENoRh5G5BGFiC1MbN9Luc2fH0P55qGAF4y4BN4LspvGC+Fnln1xAdUii8dcv VG2c5HucFP7lw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com Subject: [PATCH 1/5] tick/nohz: Rename the tick handlers to more self-explanatory names Date: Tue, 12 Sep 2023 12:44:02 +0200 Message-Id: <20230912104406.312185-2-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 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]); Tue, 12 Sep 2023 03:45:08 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776833689891639927 X-GMAIL-MSGID: 1776833689891639927 The current name of the tick handlers don't tell much about what differ between them. Use names that better reflect their role and resolution. Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 87015e9deacc..b66dd0ff1153 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1366,7 +1366,7 @@ void tick_nohz_idle_exit(void) /* * The nohz low res interrupt handler */ -static void tick_nohz_handler(struct clock_event_device *dev) +static void tick_nohz_lowres_handler(struct clock_event_device *dev) { struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched); struct pt_regs *regs = get_irq_regs(); @@ -1412,7 +1412,7 @@ static void tick_nohz_switch_to_nohz(void) if (!tick_nohz_enabled) return; - if (tick_switch_to_oneshot(tick_nohz_handler)) + if (tick_switch_to_oneshot(tick_nohz_lowres_handler)) return; /* @@ -1475,7 +1475,7 @@ void tick_irq_enter(void) * We rearm the timer until we get disabled by the idle code. * Called with interrupts disabled. */ -static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer) +static enum hrtimer_restart tick_nohz_highres_handler(struct hrtimer *timer) { struct tick_sched *ts = container_of(timer, struct tick_sched, sched_timer); @@ -1524,7 +1524,7 @@ void tick_setup_sched_timer(void) * Emulate tick processing via per-CPU hrtimers: */ hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD); - ts->sched_timer.function = tick_sched_timer; + ts->sched_timer.function = tick_nohz_highres_handler; /* Get the next period (per-CPU) */ hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update()); From patchwork Tue Sep 12 10:44:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 138142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp370301vqx; Tue, 12 Sep 2023 05:30:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwBKwiv2s49diUOiJ/Y4bkzyYJPHwoWScaTnrUW0M/YADKiUecJninfiUF+JIHwk93Addd X-Received: by 2002:a05:6a00:1a4a:b0:686:6e90:a99b with SMTP id h10-20020a056a001a4a00b006866e90a99bmr10580823pfv.25.1694521814387; Tue, 12 Sep 2023 05:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694521814; cv=none; d=google.com; s=arc-20160816; b=rXayp9xZEj3cDr2B012x10hWAjJfbZ+OlPP27+YNcCmxyvBLWxxKcpuVoOs8jCfbOd J4uSxCng2AMZGEYJ2FymU+xr3qy/qMSHiBv0AWta/xKVkO71k3TEG7/aKtRUXtnONNkR IOWDhb7e95+/GFqNvqzp7UCYbALNE7xLv5DJpqvg27k/ZxkPq3qDj2CSlwU/R+T3nIZP iwb1V9shmY3sxTxIAwsY5BLjv5d0dqOH5cgbTT+oU2/+A64kMbXIFV8u2BhZEFEqDf/m 864evqhDWp7Em0EVVJlPtmSUJ84hssERRTv1WTlDdEHEDSHysaeL1kPfzQqEOq3OvFFN TrzA== 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:from :dkim-signature; bh=ak3T8C5JbkhreYOmHRfvBRYEdS1z6Ik0wMUpDu8pGGs=; fh=CGeRqfKKrYaxvvhOGObLHRUUue/LLUSLAzhwrHrEV+s=; b=aWWxr5nowvhsKXiqASNA5sldhH8CJS/ADajC97i306aOj6zYTLTbctXfAWlbf4upuY Oyx1IiXldymZTEUTNkUhxguFm0WQmETzh7OarFZZwqcM6BceOYyPhkTLj+JuVfE8hPw7 F7TDcjLox6Q086/EaP3aANw+hOieKbSwkayDyHpnhmOrnB+PW73rawJnVMAsXOpAyW4F 1WsjV8KOK/exD6kYzhPhxWTXcFck59jZUgv9zPunT2h/nFKIn+8nqZBjG5y9tqiXSMl7 pJI21GrPfe9Ha1WDSOePyokR+znRhKaBaPNm/s5YQIwy6OioUEc5p0jxGvqhgjGujPVQ idBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ij0CYZga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id i128-20020a639d86000000b005775e13a6b9si4657816pgd.363.2023.09.12.05.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:30:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ij0CYZga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8773D8091489; Tue, 12 Sep 2023 03:45:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234563AbjILKpS (ORCPT + 37 others); Tue, 12 Sep 2023 06:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234412AbjILKov (ORCPT ); Tue, 12 Sep 2023 06:44:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3621E1723 for ; Tue, 12 Sep 2023 03:44:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B6DDC433C7; Tue, 12 Sep 2023 10:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515458; bh=VCFbnQWF4lBKNsyVMLqdG0QZaSmJF0XJv43q7YI+WJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ij0CYZgaVcSp8NNMGm/8zBEDL0iwV2PKmBd1Nm5k3o6P+Qp2yBJ98gBJSnUMfe9nb IflZHmMYS+fwdXrzegZVbXuI6GQrB2I4JL5Xmdx+wOlS7AR5HJCWHAuWM4bCbrrWqi 02ZQa72WsGXDf9LUvHsU8c+M/1+1WryFlODfmXHVHCOkJ+RXj5v3EH1FRDgJvkliYq q8ZLvYU+gbFuaVnioZnoiLTBklfsQdkbENaNEs5cEw5Bci7FoM58SXmigmJjR5LRgI tMDPLfpiTdWgqPWqvuGih3IHvGRHV4civS8KaQ3ooUdCegwF6guIvM+5X45PvJWRzZ HumGu/L4k3BRA== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com Subject: [PATCH 2/5] tick/nohz: Update obsolete comments Date: Tue, 12 Sep 2023 12:44:03 +0200 Message-Id: <20230912104406.312185-3-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 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 (lipwig.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:45:44 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776834906013241321 X-GMAIL-MSGID: 1776834906013241321 Some comments are obsolete enough to assume that IRQ exit restarts the tick in idle or RCU is turned on at the same time as the tick, among other details. Update them and add more. Signed-off-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 46 +++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index b66dd0ff1153..95a8d1d118a2 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1175,12 +1175,23 @@ void tick_nohz_idle_enter(void) } /** - * tick_nohz_irq_exit - update next tick event from interrupt exit + * tick_nohz_irq_exit - Notify the tick about IRQ exit * - * When an interrupt fires while we are idle and it doesn't cause - * a reschedule, it may still add, modify or delete a timer, enqueue - * an RCU callback, etc... - * So we need to re-calculate and reprogram the next tick event. + * A timer may have been added/modified/deleted either by the current IRQ, + * or by another place using this IRQ as a notification. This IRQ may have + * also updated the RCU callback list. These events may require a + * re-evaluation of the next tick. Depending on the context: + * + * 1) If the CPU is idle and no resched is pending, just proceed with idle + * time accounting. The next tick will be re-evaluated on the next idle + * loop iteration. + * + * 2) If the CPU is nohz_full: + * + * 2.1) If there is any tick dependency, restart the tick if stopped. + * + * 2.2) If there is no tick dependency, (re-)evaluate the next tick and + * stop/update it accordingly. */ void tick_nohz_irq_exit(void) { @@ -1330,11 +1341,20 @@ static void tick_nohz_idle_update_tick(struct tick_sched *ts, ktime_t now) } /** - * tick_nohz_idle_exit - restart the idle tick from the idle task + * tick_nohz_idle_exit - Update the tick upon idle task exit + * + * When the idle task exits, update the tick depending on the + * following situations: + * + * 1) If the CPU is not in nohz_full mode (most cases), then + * restart the tick. + * + * 2) If the CPU is in nohz_full mode (corner case): + * 2.1) If the tick can be kept stopped (no tick dependencies) + * then re-eavaluate the next tick and try to keep it stopped + * as long as possible. + * 2.2) If the tick has dependencies, restart the tick. * - * Restart the idle tick when the CPU is woken up from idle - * This also exit the RCU extended quiescent state. The CPU - * can use RCU again after this function is called. */ void tick_nohz_idle_exit(void) { @@ -1364,7 +1384,13 @@ void tick_nohz_idle_exit(void) } /* - * The nohz low res interrupt handler + * In low-resolution mode, the tick handler must be implemented directly + * at the clockevent level. hrtimer can't be used instead because its + * infrastructure actually relies on the tick itself as a backend in + * low-resolution mode (see hrtimer_run_queues()). + * + * This low-resolution handler still makes use of some hrtimer APIs meanwhile + * for commodity with expiration calculation and forwarding. */ static void tick_nohz_lowres_handler(struct clock_event_device *dev) { From patchwork Tue Sep 12 10:44:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 138154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp378232vqx; Tue, 12 Sep 2023 05:44:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLuPymtSlf9JvUBfRI89hRTSfIq7Dc5aB2/m2x3+Ma+cjqJ3KtM61tftnXoBROy5FPpXrd X-Received: by 2002:a17:903:496:b0:1bf:39d8:48f3 with SMTP id jj22-20020a170903049600b001bf39d848f3mr9409468plb.16.1694522693913; Tue, 12 Sep 2023 05:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694522693; cv=none; d=google.com; s=arc-20160816; b=ghyMhl/A69tz5B8b7ubaQs0fIIDuYpqVT+rs1C1nZtATy301+wmGszb4u9gcaHbEu3 b7EMZJHIUBhhAjtOUip6lD4+YOFKvg3LPRg3nWS9cJxnoFxSalNv/hOuWgiIFQemh3Ez KCdYBIewJRk+y08+B4uxW2qVYrXidrOPHiGaPPrFVTwTiiaaLdBbknD51t3JASokQtU7 XheBzofEfvehYxa+xjM0HC+ScRMoWi+RL4xi1/CNulbeLw9FbLbKb3kf8CDhCwDAwkAW cDvWgsiMRWazeM4xufG2y1lZWum3PxxXn5/nhInC0NBQjFDPCAlkoDaEi/q/c7XISXky /tqA== 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:from :dkim-signature; bh=IySCpvlRDtWaBhfevoMuMq4DOFuV0e10hd277zPmJUs=; fh=KZsIGXP5HqVXbsRC9/8uC3fw6jb10xtWDpNz3O4AKxc=; b=YPlk3P52QPL/+2qSKEvuC+5EdraKOtxh/WuHaer5tLi+zYhSZgNppCNKCbWOhcmh8j WGDG2Y40Sc5MzhaLBf/sGbS7lLr1wAXYgMdEb991uXxjQqnPXlj7h/pqQ0cPcVqTT/fl f+r+jYTaLhPqENx3pDOlS16monl3H5geZZpwm5hmHZyEM5rIx0aMO0K5oRNEipcKGf/x xqmkYGqklO09B4U2+MN4zGqdH8F+UvH4oJeOC433vHl3BVcsxyExPpOfbTzYCVUkfbSZ QKVQo2rYlY8GPwxL+ikwvGBQBicS6mjXGWYLekFOCoYoHSNfMabo+RDSe8FLuYU6DQ48 EgJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tEbvCx9u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d17-20020a170903209100b001bf0b29d935si7750435plc.34.2023.09.12.05.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:44:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tEbvCx9u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D31DD81BD3FA; Tue, 12 Sep 2023 03:46:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234593AbjILKp3 (ORCPT + 37 others); Tue, 12 Sep 2023 06:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234453AbjILKov (ORCPT ); Tue, 12 Sep 2023 06:44:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CCC4172E for ; Tue, 12 Sep 2023 03:44:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52499C433C8; Tue, 12 Sep 2023 10:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515460; bh=8IMEGNQxJUVrw2F/l3GmN1Ldd+1Byg1w8yqybgZALh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tEbvCx9uyF/x3U3frcNYdc0orFnxJFUZf6M65+NQ6QlTsM0zyiPtq33dJaI5zvgYq 3cA/hKUI7sBb8mYwLRFR2XMCSZ7+msxco0rRRkt9b8A2/xU1sr13E23dZC4zrut+xK HO0U+BjZqCW6XqlrCfWeLWcIWM0M1tsVMSpX/ziQumN3H7OGFjs++AR3BZLop5vWHG wI9Z/EeoOlPuw8p2fY95zQR0K0MATtZL3ca6JP9GqZ1+9RSR6lfpoSeUdeZD0PowRe vjbZz3TzGJZIPgeGezEFrQc9an1xqTqUf35Q5mhoz84fTZqWm07At91+Ksyh/JdwQf Il+4zUKLz0v1w== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com, Nicholas Piggin Subject: [PATCH 3/5] tick/nohz: Don't shutdown the lowres tick from itself Date: Tue, 12 Sep 2023 12:44:04 +0200 Message-Id: <20230912104406.312185-4-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:46:57 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776835828097024247 X-GMAIL-MSGID: 1776835828097024247 In lowres dynticks mode, just like in highres dynticks mode, when there is no tick to program in the future, the tick eventually gets deactivated either: * From the idle loop if in idle mode. * From the IRQ exit if in full dynticks mode. Therefore there is no need to deactivate it from the tick itself. This just just brings more overhead in the idle tick path for no reason. Fixes: 62c1256d5447 ("timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped") Signed-off-by: Frederic Weisbecker Reviewed-by: Joel Fernandes (Google) --- kernel/time/tick-sched.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 95a8d1d118a2..8e9a9dcf60d5 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1403,18 +1403,16 @@ static void tick_nohz_lowres_handler(struct clock_event_device *dev) tick_sched_do_timer(ts, now); tick_sched_handle(ts, regs); - if (unlikely(ts->tick_stopped)) { - /* - * The clockevent device is not reprogrammed, so change the - * clock event device to ONESHOT_STOPPED to avoid spurious - * interrupts on devices which might not be truly one shot. - */ - tick_program_event(KTIME_MAX, 1); - return; + /* + * In dynticks mode, tick reprogram is deferred: + * - to the idle task if in dynticks-idle + * - to IRQ exit if in full-dynticks. + */ + if (likely(!ts->tick_stopped)) { + hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); + tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); } - hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); - tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); } static inline void tick_nohz_activate(struct tick_sched *ts, int mode) @@ -1519,7 +1517,11 @@ static enum hrtimer_restart tick_nohz_highres_handler(struct hrtimer *timer) else ts->next_tick = 0; - /* No need to reprogram if we are in idle or full dynticks mode */ + /* + * In dynticks mode, tick reprogram is deferred: + * - to the idle task if in dynticks-idle + * - to IRQ exit if in full-dynticks. + */ if (unlikely(ts->tick_stopped)) return HRTIMER_NORESTART; From patchwork Tue Sep 12 10:44:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 138139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp365403vqx; Tue, 12 Sep 2023 05:20:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuW1Y9gqzKg1Ef7OTYyJkAOXqp3q7+CzSNknHPWTJiiOPOSWMf22rkGfscQrsza9acy5F8 X-Received: by 2002:a17:902:db0e:b0:1c0:cbaf:6954 with SMTP id m14-20020a170902db0e00b001c0cbaf6954mr3759958plx.25.1694521247451; Tue, 12 Sep 2023 05:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694521247; cv=none; d=google.com; s=arc-20160816; b=YCb+aMYH8asVOO1viDrBR2yIvhctZKAL5EKfCgv5RwV/qFnk9ReYUh75bthBJom0Sv VgHqtSF2syY/2/drYS62Pd1Auzgkw5x368Uwlp/EJs6Py5vdYXA4wLwHrIXtQsy8lm0s W1XM5xO21TtRa3OFUq0nAt3vADow2R9ddXm6WAQL1ZJzB02Y3wkMpwo+LuiESiSSKqf/ /FWoo10o9Gp/YCsSJa0h7anY5FRjMkhyI57UxwNqD3U9HW6aaE5sujAzhbslfDdfspOX wGHXa5zSELXj3jxf3y8wXYtaX1qIMKB0UN9dqo7VpT16eATpVmyWfsqi82xncz+U+ZSf LMzg== 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:from :dkim-signature; bh=m1MIBcr8/BtnlaaAi1XIPDpZodUp7qqjiVIwa8L8ABI=; fh=yDKuc92c6sM867+x3P5LuhfNA2PadQ37AAIZPomQ9LY=; b=l5jOrZE3yhPzapf320hauqmSd6rJv8zzt/8khlQMLFnbg4ZaKZdDMfjXOjhoIj8ppK aoHbW+udRdZaD/YyCf27G2IgQZwktgSDBl0w6hnUSKKNQNepBTL+zMOsDtk54u4GLki7 EFW09ZRynAeAiTeFIgZh+FLdbegI3TK/9ZQtSv1v1ycnhAFHPtMP26qcfEsiWw8JznsC VlRGtsVXx/ZSmtYNF5Ct0Yz0r78Hnu0cmn2a6hQtez0w7eoXi5EU6hTPOSQeiSAZZ3ew /NhRG1cjY3xVZ4VJY1AM8y4OCW2rRpZsY4jLHJ/+Fy95iaZ2b+8tBcRDQqCJv/Wb3wGu H1Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mRiMFQ3T; 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=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j4-20020a170903028400b001c3d864d6b5si741884plr.292.2023.09.12.05.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:20:47 -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=@kernel.org header.s=k20201202 header.b=mRiMFQ3T; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CD6CA80907B1; Tue, 12 Sep 2023 03:46:11 -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 S234435AbjILKpq (ORCPT + 37 others); Tue, 12 Sep 2023 06:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234478AbjILKox (ORCPT ); Tue, 12 Sep 2023 06:44:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 520A11982 for ; Tue, 12 Sep 2023 03:44:23 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36007C433C7; Tue, 12 Sep 2023 10:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515462; bh=wNRp0lSuxwMF/JBQ5Mv5SUmlz7jkA1SazJ3u0SEnyQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRiMFQ3TZg0b5e2/UXpeqpL962IQg/Dw5AKU6Z6/L9QPyYyo5R/qFsbM+dIFQKsCT ctbs2cJujr/63bxzP1T1GNjK0rVUGAkCoWGd00x1CzZK2R+YISC8hZXIBqlh7AIRMm voH1VupgLpwxumQEJPwbP9D0FMv9hOLHM4E9o70nPc4T8sbucC6iyRV8ERv+Uus/tJ 8jNVqm1tm/q52P/qzjGJMi8+US5jZ+7Pseb0ol1SmDb3qEb/j3GaBJOfJQu913qb/0 2j4m74AB9JhG3BGCXZ/wbs88J4wdIgVx2H9UlBNYD5mqTpEF43sjB2ow3cOFbSjR1q JCY7cTnrD5Pwg== From: Frederic Weisbecker To: LKML Cc: Xueshi Hu , Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com Subject: [PATCH 4/5] tick/nohz: remove unused tick_nohz_idle_stop_tick_protected() Date: Tue, 12 Sep 2023 12:44:05 +0200 Message-Id: <20230912104406.312185-5-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 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]); Tue, 12 Sep 2023 03:46:11 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776834311458919185 X-GMAIL-MSGID: 1776834311458919185 From: Xueshi Hu All the caller has been removed since commit 336f560a8917 ("x86/xen: don't let xen_pv_play_dead() return") Signed-off-by: Xueshi Hu Signed-off-by: Frederic Weisbecker --- include/linux/tick.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index 9459fef5b857..716d17f31c45 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -140,14 +140,6 @@ extern unsigned long tick_nohz_get_idle_calls(void); extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu); extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time); extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time); - -static inline void tick_nohz_idle_stop_tick_protected(void) -{ - local_irq_disable(); - tick_nohz_idle_stop_tick(); - local_irq_enable(); -} - #else /* !CONFIG_NO_HZ_COMMON */ #define tick_nohz_enabled (0) static inline int tick_nohz_tick_stopped(void) { return 0; } @@ -170,8 +162,6 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next) } static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; } static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; } - -static inline void tick_nohz_idle_stop_tick_protected(void) { } #endif /* !CONFIG_NO_HZ_COMMON */ #ifdef CONFIG_NO_HZ_FULL From patchwork Tue Sep 12 10:44:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 138153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp378072vqx; Tue, 12 Sep 2023 05:44:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6jaCCtkT0sKJZYjcxWU5NW8VAPOQZaV+chKlGw/OcI3QT4Jy3DXbL18PJo5rc/i3GCe4M X-Received: by 2002:a9d:7595:0:b0:6bd:708:c1f2 with SMTP id s21-20020a9d7595000000b006bd0708c1f2mr11651711otk.14.1694522674913; Tue, 12 Sep 2023 05:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694522674; cv=none; d=google.com; s=arc-20160816; b=HIG8zkWp88VZ5IY8jQNzAdrriV7f5Sq+LxWL0cSYsyWW0optRYVS9jWN8nMbx6QPHZ cFDxVf5RHOzK8EfkC5TedPvKEUOpCVprbV7dPJx/fULTPebPi6Qj20Cfey998GkpKObO cd8Z0fwsMs9wMKbngn4SKPTRPeIQBhrbSQ/HOOLQ5X4PGOjuROchEhtgC0aHCsf4dMky 1RfrPihvgIPUa63kq9zDsAHsfpdIq0h9y2i18Xzpec3kaGidRAeLAXYs9FzWzxF4hpNs q1p6BWGMKEAqNZJZMcwS1lHt6k3RRQvYv9dLgJqAB4Qzp52dbtys7bSO9Ccuy6yyk8b3 0a5A== 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:from :dkim-signature; bh=ZAiMGopUwyL/M3ozQV9VdceOhAEEV9kRjWuC9GRkVVQ=; fh=CGeRqfKKrYaxvvhOGObLHRUUue/LLUSLAzhwrHrEV+s=; b=qygksuO2tKZRJ9t9uBzaGPYybuFuKsGofQqINsyq9BrR2t+fT1fFnjp4HyG9Tw9AiC e6gjl7EUrH9DpBWkF7IZ27nR8Ay/OsmuQ/TQQJEAEThBRT0zXunQHIf61jYapN1vqrQU 9q0dxiDGJBYPt3SRWzZCz5HjJ8Om10KEtg9aOA1NW93jpkwqoQship6nHT6Znfb2CuFh sNafDSTczLl/sQUjo1HeVCTJ2iOS43bXxK/5LxfDQb39QJH8P9ooc3SLEgU0TsLXicF4 QiN+XdAnuFiMjtuK/xCoWgF3Z6+73z34AF68qqauZcN0ByW9WMXzbLsff9K5VJZWLZy0 uJXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HVplCqOX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id n31-20020a056a000d5f00b0068ff3927553si311219pfv.35.2023.09.12.05.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 05:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HVplCqOX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9D30A81C0C98; Tue, 12 Sep 2023 03:46:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234470AbjILKpx (ORCPT + 37 others); Tue, 12 Sep 2023 06:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234493AbjILKoy (ORCPT ); Tue, 12 Sep 2023 06:44:54 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8DC51987 for ; Tue, 12 Sep 2023 03:44:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19AB6C433C8; Tue, 12 Sep 2023 10:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694515464; bh=1xq6Mgf32EY2JQOJHQcEgJ3L7Kjn6lb+CzCCKEAz46M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HVplCqOXjJormHSlR2bAyrpRlkyfPFfJEe2vJuJn5mL6+u6rPaN61klmUFrLzRuSe 5Sa1L92QTSATpU1dj8EkdTWjGsnj/WWzmhP8KOGqMIUfVIkFeEKWjk8b2tG0zjp/b9 xqtgWfjjpOwTfTEbUOLbrKRWtRUcX4PIqv58T7E96oZUUX8ILH8QB9nm8VGAt+Rdkp 6IWYMbPSlcWUa/MQkDUqeFHp0NISKywyiGYeDJfCXZnVJzCE82s8FW3NxJre0QFigG rpIRrVXQIh+eEOB++P+ea8VLh8U/vXk81EPR4mlUeCvn5KRm114kdG83D0MpdSGNOL ok5tAtzcqTA7g== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Joel Fernandes , Thomas Gleixner , vineethrp@gmail.com Subject: [PATCH 5/5] timers: Tag (hr)timer softirq as hotplug safe Date: Tue, 12 Sep 2023 12:44:06 +0200 Message-Id: <20230912104406.312185-6-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912104406.312185-1-frederic@kernel.org> References: <20230912104406.312185-1-frederic@kernel.org> MIME-Version: 1.0 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 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 03:46:17 -0700 (PDT) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776835808613616282 X-GMAIL-MSGID: 1776835808613616282 Specific stress involving frequent CPU-hotplug operations, such as running rcutorture for example, may trigger the following message: "NOHZ tick-stop error: local softirq work is pending, handler #02!!!" This happens in the CPU-down hotplug process, after CPUHP_AP_SMPBOOT_THREADS whose teardown callback parks ksoftirqd, and before the target CPU shuts down through CPUHP_AP_IDLE_DEAD. In this fragile intermediate state, softirqs waiting for threaded handling may be forever ignored and eventually reported by the idle task as in the above example. However some vectors are known to be safe as long as the corresponding subsystems have teardown callbacks handling the migration of their events. The above error message reports pending timers softirq although this vector can be considered as hotplug safe because the CPUHP_TIMERS_PREPARE teardown callback performs the necessary migration of timers after the death of the CPU. Hrtimers also have a similar hotplug handling. Therefore this error message, as far as (hr-)timers are concerned, can be considered spurious and the relevant softirq vectors can be marked as hotplug safe. Signed-off-by: Frederic Weisbecker Reviewed-by: Joel Fernandes (Google) --- include/linux/interrupt.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a92bce40b04b..4a1dc88ddbff 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -569,8 +569,12 @@ enum * 2) rcu_report_dead() reports the final quiescent states. * * _ IRQ_POLL: irq_poll_cpu_dead() migrates the queue + * + * _ (HR)TIMER_SOFTIRQ: (hr)timers_dead_cpu() migrates the queue */ -#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(RCU_SOFTIRQ) | BIT(IRQ_POLL_SOFTIRQ)) +#define SOFTIRQ_HOTPLUG_SAFE_MASK (BIT(TIMER_SOFTIRQ) | BIT(IRQ_POLL_SOFTIRQ) |\ + BIT(HRTIMER_SOFTIRQ) | BIT(RCU_SOFTIRQ)) + /* map softirq index to softirq name. update 'softirq_to_name' in * kernel/softirq.c when adding a new softirq.