From mboxrd@z Thu Jan 1 00:00:00 1970 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 E1248C25B0E for ; Wed, 17 Aug 2022 02:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 340D28D0002; Tue, 16 Aug 2022 22:53:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C86A8D0001; Tue, 16 Aug 2022 22:53:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 143C38D0002; Tue, 16 Aug 2022 22:53:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 00D0C8D0001 for ; Tue, 16 Aug 2022 22:53:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CA4B31A072C for ; Wed, 17 Aug 2022 02:53:42 +0000 (UTC) X-FDA: 79807564284.02.4821C22 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf27.hostedemail.com (Postfix) with ESMTP id 392BE401D0 for ; Wed, 17 Aug 2022 02:53:42 +0000 (UTC) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1660704821; 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=hKHknFPdtsEpagdsawoMuSymjD5F5nqPAIA2dcTKaCg=; b=MCfzvq+WCMJb/PWdlB8BFTca2XvJukPQyMAnOk9F4TlOV7FX5qBqJbunguzLUiaH+Vgbzj gR2r93hrKZEr32kLH5n+i7gi/AFRetHqQGV/mC+wgAjESshzpcSinB9Oo81F1laZ869FoB CNbFg2IIRYkbkK9QUuzmmdwmwTYOTC0= 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: Wed, 17 Aug 2022 10:53:08 +0800 Cc: Andrew Morton , Mike Kravetz , Muchun Song , Linux MM , 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660704822; a=rsa-sha256; cv=none; b=sPWktZVVa5U2Yb68CLdT2yfokDuHMLYeqJZ8u525VociYXRCzJz8CWhwMyn7D4A4Z+vIHh +Ls6XUjYgQB5Vx5lCNWtXe38T1aFILAITLCKHmBggIScYo3gXxiyCuJxcW7u99221ccA9m IUxL83b/wsRKXOzaXND4uIy5luD9F/Q= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MCfzvq+W; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of muchun.song@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=muchun.song@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660704822; 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:dkim-signature; bh=hKHknFPdtsEpagdsawoMuSymjD5F5nqPAIA2dcTKaCg=; b=8jOuUA8MwZ06nXwA+Yh24FbcCqqTCVPuCOJ6t4oSLeNQG3Ee/L85OmGMCeDp/Eswi62hHB 152zPGnuEJ/oY5TObqTCZlJVxtBor4+5XnhSHOP/43wlR75sf+qfaxBoEGZYrKAjH++PdU 1qVyu3zQpdNnW/krAM6IrrqEdUanGns= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 392BE401D0 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=MCfzvq+W; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of muchun.song@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=muchun.song@linux.dev X-Stat-Signature: dd5ddhf6h7kf7r7s6womhtwri8i4xhkc X-HE-Tag: 1660704822-384409 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: > 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=E2=80=99m not sure if you are right. I think it is set_pte_at()=E2=80=99= s responsibility. Take arm64 (since it is a Relaxed Memory Order model) as an example (the following code snippet is set_pte()), I see a barrier guarantee. So I am curious what issues you are facing. So I want to know the basis for you = to do this change. static inline void set_pte(pte_t *ptep, pte_t pte) { *ptep =3D pte; /* * Only if the new pte is valid and kernel, otherwise TLB = maintenance * or update_mmu_cache() have the necessary barriers. */ if (pte_valid_not_user(pte)) { dsb(ishst); isb(); } } Thanks. >=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