Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp178640rwa; Sat, 20 Aug 2022 01:27:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR4j0isi7GS4R44L+YUCqw185BwKsvDTBGjsWLlsZEbfasSFBSg02uJu2sV/xru/cLNNYcUq X-Received: by 2002:a17:906:cc0e:b0:731:6843:c198 with SMTP id ml14-20020a170906cc0e00b007316843c198mr7236036ejb.507.1660984052542; Sat, 20 Aug 2022 01:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660984052; cv=none; d=google.com; s=arc-20160816; b=yyJNIhp9LKtoLsIQaA15nUYuYSVrMQIbEZdhGZ18yuPt5XY0SVgEkUQz1TqVk8Ol5F ZHOVRDEvl8v63GNiWm/8U7aMVDOew9qboCvTbRrZ2Usgml4zXTGtfL80TRhr4sMITBN/ wsox91Vi4bFRgJk3L9e/rqNiEhDL7Zse4SeRYzhDYD7nC8M/kGbr89JRE2czMTJtW44K iinYSdao7M/LckjvCeZheLR7D08xRLE3Bi+b2AmCCbolVWTPEa71ySQFP9HYIO9e/ZKf 8hsI4MG6MyCgx/jBI3opqsqqceL8oXA2rVcNx6673GAURmjT5ZQsyUE5FJxP+RJMrd7x GPVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=uROXnR0FNbtP4K5lfGfX+GsQclYXLCvip69kr6fv6XQ=; b=XNGkB045GGxuAq9S2Qqe3AwxWeA8nk1/oogx7CN89gG6LuTjfX2oTCc2QkrvG9txjy 4GOmRV/5wtE66u+hM0HGvp4FBxOtIGqpuBLeslh4gPctWibYqGwDXsYXsJEBswk7yjrU NXxiFRmiwNLLUUNLHbPCLyuyY2nYcM04F3ul1Ex3aEMtCH8lguIWOxUJ6RgQn6mo1Kqi SekNjMFiltzijNlvPMWqYXPojTqAcVOFkpczCIklpbq6Pa88bybD4QTLSKis7ZLOmNq5 M8Zhlf3pXQQQnKZafxwZAPlQtI69xDiN1O8O1nFGRJUNn23vdp5HO09OKVa5594EsQT/ Sieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=t1mwDFk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l26-20020a170906231a00b006feba25b350si3712219eja.106.2022.08.20.01.27.06; Sat, 20 Aug 2022 01:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=t1mwDFk5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344199AbiHTIMO (ORCPT + 99 others); Sat, 20 Aug 2022 04:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344076AbiHTIMM (ORCPT ); Sat, 20 Aug 2022 04:12:12 -0400 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D10BBA9C0 for ; Sat, 20 Aug 2022 01:12:11 -0700 (PDT) Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1660983129; h=from:from: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=uROXnR0FNbtP4K5lfGfX+GsQclYXLCvip69kr6fv6XQ=; b=t1mwDFk5LmXG1MqGD5+ZL6X/OvL9+uY3SUKGNBb419kxibz8Hr1r11J9eyM2G0GzUGfbpN HlgjB5qgeoop66ToK2ZxJcpenfHRv4zkf2ytfh3gNBGiUWDrI+oL6mSoTAeZhjbdcSBmAi 6qOx21RGLc1NBmy2Edrxvu3IB5yHQtw= MIME-Version: 1.0 Subject: Re: [PATCH 4/6] mm: hugetlb_vmemmap: add missing smp_wmb() before set_pte_at() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20220816130553.31406-5-linmiaohe@huawei.com> Date: Sat, 20 Aug 2022 16:12:05 +0800 Cc: Andrew Morton , Mike Kravetz , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220816130553.31406-1-linmiaohe@huawei.com> <20220816130553.31406-5-linmiaohe@huawei.com> To: Miaohe Lin X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Aug 16, 2022, at 21:05, Miaohe Lin wrote: >=20 > 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. I found another place where is a similar case. See = kasan_populate_vmalloc_pte() in mm/kasan/shadow.c.=20 Should we fix it as well? >=20 > Signed-off-by: Miaohe Lin > --- > mm/hugetlb_vmemmap.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > 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); >=20 > + /* > + * 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)); > } >=20 > --=20 > 2.23.0 >=20 >=20