Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1914641lql; Wed, 13 Mar 2024 11:40:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWczbjQasO27EakUJ3tN2Jv3XQBIVFXlm2p6lpgWd4RkcTvEuUzMB6BUq5Oz0CbY9Klo/LliOCWvK7YfUQIeMZIwvgNmy21UijwkvVkWw== X-Google-Smtp-Source: AGHT+IFnY5LbbMyTZCYFJb2b2c/PINPw56sAIXOGG3jLj3qA/VKfR8ufxb/5KhZMIvETFiFZ4RmU X-Received: by 2002:a17:903:1212:b0:1dd:5df5:e6e5 with SMTP id l18-20020a170903121200b001dd5df5e6e5mr5536703plh.35.1710355246444; Wed, 13 Mar 2024 11:40:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710355246; cv=pass; d=google.com; s=arc-20160816; b=WoNJ8XhPRrFWYq/OC88mFNQ9eW0NMkwJW5aFNQ5G9RRrTfH55LYCjKEzYy5mV22MlS AqHhQ47nrNxG2/7lc0GbLQlE/t29Isyr/goKB5H5GXszjnnehKXwUWxJQRuKnqJqA8nl 6bVVtKTgX6SP3YgwDbQUlIzyAru6irBUJZwVvg4lo7qSoDlA/8AOjcboXm1lbHqVZLJG /BlnYPv+ccYRJr5K7iulx2s/QDC177VUQ1DvZ5NbHkVHqkIcGzmDBO7TkBnQxx5gkmVV N02oe4TS8hf/5MZrjW/gSD+HZdH8zYcGsxsEoIZeyMVsZIPHSiyl/N+aAwxthHODYOwt y+fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=meN4TraCAUyhgG0bR4ydRoJvnL+ogtmsnkujDynm3LQ=; fh=C0+KoqgxDQXROR31c7jcR64TwaNfhrQbUzSpsJHtywE=; b=q6nU9cPWDd3g/45T7NybgadlN+ybQModyhqSLwcNe9/K/f8V9H0hly1SeG8PnxbU1n LvFlHo5+H7tzZlvSDtI9v3zUXAruwEgg6GsSklsPsOm2NB+A/JVCGsxV6OILfK05j66v /teQACxEasya4cZYBglTWp5I+sH7IN5OSzj7zpt8w7XQ6ZK3f4qVvygsyCXFYkkYDA1U qmpXlGWxWubCrXzmnsSgqmlyfSGqM8jfp45rMhBVDxtucoIVZGHG0D3ngkX/1W7sLcI6 6yvKlOVxn4NsPokbTxImo5v5PRRlBI38TG7UTnS4+KfsMasyPtQEPVS+wzcvRUMP8A0n jOBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nnNlYLBO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102257-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l10-20020a170902e2ca00b001dcabe98268si9002657plc.419.2024.03.13.11.40.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nnNlYLBO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102257-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 DE6D128C28E for ; Wed, 13 Mar 2024 18:37:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91B6062169; Wed, 13 Mar 2024 17:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nnNlYLBO" 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 AC62950A6C; Wed, 13 Mar 2024 17:21:43 +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=1710350503; cv=none; b=BunFUkTnldBA4bwmGGLS4jnmgCOREFPZzjWAxCG/KcnQvLemnng7zNWnPBXcRENLvAb9yHC46gf/fUsi0QzoIkWxZkaaEtpzQnXaSonpBcO26xmUuqSI/P+LtKykXIoyI4jQacKUsvi1DucRkCKNP6ixhc35MK5Lm4NmJOehgwk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710350503; c=relaxed/simple; bh=2+HrNPQNNrVW2SJnqA5HjU8yBIrVF6D+riwSfpUrNxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lllLrNmlIhNwbQeCPfBLYhD6EZpw3xwwSgYeqMLMcdmRTbV26ZBmeLzH/tdbPQy1/tQJ/8ozHhzK0LfSZYOD/gHOEs1BxqhpKNZ87yQzTkjPS27Hq9uIAtyfGCh4xaubiRuT2/xLriDDTGhh+G9epb6bcKzXW3dygh0D6aPaJnY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nnNlYLBO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB54FC433F1; Wed, 13 Mar 2024 17:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710350503; bh=2+HrNPQNNrVW2SJnqA5HjU8yBIrVF6D+riwSfpUrNxw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nnNlYLBOEBemLClK28M3tirohPxrI8276u9bgKJNFG7AT4s1MUEOQIyZgoGzSD12+ ZvZR4ab6rf/N/GYcd2cEyziyM5H1Nr3IgUNtc5XE310ejJK2Rvpg1N24u5EWuRN/g/ T2Dt7Scnc0QZf2f5qhWSa3pBA3lec6w1jaPeTCj6QwyNVmtgrNgfMG/TAOAq02Qs2D 2n6NvKzuuH/k/Wmf+9ao4Azr0QhIA3vts5c0bYjjTMPOnJCBtYrAPT4KATDTb1YeMt pCTL2EvdQykyihCSponjrJmQyX8TqE8zopRYMDCeHS7Enzt/Dcovtpo+O1XCio1eAo j6VkmEIRpYMRw== Date: Wed, 13 Mar 2024 10:21:41 -0700 From: Nathan Chancellor To: Qiang Zhang Cc: Andrew Morton , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Stable@vger.kernel.org Subject: Re: [PATCH] memtest: use {READ,WRITE}_ONCE in memory scanning Message-ID: <20240313172141.GB3064248@dev-arch.thelio-3990X> References: <20240312080422.691222-1-qiang4.zhang@intel.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: <20240312080422.691222-1-qiang4.zhang@intel.com> On Tue, Mar 12, 2024 at 04:04:23PM +0800, Qiang Zhang wrote: > memtest failed to find bad memory when compiled with clang. So use > {WRITE,READ}_ONCE to access memory to avoid compiler over optimization. This commit message is severely lacking in details in my opinion, especially for a patch marked for stable. Did a kernel or LLVM change cause this (i.e., has this always been an issue or is it a recent regression)? What is the transformation that LLVM does to break the test and why is using READ_ONCE() or WRITE_ONCE() sufficient to resolve it? > Cc: > Signed-off-by: Qiang Zhang > --- > mm/memtest.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/memtest.c b/mm/memtest.c > index 32f3e9dda837..c2c609c39119 100644 > --- a/mm/memtest.c > +++ b/mm/memtest.c > @@ -51,10 +51,10 @@ static void __init memtest(u64 pattern, phys_addr_t start_phys, phys_addr_t size > last_bad = 0; > > for (p = start; p < end; p++) > - *p = pattern; > + WRITE_ONCE(*p, pattern); > > for (p = start; p < end; p++, start_phys_aligned += incr) { > - if (*p == pattern) > + if (READ_ONCE(*p) == pattern) > continue; > if (start_phys_aligned == last_bad + incr) { > last_bad += incr; > -- > 2.39.2 >