Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3907357rdb; Mon, 11 Dec 2023 03:47:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQR3Wx6LhGK/WWmotJks3xWZu92Tk8gD0mRvWWMuO6hQfQhZfMNvD1R7G6sFmzvQtLc1cD X-Received: by 2002:a17:902:ef89:b0:1d1:c96a:c76 with SMTP id iz9-20020a170902ef8900b001d1c96a0c76mr3654969plb.99.1702295223525; Mon, 11 Dec 2023 03:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702295223; cv=none; d=google.com; s=arc-20160816; b=bMtqjgsUnBJygr7Bl/Ayky3ejE84C7FtzckMMPcj4D2A1DwZ5GzgG0QsfaNIvLeGdL HfRWhci6H7e40vy+futQZ3bNhUzTtnXtfk2cfP5eqdLqZEPLQYQtD2hbMm7zDuiRKoDI PzbHuSh0HK1dKnsbEi2is261P/wtCeTiQ01wsGfukuViX6AADmEbc7B70IBcnlSricK2 jckt28CQeCo/aptRHK3NQ+NyEGk8ryWXjw57i1Lxa9yHhCfPDxL6kRjV/r0gbOrSxMx/ NxpPHkZRzfquN23MYlIkPZFz8BaXAiRiDQ7nV6SrMzSpfqybI2yV6YSw0EAQbopJr4Fe 3qOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=k9Pu+V3C6P/dn55eCSoyQQMiDi0SMGOJaGZ4mpjHtn8=; fh=4nyO7PGtLkP04b9NIOsI30yIkzZNwyj8CnFSrTjxW2E=; b=CSgKC2mxYDmXRt9sZBn4LSl5QQu684JR7FlRFbnuFeWVG/rlhf44P6vPk1fU/5Mmkt hb2vMLDrypWTyLBSuixdUwA19dSoViyrSUveltq5YMGrEkR6cSatnrt84tgbmeDLtoN/ ccJa1fgq1GykUOwLiDW5gUMH+FAWLS4xu5rdeCuP1kWl/OtnPv+Ht/2QgA3IY6o1Ww0P HboRsUh62RpaeTSlabptjz6RH8x8saC7cFxlouoH2ck6Sg6nT+szYOzAvF/vLgTqri9I jXEUXZNd4kS/r+rTHI4/qRGABKI0DwtQOKN+WyMOJQp4I++if4sPqPjRi40VQEAw/5Ri 5cHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FiUP88yS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m8-20020a1709026bc800b001d06d7f9134si5939253plt.97.2023.12.11.03.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 03:47:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FiUP88yS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 0BB4C809E71D; Mon, 11 Dec 2023 03:47:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234417AbjLKLqt (ORCPT + 99 others); Mon, 11 Dec 2023 06:46:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234729AbjLKLqo (ORCPT ); Mon, 11 Dec 2023 06:46:44 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4351FE4 for ; Mon, 11 Dec 2023 03:46:51 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DC84C433C8; Mon, 11 Dec 2023 11:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702295210; bh=zok5xX1OP1JBLwsks2rLDSP5o/dPlt9Lm7Y9BmkQ62A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FiUP88yS3tXlhk0c6uic6GYAqPRUcdiOZXIxG5NviwR4WPsfbfbMNCID1WZrbmUBu Hw6w25nX8M+90iRumlsy28NYhfnur0gRbhZ3s+2YpVc4yBqPS/sXcBuzVpzKlbnBJk +vm4d7cPgNGWlYPpufsiZQSN2RSC6l85eSZEi9Ky/SzwvhGdhaQQWiIA60smARCyBO JKw1guoblFXi58hVzWP0n3bhpNQPjXMGDGRSuNh/l5MRQ51UAD842SrrCUy8x6uZ8u qr4ACm81qJipMkLCLS0byuFnDFak92M7zAdEFBZfk49IHLQgIjm3ASwBoOTqIct+NZ 5GGBsIFYhOp8A== Date: Mon, 11 Dec 2023 11:46:42 +0000 From: Will Deacon To: Mihai Carabas Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, wanpengli@tencent.com, vkuznets@redhat.com, rafael@kernel.org, daniel.lezcano@linaro.org, akpm@linux-foundation.org, pmladek@suse.com, peterz@infradead.org, dianders@chromium.org, npiggin@gmail.com, rick.p.edgecombe@intel.com, joao.m.martins@oracle.com, juerg.haefliger@canonical.com, mic@digikod.net, arnd@arndb.de, ankur.a.arora@oracle.com Subject: Re: [PATCH 7/7] cpuidle/poll_state: replace cpu_relax with smp_cond_load_relaxed Message-ID: <20231211114642.GB24899@willie-the-truck> References: <1700488898-12431-1-git-send-email-mihai.carabas@oracle.com> <1700488898-12431-8-git-send-email-mihai.carabas@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1700488898-12431-8-git-send-email-mihai.carabas@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 11 Dec 2023 03:47:02 -0800 (PST) On Mon, Nov 20, 2023 at 04:01:38PM +0200, Mihai Carabas wrote: > cpu_relax on ARM64 does a simple "yield". Thus we replace it with > smp_cond_load_relaxed which basically does a "wfe". > > Suggested-by: Peter Zijlstra > Signed-off-by: Mihai Carabas > --- > drivers/cpuidle/poll_state.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c > index 9b6d90a72601..440cd713e39a 100644 > --- a/drivers/cpuidle/poll_state.c > +++ b/drivers/cpuidle/poll_state.c > @@ -26,12 +26,16 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev, > > limit = cpuidle_poll_time(drv, dev); > > - while (!need_resched()) { > - cpu_relax(); > - if (loop_count++ < POLL_IDLE_RELAX_COUNT) > - continue; > - > + for (;;) { > loop_count = 0; > + > + smp_cond_load_relaxed(¤t_thread_info()->flags, > + (VAL & _TIF_NEED_RESCHED) || > + (loop_count++ >= POLL_IDLE_RELAX_COUNT)); > + > + if (loop_count < POLL_IDLE_RELAX_COUNT) > + break; > + > if (local_clock_noinstr() - time_start > limit) { > dev->poll_time_limit = true; > break; Doesn't this make ARCH_HAS_CPU_RELAX a complete misnomer? Will