Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp557402rdb; Mon, 29 Jan 2024 10:17:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhsjLDG5gdk0wgVuAmvEcOkEB0FyKYX2mwsHU9/zgSn5Ej4jP1RAow9HIz9bTHwHeUuD49 X-Received: by 2002:a05:6870:4414:b0:214:2c3f:4427 with SMTP id u20-20020a056870441400b002142c3f4427mr4827096oah.11.1706552224131; Mon, 29 Jan 2024 10:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706552224; cv=pass; d=google.com; s=arc-20160816; b=HXZxNLByLQ8D7dl/MKANCv9N1SSce+i0DyQs+hxy11h1LRqPFjPFH35EIuajAoV4sS 5Vlq7e1f/+21VmjP9HI7bZXayKoZ1rkeefVH04CCIuQx6zidMHnlDWTTrQBd9JV/7XXE ddXUSbevyx8CnhDGtiSCPgTwvFX7IvUjdfzbVZxt1zmMhmKahVe5ZxyjYu6Rz6v+uToR qt/sZgzBgUc+agd5jxTGVqkl7yIR1lvSdVak8NLoIAJtEdnbQXXRpISBtdCW73ogNIfL DKqeUZm+6lByYYB/tX8W48sDXpCnp6FwysONkAO1VWYlaoJ1X0aIVkOwCX5/RoSnJrAz Athw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=if5g6iBM6OYvLZX1cggbZGx12/dsyuKdvsMNw32Uq0k=; fh=4nyO7PGtLkP04b9NIOsI30yIkzZNwyj8CnFSrTjxW2E=; b=R+PKENAXQCOVPy7mxbETSisHt9UTYkJpmyz3rhGyt0wOGUC9ZD3MKgg/mif4do1AOc pZAlX/lSluPu+BkcpkfAPqsHXgn0Y21Lyvfc0Xt2LNJ9viUENf6qmnW9fVM5ZRTQBxis s6ETVcg8YZuJIYgya6iTpdEMFWw0E1agHbL7zBgN03bTLpWsHAWSpMuvFV73f4ls5Pff x3qDcN2dfYkBOtjprmCyeeeH+kARjo7lIxM+3qn+eFNHJrBjB2qW6ntylzZgY+fBkUJB NImak6cpFS29QH6NKcXvZYxhXqevktwM7UKiv0uhR2PkabKOigujIEEYaJ4Do5qc8yZw M/Cg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pPW3f9Sj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43299-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i63-20020a638742000000b005d8bb454c27si3762098pge.446.2024.01.29.10.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43299-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pPW3f9Sj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43299-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 92DA6282A7F for ; Mon, 29 Jan 2024 18:16:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A64F16F08B; Mon, 29 Jan 2024 18:15:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pPW3f9Sj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C52BF3F9FC; Mon, 29 Jan 2024 18:15:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706552156; cv=none; b=C8Y/dBnbLQZWJjvqbdCMo7tnIX1Y2YxRngXsNE+16Vr5UXFgjiZwdwc/p5zrnt8ZQFDFutJr6s5j5dqyPuqF2UF/BuUXhtakXVtOvVg3cHveU1yU9PC1SnL4aLpUDnGlVFPJis/5hvYxrSM84y91F9BoqCtMQ/JabHqijGZ8ys4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706552156; c=relaxed/simple; bh=HtWWFC71BCavDoQvTNSF5iID0oN+lBFa3TU2UQoctyw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E8AFEhOnkF67a/wpCQHKKde5gWxqYTx+xDqcdg9xAG/T56xjCRxaYDeUOs0Ovm973YFQNBZ5CVYw6bkVK8G4IbgwWvpyxaeTa2Amt+wver0u4Rs0me3J34Bq61A4FEOt7CNAk0jUI0PUjbo6xHW6XB4jLoajOk2hAplh90odN+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pPW3f9Sj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A849C433C7; Mon, 29 Jan 2024 18:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706552156; bh=HtWWFC71BCavDoQvTNSF5iID0oN+lBFa3TU2UQoctyw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pPW3f9SjldNx036oVfr2mb7rF/1uWtZ+8laYPTJFddNQu22KfZ9+JSUv3x0Zuw9Bs Zg59bttwt3Mq13HLeF7PE+CdppqGpDgui6gYfX2F0YP/bMAsrPRvM5xTKFMs/xgxq0 AKs03jubjF5XETb+5vpA4ubGccF/LgcfoHaiv9vPYmZcxEq+QxwuBLK+1qOOKyz2hB bDObKuNdlKVq94bl6KJx3hVJOl9w6th4nhM+Xg7uZ9cxQowb+FA6/48N6cVWwyJpPH Cya7zQern418k52+XIWRSXC9HRRO//yRjqbXG8Ogd0pMHsMRLRIJNPE8O4O6X4juuj UDdExsudUOJfg== Date: Mon, 29 Jan 2024 18:15:47 +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: <20240129181547.GA12305@willie-the-truck> References: <1700488898-12431-1-git-send-email-mihai.carabas@oracle.com> <1700488898-12431-8-git-send-email-mihai.carabas@oracle.com> <20231211114642.GB24899@willie-the-truck> <1b3650c5-822e-4789-81d2-0304573cabd9@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1b3650c5-822e-4789-81d2-0304573cabd9@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Sun, Jan 28, 2024 at 11:22:50PM +0200, Mihai Carabas wrote: > La 11.12.2023 13:46, Will Deacon a scris: > > 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? > > This controls the build of poll_state.c and the generic definition of > smp_cond_load_relaxed (used by x86) is using cpu_relax(). Do you propose > other approach here? Give it a better name? Having ARCH_HAS_CPU_RELAX control a piece of code that doesn't use cpu_relax() doesn't make sense to me. Will