Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp964174lql; Tue, 12 Mar 2024 03:33:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVRr7/XNWqAnakIEzkXQptNeF9wnuFj8eZ4Dr2+HR0Y4fuyEHCxIXJjMn/7DAG/7vdNlwSG69AKlOHBKYNs93fzWzpTO8aHnvPoR8F2Q== X-Google-Smtp-Source: AGHT+IF4ciFx8Naumdldpx0BWp38KMgFiItYd80SjMzVK6UNro09eoh4pv/QQ/1qXGB4ehylLBfO X-Received: by 2002:a05:6358:5248:b0:17e:53f9:697c with SMTP id c8-20020a056358524800b0017e53f9697cmr8628089rwa.20.1710239592046; Tue, 12 Mar 2024 03:33:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710239592; cv=pass; d=google.com; s=arc-20160816; b=QxuRLKP0Sa+oLoBMT5P1Dyerdx6qUqINUCWEmu8h8W9oGXaPh1Y7xbg1vgYXTz+PoT Q8e6C52UoEkpFah1FOYBIAwjsRl6Mro0+g90IZWk8n6k1QDZBdQZBNgEVBDFYC2VPTcl fANZ1AHhvsFFGBIClTsJwhycXWulNJYxOJvJ97MT6HsSvlsO7OQfkI3nm/KvPx4EoZOz /u4nRKvTVQEMYXUNPfGo9i2d4/+W3/UGYQHM7xiUjl/f3y+KJGBXm/InTADZNi/cVYTS jErlruglsT7kN7oCUWU9lXEZu2W8h27uq1s8x5sK5KlqcDu4vhvltmxgxFQvkdbhCCXt Pkag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=NjUAdbT1WBF00uAyVT+azawNxlUW3vgDNAb4uqjbraQ=; fh=Wl3OE5LeKWJBntrONcaDvpLb7bd5yJo+ppKMUoHXnWA=; b=zl0nTxqAuofMxIZLit7Vx71WAOJtzemQ2z5C6PPt1e0XZh/MXyCF6zRJhVSy2Mnamq K1bf2d3jVeO3oPh1d2SE2xSIhNO4kW1qVLqybxS1XiSiIuoljgJCI1Bqj9Lr2OcJ2Eap kSpiHO/ozh4kqRfqZx5mbZXHPXa83t0w+vihNsY16tMmDA/x88/S30CihydcHUANEk0/ kbZUPMvPmUH+4cNGFMLpazgy4VaokMHIjGIxoIJARLALU2XVFs3zVAH9JngLac4asp5X 3VWjSYU7B8S5EURO7yQyU3kpmb3CcJQpNia9qqIwFgUmrLlpIa9JYpMK+thw7hDnoPEp 3/IA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nzZN5mtv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-99936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i1-20020a639d01000000b005dc556a8765si6925961pgd.466.2024.03.12.03.33.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:33:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99936-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=@intel.com header.s=Intel header.b=nzZN5mtv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-99936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99936-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 8C274281DC9 for ; Tue, 12 Mar 2024 08:05:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95FB869DF4; Tue, 12 Mar 2024 08:05:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nzZN5mtv" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 3239D69D01; Tue, 12 Mar 2024 08:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710230729; cv=none; b=Ar1wNXfJexzNVgSmUqmKN4Kyqd92aMatGToeAwCd88Vs+yzDxCp6s5rBxVX7j6WyaWZIKzpvHwqYR3R0PGuUfwTo9sYZlUf9W2jY/rnK5AQNEMx9WS28Dh+DLY4I48hfMxFL7x5Uap/NEZmET6fHlTP+BVveMArtbFNF/nl87zg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710230729; c=relaxed/simple; bh=ZGEVlJ/kaJVd0E8jYAG2DeF+zHotxbyxow0UORgWJEs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=GF0hUMxQeFfIyz2djOibgGlFp43b20llN+oa1idX28hCo+zqcahS7YFqjcrsSNK+qKJmyWz2FvK9fzUGqpSMTt5pjo7YrQSWSdzmxGtwhA9wJDmsX1UglA/h22urcIXB/7DURip3b3UhMDh1QtzRVqD7C9M593OWzLkSr3X5zAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=nzZN5mtv; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710230728; x=1741766728; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZGEVlJ/kaJVd0E8jYAG2DeF+zHotxbyxow0UORgWJEs=; b=nzZN5mtvVWMMfEjLfqLh5rSSt61Sk3cMw76OFkZLauotveCBa84RELz3 8x/n01blZAK2tgxVrGPfLMdBViiCj3Vl3BPlEkTiSEO9J4nIAeoZvaGCg /dDABe5qoDiWt4GwkS5WtC9shD/s4+hXOqqbUshj2ZQxSLhx6QP/4KNYo 4Fe2um9ctgKQWJc1wsSXxDQ7tM+9MQ3RpsbuDY3RIKcZ1bvbjH5kqA1NF lFr1WDqCy49QKP3Ni7kqfOo6rjx4Y1JfEDX3mB+5hC+qigQ+kC3MeFQVq iTAfROEgHxbrynoz4sihMlMuy+OH7YqOjwHfPc7H8CplsG1OTnzlHobqG A==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="5112973" X-IronPort-AV: E=Sophos;i="6.07,118,1708416000"; d="scan'208";a="5112973" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 01:05:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,118,1708416000"; d="scan'208";a="34631465" Received: from qzhang4-desk.sh.intel.com (HELO localhost) ([10.239.147.49]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 01:05:24 -0700 From: Qiang Zhang To: Andrew Morton , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Qiang Zhang , Stable@vger.kernel.org Subject: [PATCH] memtest: use {READ,WRITE}_ONCE in memory scanning Date: Tue, 12 Mar 2024 16:04:23 +0800 Message-Id: <20240312080422.691222-1-qiang4.zhang@intel.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit memtest failed to find bad memory when compiled with clang. So use {WRITE,READ}_ONCE to access memory to avoid compiler over optimization. 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