From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2887D1D88B for ; Tue, 15 Oct 2024 16:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yJb2dfw75Fv4JMlsF3wsRVDBRmphvawVOQv08sa/AL0=; b=gwwcPFwHxew7OWKfj8Fj0BzAj7 gBwsxJhlvgXCVMbgqrvDhIlmYs5ZPXQzxGheOJCjOgwS4eQ+1BevSP5U0kwObveXqf/l6TWYewAtB Iz0Mjbo/H9DXVk7SPuYogCI1VSyCU+txDFouSF/7OmFyZWMw8IxDxGAOh97KXeeuYGEN89H4j29ad ZcNF17xXK+5VIYm8wkl0am+Ee+jhAfX6eJwM5gguL1mt+zRUcn86K4IHJgDgJL8Z4IXw8yYCdNzca H7Gush37jEC9GPhN1oxvXrwzRW+9TdNQz3c4IV6F5Xdg4xxMnwxFcmGbXbFhhZ2phq+USm/6kBKdC X9Xz+/hA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0kmg-00000008wU4-1kzz; Tue, 15 Oct 2024 16:52:34 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0kl6-00000008w0x-2bMG for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2024 16:50:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1B6135C54EC; Tue, 15 Oct 2024 16:50:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CD95C4CEC6; Tue, 15 Oct 2024 16:50:50 +0000 (UTC) Date: Tue, 15 Oct 2024 17:50:47 +0100 From: Catalin Marinas To: "Christoph Lameter (Ampere)" Cc: Ankur Arora , linux-pm@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, pbonzini@redhat.com, wanpengli@tencent.com, vkuznets@redhat.com, rafael@kernel.org, daniel.lezcano@linaro.org, peterz@infradead.org, arnd@arndb.de, lenb@kernel.org, mark.rutland@arm.com, harisokn@amazon.com, mtosatti@redhat.com, sudeep.holla@arm.com, misono.tomohiro@fujitsu.com, maobibo@loongson.cn, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Re: [PATCH v8 01/11] cpuidle/poll_state: poll via smp_cond_load_relaxed() Message-ID: References: <20240925232425.2763385-1-ankur.a.arora@oracle.com> <20240925232425.2763385-2-ankur.a.arora@oracle.com> <086081ed-e2a8-508d-863c-21f2ff7c5490@gentwo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <086081ed-e2a8-508d-863c-21f2ff7c5490@gentwo.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241015_095056_726191_DCF7F206 X-CRM114-Status: GOOD ( 19.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 15, 2024 at 09:42:56AM -0700, Christoph Lameter (Ampere) wrote: > On Tue, 15 Oct 2024, Catalin Marinas wrote: > > > + unsigned int loop_count = 0; > > > if (local_clock_noinstr() - time_start > limit) { > > > dev->poll_time_limit = true; > > > break; > > > } > > > + > > > + smp_cond_load_relaxed(¤t_thread_info()->flags, > > > + VAL & _TIF_NEED_RESCHED || > > > + loop_count++ >= POLL_IDLE_RELAX_COUNT); > > > > The above is not guaranteed to make progress if _TIF_NEED_RESCHED is > > never set. With the event stream enabled on arm64, the WFE will > > eventually be woken up, loop_count incremented and the condition would > > become true. However, the smp_cond_load_relaxed() semantics require that > > a different agent updates the variable being waited on, not the waiting > > CPU updating it itself. Also note that the event stream can be disabled > > on arm64 on the kernel command line. > > Setting of need_resched() from another processor involves sending an IPI > after that was set. I dont think we need to smp_cond_load_relaxed since > the IPI will cause an event. For ARM a WFE would be sufficient. I'm not worried about the need_resched() case, even without an IPI it would still work. The loop_count++ side of the condition is supposed to timeout in the absence of a need_resched() event. You can't do an smp_cond_load_*() on a variable that's only updated by the waiting CPU. Nothing guarantees to wake it up to update the variable (the event stream on arm64, yes, but that's generic code). -- Catalin