From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7964935FF6B for ; Wed, 25 Mar 2026 20:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774470243; cv=none; b=QtHpAjsD4XGOTQtXgy+ht0E+hbraJuaLp1U3wL87EJv8jwHGk6375yhxDxomLWt1/sc+CmXm6rzS8C5TsY7eN1e0MOA0y2GUIjIjIrN8rvXxlrebg51DDsIna3ETy9kReEkENJLDYibRdFayN8TMxQH2g2Ww3w0qTO7U+T9rPSs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774470243; c=relaxed/simple; bh=yLQmvGZ9qUpeV/RlqPnpEBWWJVhN3ND5IbWmVgrZ9hc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q50B+9Jg8KUDjwPo9oaoWT2FPE9RrHssAsuO0E4ZuLzVa+M70pX8FtOJmtj+6nSE4wv3Viayo4VbSh8mT6H+qY1ou9RwNcfIJ/WHioRecoGBBoyVr0+KiyVk2zyOBRgtCIzvpt0Bl6gcIFy19ZIq60kzerRCnHmaXZQDy/R6K3U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ud6j+46n; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ud6j+46n" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-486fba7ce4cso2826265e9.3 for ; Wed, 25 Mar 2026 13:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774470240; x=1775075040; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=gXPaSk6rOeSHzsuBeOwJ4iqoWQAtJOAov6388j1L0Ko=; b=Ud6j+46n3VJTG/W17THyEbW2e7ncYy5oZMQV/zIS4NWA6K41fRt8pGOa0mZHDls0Ho tAnoqx818c1OPDdszo6POX6hDOYA5MArxKOD2ks9ohbhzsbtLhMB5E0f48+qcmtHQXdB cc5+wW5wrEN449Uvk6PsvIiXxs65BeCk8dbppKk6rhVegLfzFq2mWRvqCt5WfZhDis6z YYIJMMc4+ONjPnmSe+46jOZZsxQDb42mcXES6s7IRWpwHayST7GJxYc2Iat7rCJmgwoh wdrKmBfOo3Zvu8butllgBCGlzd7zAlmaEKqr+RaBLjpIuaVI+C/Acsezbh155UecLcaG gqSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774470240; x=1775075040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gXPaSk6rOeSHzsuBeOwJ4iqoWQAtJOAov6388j1L0Ko=; b=Y7/oPP1rv67TtB+iN+IwE05Thgh1U4Wakd4af0C73zcXveBm5UT6eQZlDp58OtG6S4 datMqL/I5LPA2awBSudvTxcs6tiF0nOhr6l4Fxqk7EJ/kPF7jCYO6/C7CDKRYvbBs4qE tcc6D8BGdqBPfUMrbUnD1l3sjUURY+BBGVVy6D5DDONrpzTZqdUKCTpU+GRk4uBjBtdg JG16HsZoIqg4poo1uH3eeFpDzlbtZJAMd4v0+sqb4+1IzB7ZbgeHAxYUELtLU5GF4oAr z4vCKFLt5hfMDWhOdiDUXXP/qAykbYJz0CwzNsbK/8sYgEmZefXrANKpH7HRGs87mmN8 80Sw== X-Forwarded-Encrypted: i=1; AJvYcCWdXQqaBAPA5DUMhKFeZWEuryFOiF6o4A+0FV3NP8XMvdJN70eESh2gfum/VNYXE37hAKN8/EFC9J8qIMk=@vger.kernel.org X-Gm-Message-State: AOJu0YxvCcIoH0/t+yQgiYIF9VdWRw2tXfAfq4gCiMsFjZoCUIVfoiqT 59KhvHBX3ztSoRBy69UKnVLjp8cSxzIrVKnpqK3UWOuhTZrsepe+Dx/M X-Gm-Gg: ATEYQzwuTFmJP2a2/Mgder/qfjX7x1GT8yetuNY3jh3z5skr+qxiWXByKRJeNKuCNMj +iuNnrxy62wepso8TREcapcyMQ5USvvawsIz8iUse1VG6FqkH3uJwRf4tuh+rOMmH5cj7sL4eCB BR9EFdSSuKUwmhmOgFlmqxH1I+fT46WVwvt9PknxIsK8oI5HETYmQL6Tg9frcelEYquKiin89pF HEkS33M3eZFGMxJwcYQV6hlvkc5L9f3AdU0wbk4RgPLf2ug2IalNNLsyaEu2xjyTXHeIBihCXbN MMH46ivgLoDAHPYnN1ZSdV1bTcRaDvkueRA5lr17ycSXqu5kCa8BWbPUNXdeLJ+j/UAO329Y59f Ke12rJXrHqnb1yvBnHwPTPPEEurLKN7TnWdFFDwjcFWxm3YPzuxG82vONhasKcwB3npr1i18ZgR nnnHnGXxglIWDlUPwVyiizr6E2nzRit5O4XqKy8EC7htaktNDP+xu0fUMaoD2NOW01 X-Received: by 2002:a05:600c:4685:b0:47d:8479:78d5 with SMTP id 5b1f17b1804b1-48715fc38e8mr75859145e9.7.1774470239711; Wed, 25 Mar 2026 13:23:59 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4871fbca47dsm2239685e9.1.2026.03.25.13.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2026 13:23:59 -0700 (PDT) Date: Wed, 25 Mar 2026 20:23:57 +0000 From: David Laight To: Catalin Marinas Cc: Ankur Arora , Andrew Morton , 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, 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, rdunlap@infradead.org, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Subject: Re: [PATCH v10 00/12] barrier: Add smp_cond_load_{relaxed,acquire}_timeout() Message-ID: <20260325202357.3e203314@pumpkin> In-Reply-To: References: <20260316013651.3225328-1-ankur.a.arora@oracle.com> <20260315184925.b6f93386e918ca79614843e3@linux-foundation.org> <874imftol4.fsf@oracle.com> <20260316233712.7cbfac27@pumpkin> <87ms07rlp9.fsf@oracle.com> <20260317091705.5a64fc56@pumpkin> <20260325154210.79a621df@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Wed, 25 Mar 2026 16:32:49 +0000 Catalin Marinas wrote: > On Wed, Mar 25, 2026 at 03:42:10PM +0000, David Laight wrote: ... > > Looking at the code I think the "sevl; wfe" pair should be higher up. > > Yes, I replied to your other message. We could move it higher indeed, > before the condition check, but I can't get my head around the ordering. > Can need_resched() check be speculated before the WFE? I need to think > some more. I don't think speculation can matter. Both SEVL and WFE must be serialised against any other instructions that can change the event flag (as well as each other) otherwise everything is broken. Apart from that it doesn't matter, what matters is the instruction boundary the interrupt happens at. Actually both SEVL and WFE may be synchronising instructions and very slow. So you may not want to put them in the fast path where the condition is true on entry (or even true after a retry). So the code might have to look like: for (;;) { VAL = mem; if (cond(VAL)) return; SEVL; WFE; if (cond(VAL)) return; v1 = LDX(mem); if (v1 == VAL) WFE; } Definitely needs a comment that both 'return from exception' and losing the exclusive access set the event flag. The asm probably ought to have a full "memory" clobber. Just in case the compiler gets lively with re-ordering. David