Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp941013rwo; Wed, 2 Aug 2023 06:35:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlFjUQ/RedmQ97FipWBiMDJ88TN05OPl5VsLx3hFM0RpNNG1batfyKLN8u+pM2X7JIYTo6/u X-Received: by 2002:a05:6e02:1569:b0:348:76eb:17d9 with SMTP id k9-20020a056e02156900b0034876eb17d9mr17483410ilu.20.1690983316263; Wed, 02 Aug 2023 06:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690983316; cv=none; d=google.com; s=arc-20160816; b=LKebxEtegsJd3r8n69A5BK/KtFCGX/ofJfhjmwFWlSxPDM5kV0GNj6mZjV/OY4IYG7 GBFGSRv+V0IHU6A/+YtuMoLJ5fKJwfKBzzi4YoV9EpWHi02N7LZUrNz9RMlq2GP5voHC jEeA23SvIN686c7kYy38krVaYPfJ/M5mnhfh1bM8G58sIDyo0Hva9BDLYjPf86UFouy3 RAd6JAOi89Chm+G659hkFc6UtdwoQ97kOEUcqEBK3cuZ3xbu8AvQtE/CYoOg5iQjH81w jiB/xisT6B1Dvsr9G3OXfkmMEZvTOCH/hyPq8aSHCSoRqjF1ScWU3F0PZKrcKGagQpNL 3FxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:subject:user-agent:mime-version:date:message-id; bh=HC0cU2oVHRW1+a+2oZeTTEk9I5ow90vNHE3i9Okfx0Y=; fh=VfAZBxAKARlbOYpOQIn/qTwEa/zX9DTJIc7Dq/f9nhc=; b=nMRjcKoIpaX0ov+SnsJeyGAS8qYMzP70Fu7gq2nU8Y3Q+Eygw+1DowUOt3B6VCv0Gv bTVRYJ0MDob/hfOa89hK36yV4kbbAEBpxN+OfPdKB0K2rw3k5XkE5Yvx3elkT6fLJjh/ nVhnYlI+QKSRZHkD5rpbZImdExzPI/TBHgk1dusSd7wGQz7HfuQtD0SHOsAloDn8HYhg R+hYS+HsHLe8VFOjJR5iXsbXD0l7375QduaOs759bIP+OakEcadiYO4tN6IX1wk9F+am hDk4do3I9B+042xjHsXPBepV7yqqYqJIE/pQpL8z2NPIM0lbMwCrxvy3pteOdI5RZYip 0BNA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a631e48000000b00553b54585e9si10614030pgm.696.2023.08.02.06.35.03; Wed, 02 Aug 2023 06:35:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234912AbjHBMvr (ORCPT + 99 others); Wed, 2 Aug 2023 08:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234911AbjHBMvc (ORCPT ); Wed, 2 Aug 2023 08:51:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 137193C14; Wed, 2 Aug 2023 05:51:10 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4FDED1424; Wed, 2 Aug 2023 05:41:06 -0700 (PDT) Received: from [10.57.77.90] (unknown [10.57.77.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 626F13F6C4; Wed, 2 Aug 2023 05:40:20 -0700 (PDT) Message-ID: <3541d2de-5cf8-2f84-8153-277e2bfc0101@arm.com> Date: Wed, 2 Aug 2023 13:40:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 0/2] don't use mapcount() to check large folio sharing To: "Yin, Fengwei" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, vishal.moola@gmail.com, wangkefeng.wang@huawei.com, minchan@kernel.org, yuzhao@google.com, david@redhat.com, shy828301@gmail.com References: <20230728161356.1784568-1-fengwei.yin@intel.com> <3bbfde16-ced1-dca8-6a3f-da893e045bc5@arm.com> <56c8f4f9-b54b-b0bb-250c-ec8643accfc7@intel.com> From: Ryan Roberts In-Reply-To: <56c8f4f9-b54b-b0bb-250c-ec8643accfc7@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,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 02/08/2023 13:35, Yin, Fengwei wrote: > > > On 8/2/2023 6:27 PM, Ryan Roberts wrote: >> On 28/07/2023 17:13, Yin Fengwei wrote: >>> In madvise_cold_or_pageout_pte_range() and madvise_free_pte_range(), >>> folio_mapcount() is used to check whether the folio is shared. But it's >>> not correct as folio_mapcount() returns total mapcount of large folio. >>> >>> Use folio_estimated_sharers() here as the estimated number is enough. >>> >>> Yin Fengwei (2): >>> madvise: don't use mapcount() against large folio for sharing check >>> madvise: don't use mapcount() against large folio for sharing check >>> >>> mm/huge_memory.c | 2 +- >>> mm/madvise.c | 6 +++--- >>> 2 files changed, 4 insertions(+), 4 deletions(-) >>> >> >> As a set of fixes, I agree this is definitely an improvement, so: >> >> Reviewed-By: Ryan Roberts > Thanks. > >> >> >> But I have a couple of comments around further improvements; >> >> Once we have the scheme that David is working on to be able to provide precise >> exclusive vs shared info, we will probably want to move to that. Although that >> scheme will need access to the mm_struct of a process known to be mapping the >> folio. We have that info, but its not passed to folio_estimated_sharers() so we >> can't just reimplement folio_estimated_sharers() - we will need to rework these >> call sites again. > Yes. This could be extra work. Maybe should delay till David's work is done. What you have is definitely an improvement over what was there before. And is probably the best we can do without David's scheme. So I wouldn't delay this. Just pointing out that we will be able to make it even better later on (if David's stuff goes in). > >> >> Given the aspiration for most of the memory to be large folios going forwards, >> wouldn't it be better to avoid splitting the large folio where the large folio >> is mapped entirely within the range of the madvise operation? Sorry if this has >> already been discussed and decided against - I didn't follow the RFC too >> closely. Or perhaps you plan to do this as a follow up? > Yes. We are on same page. RFC patchset did that. But there are some other opens > on the RFC. So I tried to submit this part of change which is bug fix. The other > thing left in RFC is optimization (avoid split large folio if we can). > > > Regards > Yin, Fengwei > >> >> Thanks, >> Ryan >>