Received: by 2002:a05:622a:4ca:b0:41c:c224:f26f with SMTP id q10csp538215qtx; Thu, 16 Nov 2023 10:49:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdbId3Kq/Z2ThMSPda3x0GoS7CGdVXnuzsjcVf6+a2M4OWriNC9WarEAgS6jZRP7GGnd5T X-Received: by 2002:a9d:6656:0:b0:6c4:ded2:44d0 with SMTP id q22-20020a9d6656000000b006c4ded244d0mr10369137otm.27.1700160556907; Thu, 16 Nov 2023 10:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700160556; cv=none; d=google.com; s=arc-20160816; b=YK9FIudb9uko5ycQQfLmBFBg0mQWG40sjNSsOkzt/zqNIqpAqn5pbCPWsTBx0TbpNc bBxBlPpjhAPytS3wdGCUURrd9WozERTgGnH/Qq499KF4My3wiiBSH1cpku4hpdWCZ6K7 BUUwAlGKV7RzxufgHyI1ZzowYRwdaeGSng29UHdlSTGgo0zrJwvKuZvjeEOj7e2DnnIi 4nHcnXy0aWWVVlKS26qRn8g/ccKi6NNZKrsc92EiWERhkepsapVhGrfXmzKa3OLXd66l 9Hh+rzmz+mNOy5/L4ZnfQsVuYh35Y30uPd/Qq8TkSS8WMpVVbl8FvMgwmGDmZ/tBrJfE 4TMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9kdgSLyA02Hwq6KW0Hb/5ImZHzbiZ6Nt6hcgENnhDUg=; fh=hOrYZMVHpjYX4qdSvyslvtocqyeiZbjRsqNckK9HsoE=; b=aFXwrMmUpXWBGTJtCAJ9hS87M35G6D1KxEUW4ZsoCACkRs6X0lrtYL3z4r0BTuqYtk 4A5ZKcDfpoVCW9NM3MmaxyOriOSSTXP7swH75+9AVm01P9pbR0FfnCia0MFz0ATCntX6 pEBBxDy/7yagkW7tHZL0eE0CcR95zIgxS+0W0u7qdK1zDXShyGw9LMut8R5cc93MyjKA qKcWA3f08R3JiJ+hbzPYkjPhawaqpyULaNGiEyDD+yoXCz3/R56mJ92HpB5MDh32DkcN 7et9qHw+n0dOL0sTYsg4tX//jCpisRmDpC59C1+RIQfCvvkaMthkK4FJG9QMk26EqofO 5PSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GHTwRTm7; 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id j71-20020a63804a000000b005859a7d38f9si39431pgd.703.2023.11.16.10.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 10:49:16 -0800 (PST) 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=GHTwRTm7; 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 55D668051AB1; Thu, 16 Nov 2023 10:49:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjKPStA (ORCPT + 99 others); Thu, 16 Nov 2023 13:49:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjKPSs7 (ORCPT ); Thu, 16 Nov 2023 13:48:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D138C181 for ; Thu, 16 Nov 2023 10:48:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 115D7C433C7; Thu, 16 Nov 2023 18:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700160536; bh=0KG7GdzP336+0cjZwUNxFr0qe0BUvljcO4RomC7f7nI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GHTwRTm7/D2J7jeuVpmBKgYqMUX5QcAnwsYrmyNaxDYK3PcabLuiWSozYDuMFsHTn eB6OM9gOD2DshqlUCufpO4SnFaGWhV72cjygNi6NUU8zLmM7MLLyRab3q7NdyP30wo hgc8uewEAGuB6oxiHcByzefcglPCNh/xwx3lr2kg4a6F/9qOi3QH7vTpHEjTwn+8ps a1vowyJvO2+O1wh6H8Ufx/TNhAwYfJcku1daxzoJje4zu65EAZg4hC83iEAXFNRiQr hVJAchK7WprnjQJhoDHaXPuFEOPSwANGc1hvqfTejIc1Fe+x3E6gktAdsuzIa2iQaz YsXITMmodmqUQ== Date: Thu, 16 Nov 2023 13:48:47 -0500 From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "Rafael J . Wysocki" Subject: Re: [PATCH 3/4] x86: Remove __current_clr_polling() from mwait_idle() Message-ID: References: <20231115151325.6262-1-frederic@kernel.org> <20231115151325.6262-4-frederic@kernel.org> <20231116151316.GH8262@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231116151316.GH8262@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=-1.3 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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]); Thu, 16 Nov 2023 10:49:13 -0800 (PST) Le Thu, Nov 16, 2023 at 04:13:16PM +0100, Peter Zijlstra a ?crit : > On Wed, Nov 15, 2023 at 10:13:24AM -0500, Frederic Weisbecker wrote: > > mwait_idle() is only ever called through by cpuidle, either from > > default_idle_call() or from cpuidle_enter(). In any case > > cpuidle_idle_call() sets again TIF_NR_POLLING after calling it so there > > is no point for this atomic operation upon idle exit. > > > > Acked-by: Rafael J. Wysocki > > Signed-off-by: Frederic Weisbecker > > --- > > arch/x86/kernel/process.c | 1 - > > 1 file changed, 1 deletion(-) > > > > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c > > index b6f4e8399fca..fc7a38084606 100644 > > --- a/arch/x86/kernel/process.c > > +++ b/arch/x86/kernel/process.c > > @@ -930,7 +930,6 @@ static __cpuidle void mwait_idle(void) > > raw_local_irq_disable(); > > } > > } > > - __current_clr_polling(); > > } > > > > void select_idle_routine(const struct cpuinfo_x86 *c) > > > Urgh at this and the next one... That is, yes we can do this, but it > makes these function asymmetric and doesn't actually solve the > underlying problem that all of the polling stuff is inside-out. > > Idle loop sets polling, then clears polling because it assumes all > arch/driver idle loops are non-polling, then individual drivers re-set > polling, and to be symmetric (above) clear it again, for the generic > code to set it again, only to clear it again when leaving idle. > > Follow that? ;-) That's right :-) > > Anyway, drivers ought to tell up-front if they're polling and then we > can avoid the whole dance and everything is better. > > Something like the very crude below. Yeah that makes perfect sense (can I use your SoB right away?) Though I sometimes wonder why we even bother with setting TIF_NR_POLLING for some short parts in the generic idle loop even on !mwait and !cpuidle-state-polling states. Like for example why do we bother with setting TIF_NR_POLLING for just the portion in the generic idle loop that looks up the cpuidle state and stops the tick then clear TIF_NR_POLLING before calling wfi on ARM? Or may be it's a frequent pattern to have a remote wake up happening while entering the idle loop? Thanks.