From patchwork Fri Jul 14 12:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 120448 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2465512vqm; Fri, 14 Jul 2023 05:24:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0s0699rTdhF5U3WCNhTabkCz5XG30nXzvO6ZV0vKKUzWAIO7+BHWVjrlHs1ijNSDEprWp X-Received: by 2002:a17:90a:1b64:b0:25b:e85a:e9fe with SMTP id q91-20020a17090a1b6400b0025be85ae9femr3531139pjq.27.1689337456357; Fri, 14 Jul 2023 05:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689337456; cv=none; d=google.com; s=arc-20160816; b=i7eBvGrHEty8okhV2yaTItMkHgxBPhRvrPCHDvm+PPeusdLnc6MvJKwLnDpjRLN9di +Sl8myLvV4KGbzRRGEXJpwgYrM7hEdhw3kLs4EfJl8o77BITxShoGTGGUA7xwYiXmzRh 6Nl3QVDhC7R46TKWBobHAU4O92RlhxdBCr6YKGkdFgWXYJssM6dnuYmm7165GvTAN8H4 o/QEZqIXNhzjPBYEgeg7M8J0u82dDKWPIigMlGG3myqeQrILK5dCCisylkGBpi0IsKmD 68swZ3iu6whSUv3DoiiYlXzmajCBaqtLLgBvVmgSJq1OGbVYPJPs4gRhhW01onqtAg8A NndA== 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=zaoHTLPPjTBF/KLRLSh9kbCut/t1wErd0fpavaWyEEM=; fh=vNYwn+erbeWwD/B9CW78N3vavRIPBl+xONykG2Vq2so=; b=cwRipAo4a8+AXR2YW4z5zBuiEcWqakxD0+Gw7jRLWODj8MvTyD+mtponpWPmxdUxXU s5MMXG37t5YcVSv090qNDQlzvXuJhLInaAppfFApJtGC8fsTvqby37QOgVTr8aSzo2Vb c3RK5ylBqdjpoOfioIO7Xvggb/Fk+GyY0QjR0aHB753ELuUBDTC7VrWsRn2sclka0O9l 42uMmS6voQt9nEjMnQ3Eww/hv+6qcjN0jy7Dk4ozBKSSiidj2Ooanat4Ja86DcwXGNzN r8TJyBQCU0g2udiPNUnSa1RrnH4SugpEevsqjlmhJszDPqcOJ5i/f8V4ORLQ0znlmHIL ZSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ezahMPhe; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a17090ab79200b0025945de4165si1165142pjr.141.2023.07.14.05.24.03; Fri, 14 Jul 2023 05:24:16 -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=@kernel.org header.s=k20201202 header.b=ezahMPhe; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235711AbjGNMJG (ORCPT + 99 others); Fri, 14 Jul 2023 08:09:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbjGNMJD (ORCPT ); Fri, 14 Jul 2023 08:09:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8741B30FA for ; Fri, 14 Jul 2023 05:09:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1CDC761CF8 for ; Fri, 14 Jul 2023 12:09:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2FF1C433C8; Fri, 14 Jul 2023 12:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689336540; bh=5aN+Q3oPnafKIF2T8wfhM6z+hA+r3+neTwc70S52vG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezahMPheOD63bR1r/oq88CH2vQRpZI5Byj8Fnh9pW29M7BWLpyJ4SEoC9127ahOy+ V8daIhJFQieJdx9MqSve3W9uSzCd5jRMLEFdjd8mZNyqGyj220pJP0NQCvK929Qf5W iYPG8HBnh2pSv6bgEkiCizEOC1Uxyh/fK2SR9r7y+bAmR+59VpMjytaMXh5gZ0Lyu2 +905GRsd4V5N32w/fppNIUbJjbj+RbQfDXEyJWaIz8kNSmOyMoaiULSsoUjBoJ6EOM mVjKL71NOcBrn+oZ29tMxZ02QJnLpWxmKFTCu1VzUozn0C03DbNv3RliTbtGbGqTg5 im99tuTCdEQXg== From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker Subject: [PATCH 1/3] tick/nohz: Rename the tick handlers to more self-explanatory names Date: Fri, 14 Jul 2023 14:08:50 +0200 Message-Id: <20230714120852.23573-2-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714120852.23573-1-frederic@kernel.org> References: <20230714120852.23573-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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: INBOX X-GMAIL-THRID: 1771398712425602820 X-GMAIL-MSGID: 1771398712425602820 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 89055050d1ac..a7b5960258f2 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1355,7 +1355,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_lowres_handler(struct clock_event_device *dev) { struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched); struct pt_regs *regs = get_irq_regs(); @@ -1401,7 +1401,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_lowres_handler)) return; /* @@ -1464,7 +1464,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_highres_handler(struct hrtimer *timer) { struct tick_sched *ts = container_of(timer, struct tick_sched, sched_timer); @@ -1513,7 +1513,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_highres_handler; /* Get the next period (per-CPU) */ hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update()); From patchwork Fri Jul 14 12:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 120447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2465451vqm; Fri, 14 Jul 2023 05:24:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlHGcKDOP6FK3QU9kTEyUqZXrVXH7XmO1RBPpT6FUxP0ThbShQwuOkqmf73lH32tSMBfgqm/ X-Received: by 2002:a17:903:1205:b0:1b0:3a74:7fc4 with SMTP id l5-20020a170903120500b001b03a747fc4mr3746667plh.24.1689337452020; Fri, 14 Jul 2023 05:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689337452; cv=none; d=google.com; s=arc-20160816; b=Xu9+IYVxPgfK80QJM5gYlhPRA2InyNSu1LiH1JxnMvIek1OV9HDZgr3GdVBJLnLDs0 b4lvkIYm8G0sMjN6eRRJHEOz6lYhyKedjvw62MxQF+STycTGR0a9hz/+jJS0GanUS+BG /qgfU2YmWhBut8HDNfDBEX68EnY6BpeH3YVHg5tAZji+ax4EmBxPeyRH9B/IXhYia+IH 8FxQd2BOvXWm8Pp2KoxvjBfK+rFhEdnQry77j1wYg7Ay9EwsbsGzOKIpOK/88mqYBqvS OaEb8gNkc2cGN5n1NBnh6HxVamyREHGCU/zux1VnM+rk8qSE05K3Ohnr7BU0O9zJIwIX f1hg== 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=xKmFKOVZ3pMTXww/u6pLwlUieiLyxygClj2cq9HnpCQ=; fh=vNYwn+erbeWwD/B9CW78N3vavRIPBl+xONykG2Vq2so=; b=bi4B4nW84z3Ozavp494YPrthoazwmIT536zNS2xmT6ljFZ4k9rJfxziXKHqU1TtZ1a U8on9fRNXVmDEzsKIwywSyMYGODSsHrmxsKxQ5Qst/hW6CR6g3jh4X/s1qhPJZkaTpl9 iOMI1PP6aZHEHFk1eKFLJOmSOLjDJeF/76hu951nFiC+xPfK3pFJYVjQ2RBPO6BxiAtz JjKmYFzTcHWQR69CVJyx4BG/7qfLG5RgAKsVSF4iX9ueyZz4/TWMo7f9uAYQ6U3sAMLF UAz/+iw7fMSz1qoVEF+sojaH4yKvZqQfQUMnalxmzGbw8mo1IsIyCYkD72BwKEK2hIab ObwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UFL3GL+i; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a170902a3c700b001b8a8f359fcsi6998980plb.208.2023.07.14.05.23.59; Fri, 14 Jul 2023 05:24:11 -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=@kernel.org header.s=k20201202 header.b=UFL3GL+i; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235720AbjGNMJI (ORCPT + 99 others); Fri, 14 Jul 2023 08:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235700AbjGNMJE (ORCPT ); Fri, 14 Jul 2023 08:09:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E07CC358C for ; Fri, 14 Jul 2023 05:09:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 753DA61D0A for ; Fri, 14 Jul 2023 12:09:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03E65C433CA; Fri, 14 Jul 2023 12:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689336541; bh=/slFP8PnGWA7H6MNZcZEGi/oCv3llKDnLYsTqJrggjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFL3GL+i9SEmh6xzehP3qYrtCSQOb0b6FNgdVcFZjKbCZejrXkHygNSLEHjLu/kk4 qhI/CZrbrLA7K1543AHyXbq8FNOEu11/ENta+gfatziIz20qyAkQX1XM+mofdK31Kg IgHa+hp86NexxnQSwTYekodb/dTkFRAdotYw6avQ+RBIjPqkeO1s91brUbpL59B8vZ mOyv0Q8ofr51/pZ6FKS/byFQIaGWGLE8xW5LWAz0aF75pqItc2/+Pc5hgDVrri+9nk pFnva78vZkH5p0fUXbSg3EGnob9wrxhJ0sayjglGlmXWOXCRdCsCZcjY7Iic2Lzm2f 02hW7WDbZ39Eg== From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker Subject: [PATCH 2/3] tick/nohz: Update obsolete comments Date: Fri, 14 Jul 2023 14:08:51 +0200 Message-Id: <20230714120852.23573-3-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714120852.23573-1-frederic@kernel.org> References: <20230714120852.23573-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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: INBOX X-GMAIL-THRID: 1771398707844112129 X-GMAIL-MSGID: 1771398707844112129 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 a7b5960258f2..dd25da8531f4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1164,12 +1164,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) { @@ -1319,11 +1330,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) { @@ -1353,7 +1373,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_lowres_handler(struct clock_event_device *dev) { From patchwork Fri Jul 14 12:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 120451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2466149vqm; Fri, 14 Jul 2023 05:25:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlGf0AhC/2lLfawOBxKR2uhX3AeC5teJuNoMs0fXqH67vIT+AwZNgSJb7oAhcS3HiXb0Gc34 X-Received: by 2002:a17:902:ef85:b0:1b8:9044:9ede with SMTP id iz5-20020a170902ef8500b001b890449edemr3142806plb.62.1689337523646; Fri, 14 Jul 2023 05:25:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689337523; cv=none; d=google.com; s=arc-20160816; b=p0ELzQdtGt2Dy/iSdr2/UxOX0IJxpxCgsLQL+pQ686yvQFYO4QW2e4saes44kn0612 MEpq/NCzuAaMph4/e7Y2edmsoFylSztp/lj2fszWiNrhTLuGp+75DbjYiCoUFzpL0bzn x9uSrMpiXSr9SvHLERWhXCeQCqZh20jc+8zld6Ts8YyLPPm25IS/cyvmvA7LGAZxVsdj 42D9V/JeN2g2Y63b16WkBK8u3HLhQTV+Lr8XG+qpqfj0rL5NqylZzIB5vl4ZmjV8vwHw ocMP2w4Y3wQIkHNuNffY8tdOh5dyc5d0xDuL/d745fj+KXmR1snoJCfmYD4GgzqJXJsz U8MQ== 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=PU/dDkGlaP+BQOkYqUFvlOR5a15Zkn2dL0CNUDn9lZE=; fh=vNYwn+erbeWwD/B9CW78N3vavRIPBl+xONykG2Vq2so=; b=DU++8RtuZvaZMR27ML6JPO7nV77Cmvqj0Jj6MPE66tXk2HStuekrYXysVb304AvaFL VzNKrE2M9cddqQQach2k6NlshzcYOjHA0/u4Tn5re/K2iI0lqKPYy/efRl0yuxnyLBCw 1ETYx5RMS3J8gccv9+90HFYHxzAi//1ncThOmaLn3rj0MZPRRcyqB31vs14DMmTu5nHe BiiyiBhMigFAgKvSbQcQBD/oFr+ZH3cNhNUuI91bRClzFzapxgzIcmMUmJ5HDh2uBHBo flaARkCWYtYp0Ga9xTfUu0t9BBk7WUCnmkHFYMqdJKDSfSJcGkCAQW7kun33ewXVilFM QYng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EELJSa6d; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a17090301cb00b001b3be4fadbfsi7315747plh.159.2023.07.14.05.25.10; Fri, 14 Jul 2023 05:25:23 -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=@kernel.org header.s=k20201202 header.b=EELJSa6d; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235732AbjGNMJK (ORCPT + 99 others); Fri, 14 Jul 2023 08:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235709AbjGNMJF (ORCPT ); Fri, 14 Jul 2023 08:09:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF92212B for ; Fri, 14 Jul 2023 05:09:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CAB1B61CF1 for ; Fri, 14 Jul 2023 12:09:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58240C433CB; Fri, 14 Jul 2023 12:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689336543; bh=nUjt9aPIm8t8zpCcFZjv3pXhHtLHcHwW+ZKfovq5PGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EELJSa6dEHGyMIPSwoSdvUpZm/AQsox03og/2qj+DWzf101pcI642XDG3WektyVaN Up2r9pkCt/JsJ+uVAS8qFHYS9q47Vl0auU+lk5wG1K4i0nXHEViENcW+PaUUjtEcO0 I0jp1jssPkj3Jw6hEQOlX8ED2NO/9PvKaEIG/qBLXWrn2yLoOmCw0+wuZvWbClBFWS qHrsbu/BS9vZNPeTJKpc1tLBS/fqB9mAhFrazZOeo40+nKK/LISOXEvWDkjx1COIAG 6WvBimR4igEcq/Q2+o2NdTmwbdUrUgS9zPOq4TX3IDFJsX+BliqACR+lg7nnRcegQ7 +EkBl5Y66fdOQ== From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , Frederic Weisbecker Subject: [PATCH 3/3] tick/nohz: Don't shutdown the lowres tick from itself Date: Fri, 14 Jul 2023 14:08:52 +0200 Message-Id: <20230714120852.23573-4-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230714120852.23573-1-frederic@kernel.org> References: <20230714120852.23573-1-frederic@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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: INBOX X-GMAIL-THRID: 1771398783140064729 X-GMAIL-MSGID: 1771398783140064729 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 --- 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 dd25da8531f4..101251e103be 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1392,18 +1392,16 @@ static void tick_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) @@ -1508,7 +1506,11 @@ static enum hrtimer_restart tick_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;