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 73F63C25B08 for ; Sat, 20 Aug 2022 08:12:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77AAA8D0003; Sat, 20 Aug 2022 04:12:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 701B98D0001; Sat, 20 Aug 2022 04:12:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2778D0003; Sat, 20 Aug 2022 04:12:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 479838D0001 for ; Sat, 20 Aug 2022 04:12:12 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 126CEC0511 for ; Sat, 20 Aug 2022 08:12:12 +0000 (UTC) X-FDA: 79819253304.08.004C80A Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf24.hostedemail.com (Postfix) with ESMTP id 80A0B180034 for ; Sat, 20 Aug 2022 08:12:11 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660983131; 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=uROXnR0FNbtP4K5lfGfX+GsQclYXLCvip69kr6fv6XQ=; b=MbR81kp9ZkCQ0ifnWAhUSd/KWpKAkOXn/IHSYxUbUBoIBG5U6WspAwe6KavcTpsUtjYOVB z0qFN3s8/MUYv6kSU2xdKf92GdwiUX6xrm+MzmYPxAj9J/9JWjJbtsCrNTq/LB3M7K7XfS zstC6dhOfuikFNSL2Y8kBRuUtVVVJ20= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=t1mwDFk5; spf=pass (imf24.hostedemail.com: domain of muchun.song@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660983131; a=rsa-sha256; cv=none; b=rC7lGYsgqVqZoFJn7WJcUwe5zlfWjL8e9U7fuwReVFChPDL4WQ0nw1FJaoPhoxfXW8OYKE TipssQOa3LSrFF4gamCmaKAiha5Ai0FV0041+O5KFaxy3HEtZNzd5xu51hW9yhKKW5XEKL Qp+TIVS+/eEVtAWlOifS9EhKVEeqns0= X-Rspam-User: X-Rspamd-Queue-Id: 80A0B180034 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=t1mwDFk5; spf=pass (imf24.hostedemail.com: domain of muchun.song@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=muchun.song@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Stat-Signature: wbegmrhmjurz47o3hd5te3a4r6erzhff X-Rspamd-Server: rspam10 X-HE-Tag: 1660983131-754911 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 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