From patchwork Tue Aug 16 13:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12944897 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 92DC1C25B0E for ; Tue, 16 Aug 2022 13:06:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 620338D0005; Tue, 16 Aug 2022 09:06:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 540E68D0009; Tue, 16 Aug 2022 09:06:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BD0B8D0006; Tue, 16 Aug 2022 09:06:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DDF008D0005 for ; Tue, 16 Aug 2022 09:06:23 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id ABF58A10B5 for ; Tue, 16 Aug 2022 13:06:23 +0000 (UTC) X-FDA: 79805479446.28.FBD878B Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id DDD05201D4 for ; Tue, 16 Aug 2022 13:06:22 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M6WY10B01zlVpm; Tue, 16 Aug 2022 21:03:17 +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; Tue, 16 Aug 2022 21:06:19 +0800 From: Miaohe Lin To: , , CC: , , Subject: [PATCH 4/6] mm: hugetlb_vmemmap: add missing smp_wmb() before set_pte_at() Date: Tue, 16 Aug 2022 21:05:51 +0800 Message-ID: <20220816130553.31406-5-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220816130553.31406-1-linmiaohe@huawei.com> References: <20220816130553.31406-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660655183; 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=FuN6T2p2RJ2CpDWMi2zsepaC0Qel6Up9shsoD+jS828=; b=bPjs9DbDpc5FFsFqSYutTEvoQpri6Yg/nlPMSE+jxyqXvY6egkQBkNtd0FcUb0rHyhrPc7 Igqk445lD8uGBDPGskZb67GWTGBwjdUQMv0grrYbrQv0t8XIB99vYDgSNrLuZK0DHn4ezI 4Gx87/M1Mz006OrGA1l8Vw6C1SPXXo0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660655183; a=rsa-sha256; cv=none; b=ohxCBu/NGZhnMDjrvJyTnWaJ+EF7oFFtPbtB2E+6sz0qvdUd4ooufBEd5iuJ3hXCNT3yra AKXJLw5jei/FXBlRzGrvyO+SxYLvBiw4ciY0bYgoh2mepU6omMa+y80eEYINa/Svf7TgkV 3IfjWEkHSANaigBHhYxznlg6Kqz+SIM= Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Stat-Signature: 4r1ygxu1z9z8itr39uikx34m5711x5pz X-Rspamd-Queue-Id: DDD05201D4 X-Rspamd-Server: rspam11 X-HE-Tag: 1660655182-761774 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: The memory barrier smp_wmb() is needed to make sure that preceding stores to the page contents become visible before the below set_pte_at() write. Signed-off-by: Miaohe Lin Reviewed-by: Yin Fengwei Reviewed-by: Muchun Song --- mm/hugetlb_vmemmap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 20f414c0379f..76b2d03a0d8d 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -287,6 +287,11 @@ static void vmemmap_restore_pte(pte_t *pte, unsigned long addr, copy_page(to, (void *)walk->reuse_addr); reset_struct_pages(to); + /* + * Makes sure that preceding stores to the page contents become visible + * before the set_pte_at() write. + */ + smp_wmb(); set_pte_at(&init_mm, addr, pte, mk_pte(page, pgprot)); }