Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp114544pxb; Tue, 31 Aug 2021 16:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM9wTPqDGOgil6zddJzvq1iBjL6D5H3ANl1FEi2P0fGOOnCExBEoX/9I9dq8TXuY6BeklA X-Received: by 2002:a92:7305:: with SMTP id o5mr10888443ilc.70.1630453035484; Tue, 31 Aug 2021 16:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630453035; cv=none; d=google.com; s=arc-20160816; b=X8YSg94zDOfgc+rjuvBIg4lbELbR1DFOVG7zrlduZeIB1Rqz/+PxR4xsKlOwm7YJcR EEMw25l6uAnOeuJmAl2z3x3qSmdTc9BZb3BNIUbKmQPY4jqc6v/pzbxSMTWif0p+iRJM zuMamh2XYZPjGXhK1K0wEv9OsdOeXpnOX5k7WpZsKKPj3aRaoMl67IhdATmDaoE5nI8Y vNLPYJBueNuxukos1XZdcus/URhg1sIuLg7SyG3/srOY5KTZUfZ810GyShSxzFHSS/z1 JXgTdmQwSeU/phwN/3D5gNZhd+Oi9Ah16fv5CYnQVJ0Oe4yS8yh1o28SQMbQGFwiJf+A AJHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ReC2ox+Cju/4N9Fc/5sSAV7oCq75ICewzDo/R9c9AWY=; b=YMHPmnGz8Gbjq1pOYMv66bokuufTICGXVQIMHalXG5u+dArGegtUHxpmDPcUzhNOdd jsSM5K2OJfh+8M3/Br8fKkPybeugJD+lmkUC89nzl24jC77arxp6SHL9oW4WfTTRXXs+ S5nKDYkO/4fTRfk/SX90iHK0N81GvJNp9GWOtvVJwCudSDCF1gLrCbATsPqewVbN89l+ XBY+Oibq2+cQokTa6JTQd1s6QH8PyLSjKIm0NkBGqDVz1VZbvzs09BNFfm+M8EaN72yb rGk36g6sqc0uV2ignYESZBmnidRWdQ4CjvvOXbPizfKQd6VyzZhlixeIupI5MfoFxEV1 a7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=pN2iMhH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j4si18168942ilc.2.2021.08.31.16.37.03; Tue, 31 Aug 2021 16:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=pN2iMhH1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240022AbhHaX0P (ORCPT + 99 others); Tue, 31 Aug 2021 19:26:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239407AbhHaX0O (ORCPT ); Tue, 31 Aug 2021 19:26:14 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622F7C061575 for ; Tue, 31 Aug 2021 16:25:18 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id f2so1672944ljn.1 for ; Tue, 31 Aug 2021 16:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ReC2ox+Cju/4N9Fc/5sSAV7oCq75ICewzDo/R9c9AWY=; b=pN2iMhH1zDTCH5MDvXVSzuCCB8DDe5RwD/to1P+zYwgR3DO/7mbOMaR+UgXeGk6uEY VS+eBqv36wZzDcoK+gl28f4wVMGO0a8tRVlNE4KUWK5lS+DtIThtjNjrA5vFjnoLuFx5 SF2NE3vcEWAOMwE7kJMkKVnpiyuvH3aOqyjNU7QBSLTgSZ5pIhsY+ZobDcJz0MUqUiZi u9dKRXDo4CNeHOaWa022jYMGL/JGxNvl5/vr91LmlOC8nMa0dBivNRDi809sIPe+joPy TOkgWM6CTQr0rztXAn1t4byLi8pmM1TnYj+LEy+o7xklXItVtOLrir0qHRdiJhVga9uu TEDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ReC2ox+Cju/4N9Fc/5sSAV7oCq75ICewzDo/R9c9AWY=; b=qZ6BXUGUAkdh3p95q84Y2TnvEr/GNzh745QH3BQC2cHaU2A8fsEzxSCLgtxl3xbFay FN53fsIh4gZvR5PvuQEM6N2+ZIXI+zv8y1Reynf7mTeiHD1OJT/LZkCQiiF+8kWY8GLA kxQ/ZgGGGl8rRAa4v0LwZZ6vfehAXW9VaJrs3Mcg6nBi0+eODt/VGW0oQCUftzypqV0X Y4V5/YodEh88iqI4Q27ysdpMTjXIkNRwLHt1x/crqOo1G9dYSR/cF4MafhMB4c/XC7A2 8SkqIw8a+kqaAITJV0CHbYECx/GqJUcM8rcu0f9xlZ09TcrZfQsX/qbmEc77mkdz4QaK mJvA== X-Gm-Message-State: AOAM531snDQhPbvwelwE6S21cZ5iog+AdsInDaKclL34X6y7br7PM9gg sQHgxFwwd6LN6jp9bPdq9SnT8w== X-Received: by 2002:a2e:a4ba:: with SMTP id g26mr26698740ljm.254.1630452316794; Tue, 31 Aug 2021 16:25:16 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id c3sm2344950ljj.77.2021.08.31.16.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 16:25:16 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 44B20102EFE; Wed, 1 Sep 2021 02:25:16 +0300 (+03) Date: Wed, 1 Sep 2021 02:25:16 +0300 From: "Kirill A. Shutemov" To: Qi Zheng Cc: akpm@linux-foundation.org, tglx@linutronix.de, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, kirill.shutemov@linux.intel.com, mika.penttila@nextfour.com, david@redhat.com, vbabka@suse.cz, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, songmuchun@bytedance.com Subject: Re: [PATCH v2 2/2] mm: remove redundant smp_wmb() Message-ID: <20210831232516.4ft2kkn63lngggbb@box.shutemov.name> References: <20210831132111.85437-1-zhengqi.arch@bytedance.com> <20210831132111.85437-3-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210831132111.85437-3-zhengqi.arch@bytedance.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 31, 2021 at 09:21:11PM +0800, Qi Zheng wrote: > The smp_wmb() which is in the __pte_alloc() is used to > ensure all ptes setup is visible before the pte is made > visible to other CPUs by being put into page tables. We > only need this when the pte is actually populated, so > move it to pmd_install(). __pte_alloc_kernel(), > __p4d_alloc(), __pud_alloc() and __pmd_alloc() are similar > to this case. > > We can also defer smp_wmb() to the place where the pmd entry > is really populated by preallocated pte. There are two kinds > of user of preallocated pte, one is filemap & finish_fault(), > another is THP. The former does not need another smp_wmb() > because the smp_wmb() has been done by pmd_install(). > Fortunately, the latter also does not need another smp_wmb() > because there is already a smp_wmb() before populating the > new pte when the THP uses a preallocated pte to split a huge > pmd. > > Signed-off-by: Qi Zheng > Reviewed-by: Muchun Song > Acked-by: David Hildenbrand Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov