From patchwork Wed Jun 22 17:06:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12891183 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 8023DC43334 for ; Wed, 22 Jun 2022 17:07:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 603FD8E00D1; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 541058E00D8; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D36A8E00D9; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 119408E00D7 for ; Wed, 22 Jun 2022 13:06:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EB510355B3 for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) X-FDA: 79606501548.03.90C0E1D Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf30.hostedemail.com (Postfix) with ESMTP id 654F7800B2 for ; Wed, 22 Jun 2022 17:06:54 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LSqT36mZDzSh9m; Thu, 23 Jun 2022 01:03:03 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 23 Jun 2022 01:06:28 +0800 From: Miaohe Lin To: CC: , , , , , Subject: [PATCH 02/16] mm/huge_memory: access vm_page_prot with READ_ONCE in remove_migration_pmd Date: Thu, 23 Jun 2022 01:06:13 +0800 Message-ID: <20220622170627.19786-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220622170627.19786-1-linmiaohe@huawei.com> References: <20220622170627.19786-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655917614; a=rsa-sha256; cv=none; b=mR6BBgFmiu8rTi6EL1vjhLfHcrm4frIR1gtVfmN4es8kYP5MuEKJidM/fg7iLmDOI+0PWT 8cpYOqpr+oP6VtonVTbQu+zGB1aLihJxcBPBzLtusmYvcFYIQ07xbY6XKUJsSLSBtj33rq bef0Gx7tj20bsNnoNiamn8S32Uo9JOo= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655917614; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2Xbl29GIhuxqCtpYlDQLHpFA7Fv96sx7/11+jwKcu40=; b=8lOI0pQy3ORSi63wtBWd3OeE3iELaHmMlWuFqgKURrW3F8hi17LdgreIfrH4O9og/WS2gh EbOLTaLe5GxmGpxlPetReszXYJ7iMWPempmFExYkP9VQZC3gF7/Jsmp0xEov8bjkcbRtzS yERpayaxDUfXD86xlyrRw2HHsn5Op3U= X-Stat-Signature: 1b45xi7dgq465z4rb99oku7m7onih9c7 X-Rspamd-Server: rspam06 Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Queue-Id: 654F7800B2 X-HE-Tag: 1655917614-659361 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: vma->vm_page_prot is read lockless from the rmap_walk, it may be updated concurrently. Using READ_ONCE to prevent the risk of reading intermediate values. Signed-off-by: Miaohe Lin --- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index fd6da053a13e..83fb6c3442ff 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3202,7 +3202,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) entry = pmd_to_swp_entry(*pvmw->pmd); get_page(new); - pmde = pmd_mkold(mk_huge_pmd(new, vma->vm_page_prot)); + pmde = pmd_mkold(mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot))); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); if (is_writable_migration_entry(entry))