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 C5A4CE9E31B for ; Wed, 11 Feb 2026 15:40:01 +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=bGSEUeAMENP4be6s2i3paIEHHNF6/whysqf6hjNnA/c=; b=eT629TCYBeR/+0RPMUsTAjrEBT 2BPpAWq1nWewg1B/BnoRdXnzIsCnnu368BGGiBjcNtKP7prBcDBndu8W/4887djK7cc4y24hX8Cgh hDilgYhoRBkPPtG6k11twRnti9uL3E/EAwKMb8qZUkk64Uy+1Ljl2iN97lXuDIv3CnKgeT5lDUJnv SoVEpsdLSJwMkddvrYq4TmwpdhAo0UjMZGHjDGX27yqknMuaAfY9ekLu/bsO36YC3gKHZ1hIVSfBT YMEuJPFw9bDv1bk6sznsbc/+VZNxJdSQ8GdLk3zqDWwcVtsXtQvOErw5/Jb+Va+vb+8OdLuMV+fqj oaFDU6IA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vqCJn-00000000ndS-0YxA; Wed, 11 Feb 2026 15:39:55 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vqCJk-00000000ncW-2UOW for linux-arm-kernel@lists.infradead.org; Wed, 11 Feb 2026 15:39:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A4F17497; Wed, 11 Feb 2026 07:39:42 -0800 (PST) Received: from arm.com (arrakis.cambridge.arm.com [10.1.197.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45E503F63F; Wed, 11 Feb 2026 07:39:45 -0800 (PST) Date: Wed, 11 Feb 2026 15:39:42 +0000 From: Catalin Marinas To: Ankur Arora Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, bpf@vger.kernel.org, arnd@arndb.de, will@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, mark.rutland@arm.com, harisokn@amazon.com, cl@gentwo.org, ast@kernel.org, rafael@kernel.org, daniel.lezcano@linaro.org, memxor@gmail.com, zhenglifeng1@huawei.com, xueshuai@linux.alibaba.com, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Re: [PATCH v9 01/12] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Message-ID: References: <20260209023153.2661784-1-ankur.a.arora@oracle.com> <20260209023153.2661784-2-ankur.a.arora@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260209023153.2661784-2-ankur.a.arora@oracle.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260211_073952_671651_4EFEBF7B X-CRM114-Status: GOOD ( 20.92 ) 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 Sun, Feb 08, 2026 at 06:31:42PM -0800, Ankur Arora wrote: > Add smp_cond_load_relaxed_timeout(), which extends > smp_cond_load_relaxed() to allow waiting for a duration. > > We loop around waiting for the condition variable to change while > peridically doing a time-check. The loop uses cpu_poll_relax() to slow > down the busy-waiting, which, unless overridden by the architecture > code, amounts to a cpu_relax(). > > Note that there are two ways for the time-check to fail: the usual > timeout case or, @time_expr_ns returning an invalid value (negative > or zero). The second failure mode allows for clocks attached to the > clock-domain of @cond_expr, which might cease to operate meaningfully > once some state internal to @cond_expr has changed. > > Evaluation of @time_expr_ns: in the fastpath we want to keep the > performance close to smp_cond_load_relaxed(). To do that we defer > evaluation of the potentially costly @time_expr_ns to when we hit > the slowpath. > > This also means that there will always be some hardware dependent > duration that has passed in cpu_poll_relax() iterations at the time of > first evaluation. Additionally cpu_poll_relax() is not guaranteed to > return at timeout boundary. In sum, expect timeout overshoot when we > exit due to expiration of the timeout. > > The number of spin iterations before time-check, SMP_TIMEOUT_POLL_COUNT > is chosen to be 200 by default. With a cpu_poll_relax() iteration > taking ~20-30 cycles (measured on a variety of x86 platforms), we expect > a tim-check every ~4000-6000 cycles. > > The outer limit of the overshoot is double that when working with the > parameters above. This might be higher or lower depending on the > implementation of cpu_poll_relax() across architectures. > > Lastly, config option ARCH_HAS_CPU_RELAX indicates availability of a > cpu_poll_relax() that is cheaper than polling. This might be relevant > for cases with a prolonged timeout. > > Cc: Arnd Bergmann > Cc: Will Deacon > Cc: Catalin Marinas > Cc: Peter Zijlstra > Cc: linux-arch@vger.kernel.org > Signed-off-by: Ankur Arora This series evolved a bit since last time I looked, so going through it again: Reviewed-by: Catalin Marinas