From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 8ECAE298CC0 for ; Tue, 27 Jan 2026 20:47:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769546837; cv=none; b=mSuz1PXtUnDeBfQOj0Go5tH4lOanT7OBWDACj1Gx3w9fgRAJl57XrehlBC1s4F41br8VOSkU7H0PW4/yg5564qbkNOAVS2DQTv6c5nr8Wd6c8X7KmzlsvXnGnu+4AaA/R51/jLpCXD6RaAw+QrOK7Frp5fSahtWjuk6m6V7UmEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769546837; c=relaxed/simple; bh=Q1O/+GBbXOYfYaXTxbxbqmTGWTj/y+mjKsnvqcLbKTo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=crxpnNVXGegxiWuODfzUUM7Ai1ZzqK98sA1eWbo4pljt8X1z+7eIyR6YyFaigsnLOKmkx7obFH271YmJezxtejefGwn5OEB4OmCvoyJa/pVXDzojmLt+dgX+ZP9vqGjP/2iZfcEsWpATVpoahiDKw3tOfqnYjvt38XQFI31imV0= 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=D+UMiy2g; arc=none smtp.client-ip=209.85.128.54 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="D+UMiy2g" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-47eddddcdcfso36341845e9.1 for ; Tue, 27 Jan 2026 12:47:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769546834; x=1770151634; 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=Y76INJz49l6c3foMm04ZUQu2Dm0oObzGN1DVFxd18LA=; b=D+UMiy2gT6XUCwF22ZuoIDz5Bc/MoIopZ0tMNjY2eQ7FRz1QGuOVx6xWcziqnd5LfM AsiiBNb2pknTUlV/V+CSvqHqhXbsWY/yMhIrUSIY/GakVMNAQ8w99r8RzIOW9GbDUH91 4ZEyLIoRhNNPFurV/Z+UcJGxPsmzN0XBpJretWSxJOU9OOcV07A9HuSLbPAJ6o9tWCvV YRvTICKd61oQBTdfzneV0bnTZmBmp/KOIs6dQ8HFFJ1eC2uyWk3xrxlefKjphATny453 6L65ck5BLyyduQcGQBl7Klpru4/JyVNI9btiEaxAU7cUOpUudeKqrRFGFCsa+tT8J8O+ mQBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769546834; x=1770151634; 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=Y76INJz49l6c3foMm04ZUQu2Dm0oObzGN1DVFxd18LA=; b=l1hZi+PQv7iMWWKVoK0UK8HeWrtPIhiv11gaxamk0Ztx+iv3P91cZ9eh0o/Rapoijc 64gjhwlS8zqYvPMVguQ7wAaiZon+QQ1L492z2aGkhTeVbADQXGbUhA1fLujjDYT5mICN p5MtnlmeN3deVU26sZEQactAatcJtzj3dOXvz5eFAwfK7RJYZhTWW+wb0HjhnBz3Hm86 5CTKdqMuy+eQIG3I7+uAv9vntiuycnh7UP2hgvZb5zNv4Lpr1fFfEdm/W444nHFsLiSN jZKxAWK3E+N30N7gxLRPMSrjFR2bqOASNHeF5VN36REC4sobXGm+Vh4n+JDHECg5T/oJ SPMw== X-Forwarded-Encrypted: i=1; AJvYcCXOdw+2yJVSmm2Vw/83TDymc5CWUBqvXRodM/e+kba/qFCSi0NAUTYhryIjna/rEmnHnxNcfrcvU9wtCcI=@vger.kernel.org X-Gm-Message-State: AOJu0Yyv8aE6soNpy7qv4FRmcAeuZEr++OOYYxg/r99v34mIPqOhoyWG x8sLlsRiY3AkzyPuOzlmVq0M8BZNRCUg3NpUyPSXbIlz1NzvKSLeA7VP4cjKbQ== X-Gm-Gg: AZuq6aIfm5kC6xdZAGKmHe3pcG7KWTjaE2El7aCV8Sj51mbkScmeS66XQEqRXREC3B7 myDkVG7P0kUtmcYyvq/deIExS00fGWxfwiWjNw+5hb2JGdJQeeeB4kuSzZvZrJFWwozHD4evsDX ObeBXBJ2PrdG0l/ZnO1S7JTT7/w2DhS5CKRIPW/rCZmcUmnn4+knNgYVibhiOJohL0ls/fLh+pK 2Kqes0Y2ysEyWXDQm399tBvtbn8PNRvI7iKg5UK2tl/IOjANl1nC1+rgivKIhsMwb8wr0k+cye0 xzSh5Bs5Xvp9f4kFrXwCcdVjCZggNvz/REjVR0N0DvEpV5zy3FcqD8eie0ZG7M78LInSc8kmHpS 8SxMwdG69IqL7/R5VVRsWA8QSIm4N/d2DHozx8Y+WWj+PBNf4LbUE3qpp5Ln0nxOHbOPGLH7W/Q +J4VCyXt7/EM9vogtYhS/6+iq+RRgzjUfSvxyHyADQgZbUwGHGbEDk X-Received: by 2002:a05:600c:c16b:b0:47d:264e:b35a with SMTP id 5b1f17b1804b1-48069c1a85bmr30848435e9.13.1769540070008; Tue, 27 Jan 2026 10:54:30 -0800 (PST) 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-48066bee687sm126914635e9.5.2026.01.27.10.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 10:54:29 -0800 (PST) Date: Tue, 27 Jan 2026 18:54:24 +0000 From: David Laight To: Marco Elver Cc: Arnd Bergmann , Peter Zijlstra , Will Deacon , Ingo Molnar , Thomas Gleixner , Boqun Feng , Waiman Long , Bart Van Assche , llvm@lists.linux.dev, Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] arm64: Optimize __READ_ONCE() with CONFIG_LTO=y Message-ID: <20260127185424.39d801ea@pumpkin> In-Reply-To: References: <20260126002936.2676435-1-elver@google.com> <20260126002936.2676435-3-elver@google.com> <7478d2cf-9636-45c8-8ffa-8e3a3ba9baf8@app.fastmail.com> <20260127143026.32429f32@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 Tue, 27 Jan 2026 16:04:45 +0100 Marco Elver wrote: ... > I think the bigger issue was 'volatile': "Passing a volatile-qualified > pointer to READ_ONCE() is an absolute > trainwreck for code generation [...]" per dee081bf8f82. > > While the above with the temporary is gone for the asm-generic > version, the arm64 LTO still has the temporary and we need some > qualifier-stripping helper. I've done some real experiments, see https://www.godbolt.org/z/n9f91dGe3 If you don't strip the volatile you get a 'trainwreck'. Visible on godbolt for the short sub-structure function f_v_s(). Fixable using __unqual_typeof__(). But the code for anything over 8 bytes is also a trainwreck. eg: for an int[4] in a sub-structure: return __READ_ONCE(s->s_i).i[2]; f_s_i: sub sp, sp, #16 ldr x8, [x0, #56] str x8, [sp, #8] ldr w8, [x0, #64] str w8, [sp, #4] ldr w9, [x0, #68] mov w0, w8 str w9, [sp], #16 ret (The same code for a char[4] is fine...) For integral types you can get a variable of the unqualified type with: auto v = (typeof(x))0; but that doesn't help here because the code needs to read short structures. For long structures member by member access will give better code. I'm not sure they should be allowed. (and there may not be any.) David