From patchwork Tue Jan 18 23:05:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12716972 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88918C433FE for ; Tue, 18 Jan 2022 23:05:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2C776B0072; Tue, 18 Jan 2022 18:05:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB4D56B0073; Tue, 18 Jan 2022 18:05:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D558B6B0074; Tue, 18 Jan 2022 18:05:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id BF7A56B0072 for ; Tue, 18 Jan 2022 18:05:52 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6702095B14 for ; Tue, 18 Jan 2022 23:05:52 +0000 (UTC) X-FDA: 79044942144.16.D76B257 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf31.hostedemail.com (Postfix) with ESMTP id 1B5DB20004 for ; Tue, 18 Jan 2022 23:05:51 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id v70-20020a25c549000000b006130de5790aso1209619ybe.4 for ; Tue, 18 Jan 2022 15:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=l6hbRAzMlKkhDXyQqtvv9DAL8rlD+/FgUl4MA5CnPm8=; b=nKkhAP96OCYA4M4x80g28cPG8G8ErsxJaS13Ynx/835zUQOktZxpfEllu14SNaW6ZN qXjKLzaRdYhy9PJXVwbP+2Jf1b9hP+lSMPoBwidlUYmXQWDyTWVpJInj3fq7WDafuxTa iIoMeNcwjnN6Ys6MwD+AtzizkCx/n3FuS7igc6T6IDDeJFG6FQ777u1Qd2e2Lzw62juQ 5JRnEs8RrSNVwLs7Y+HjIBoRj9LPNtc4cLGAxoZ+I0F6hnJ9Xco3AK9rmu4dY5TIwj4G GtXcDJ7/CuGC+07RaUPJ0D9cxTZnpUu/BKnZULfy5igYqfOQlEk7iMU8tfsSEEyXIhRU O4dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=l6hbRAzMlKkhDXyQqtvv9DAL8rlD+/FgUl4MA5CnPm8=; b=vpYuc2knalmHtsay1lMOpsdRo5kdpotuAy4UFm7tajludrrRhjKMGlMBvcb6Z3nyDW jxkBET3nqFRw9smIdr3yY/ulcJ+OdMcezAMKdkpsPVZVRtsFC62NuttRP7G2F13t8z5j Iw+shxfBDrDiSYNK81fbfPHg9fzERNOypY9U8C+vemeW5bJE3j09t2f2QhspkJRqZqPy yaZBaVEaL3wWYd3X6mLRm+Hj1wOiAQQaBdoC2nWw/tPeJTYPmijfEQnGPeWaliXUw3rh WQpRKkDNRhoHpBg1s4HKs2MKNIyGdPr/I7Y+Q38OmYTN92vcclc9ZbhXxNGyTxhfvjiR Qr2w== X-Gm-Message-State: AOAM531PbjCu3FSRFGvGPtUVyjkyNlBrtnrMmO+cZI3qzv8fC6hrDadn ZjqggcnZVcnKlk3VIsJFZqU9M5A= X-Google-Smtp-Source: ABdhPJyPdrj4Y716RGRIKh5U4LkCBP0FlJ7hNEnEfsKuQQvudDZBs5KtsbgYz/GzyiJmv9fnRvg5DBM= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:1443:965d:6393:cd60]) (user=pcc job=sendgmr) by 2002:a25:a047:: with SMTP id x65mr37555287ybh.370.1642547151356; Tue, 18 Jan 2022 15:05:51 -0800 (PST) Date: Tue, 18 Jan 2022 15:05:39 -0800 Message-Id: <20220118230539.323058-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH] mm/mmzone.c: fix page_cpupid_xchg_last() to READ_ONCE() the page flags From: Peter Collingbourne To: Andrey Konovalov , Andrew Morton Cc: Peter Collingbourne , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Mel Gorman , stable@vger.kernel.org X-Rspamd-Queue-Id: 1B5DB20004 X-Stat-Signature: 5ium4ji55oqug7ehmpme9j1hnsi463cg Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=nKkhAP96; spf=pass (imf31.hostedemail.com: domain of 3z0fnYQMKCBI7uuy66y3w.u64305CF-442Dsu2.69y@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3z0fnYQMKCBI7uuy66y3w.u64305CF-442Dsu2.69y@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam07 X-HE-Tag: 1642547151-188453 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: After submitting a patch with a compare-exchange loop similar to this one to set the KASAN tag in the page flags, Andrey Konovalov pointed out that we should be using READ_ONCE() to read the page flags. Fix it here. Fixes: 75980e97dacc ("mm: fold page->_last_nid into page->flags where possible") Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/I2e1f5b5b080ac9c4e0eb7f98768dba6fd7821693 Cc: stable@vger.kernel.org --- mm/mmzone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mmzone.c b/mm/mmzone.c index eb89d6e018e2..f84b84b0d3fc 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -90,7 +90,7 @@ int page_cpupid_xchg_last(struct page *page, int cpupid) int last_cpupid; do { - old_flags = flags = page->flags; + old_flags = flags = READ_ONCE(page->flags); last_cpupid = page_cpupid_last(page); flags &= ~(LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT);