Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp944717rwl; Thu, 10 Aug 2023 04:17:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgox9hwc3x5fXEurVCDj1uPx8xqY4aiG/iIM1Xnd3j/PoRYH7UBEnXihtPD4N459hUjFrX X-Received: by 2002:aca:210e:0:b0:3a7:b4e8:563e with SMTP id 14-20020aca210e000000b003a7b4e8563emr2557681oiz.38.1691666272644; Thu, 10 Aug 2023 04:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691666272; cv=none; d=google.com; s=arc-20160816; b=hCeIb78Cx5Gu5LI1Udt/u4EuMQF8j/rpq2Hbm8aTPJbFQnHMWH7jVUb5W304Gjmo0H JSxjX8yZGW+DYHkigC2QvP+fmiOEsKF2PrrS2tHRCMYk4pmCG6oNya/M1zNCvCQkOXmg nzcdvjD6tG9jv4lg1gdnOVsDgmPXfrdQisu/4ihw54xDYChaFzPh1lqtoMNgfC8VmSXZ v9sxUkXux2gxoRh4gIYqg2QuRPNeK7GEhH0q4rk8RvdU97g+ZJgUXcare91qG92BvLZJ MBl7bl2aSOGF7rjMRuxoiGsC2B5ex12ieD8+i1apiEGiVEsS+3Y1uu3HSCduHAJkTmog ekaQ== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=Xxs5p4t1SDS5v4F3hr5MB+FRoGLt1jB0xXEcoGTBeqA=; fh=HMbQfyAvLe7iIsSAAqFZcI6a5rrnZvFXFdrSuBprNfk=; b=FZXLjRJb4Db87P6IzpwnErrNhrifNqAHMV4RvMrSO6wmXTrySrqMoAAZaVi0wwE5Kg D1DpEg/+98j/k5MP4E3B0KicS9AI10TQnsd2t3ZUgEwTp6QLvLJcE9hkAEg82iXTbIhE PByAE66I/DUsYnT6b0ZpWoSfKPOK/f2rEI/EPr3UTMD4bU/abYHxLrNzcP+hy/l4zvNG 07LnPpBU9zqSW8vk5leNYU75VQje284tYI+Rn1+p/k+K44D2amMIBcj8OhbHxC8iiw2a xF7D2/ch2bxoK9isTJE0kMYiaI20SM10sini1xyS5iJNztQ5jkNiXcocQFu96BCOL26Y D+kg== 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 h26-20020a63385a000000b00563b0cbe802si136964pgn.109.2023.08.10.04.17.39; Thu, 10 Aug 2023 04:17:52 -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 S235306AbjHJKtP (ORCPT + 99 others); Thu, 10 Aug 2023 06:49:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234097AbjHJKsx (ORCPT ); Thu, 10 Aug 2023 06:48:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 928A726BE; Thu, 10 Aug 2023 03:48:30 -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 A39D4D75; Thu, 10 Aug 2023 03:49:12 -0700 (PDT) Received: from [10.1.27.169] (XHFQ2J9959.cambridge.arm.com [10.1.27.169]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 86E073F64C; Thu, 10 Aug 2023 03:48:28 -0700 (PDT) Message-ID: <155bd03e-b75c-4d2d-a89d-a12271ada71b@arm.com> Date: Thu, 10 Aug 2023 11:48:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios Content-Language: en-GB To: David Hildenbrand , Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Andrew Morton , Jonathan Corbet , Mike Kravetz , Hugh Dickins , "Matthew Wilcox (Oracle)" , Yin Fengwei , Yang Shi , Zi Yan References: <20230809083256.699513-1-david@redhat.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 10/08/2023 09:59, David Hildenbrand wrote: > On 09.08.23 23:23, Peter Xu wrote: >> Hi, David, >> >> Some pure questions below.. > > Hi Peter, > > thanks for having a look! > > [...] > >>> With sub-PMD THP becoming more important and things looking promising >>> that we will soon get support for such anon THP, we want to avoid looping >>> over all pages of a folio just to calculate the total mapcount. Further, >>> we may soon want to use the total mapcount in other context more >>> frequently, so prepare for reading it efficiently and atomically. >> >> Any (perhaps existing) discussion on reduced loops vs added atomic >> field/ops? > > So far it's not been raised as a concern, so no existing discussion. > > For order-0 pages the behavior is unchanged. > > For PMD-mapped THP and hugetlb it's most certainly noise compared to the other > activities when (un)mapping these large pages. > > For PTE-mapped THP, it might be a bit bigger noise, although I doubt it is > really significant (judging from my experience on managing PageAnonExclusive > using set_bit/test_bit/clear_bit when (un)mapping anon pages). > > As folio_add_file_rmap_range() indicates, for PTE-mapped THPs we should be > batching where possible (and Ryan is working on some more rmap batching). Yes, I've just posted [1] which batches the rmap removal. That would allow you to convert the per-page atomic_dec() into a (usually) single per-large-folio atomic_sub(). [1] https://lore.kernel.org/linux-mm/20230810103332.3062143-1-ryan.roberts@arm.com/ > There, > managing the subpage mapcount dominates all other overhead significantly. > >> >> I had a feeling that there's some discussion behind the proposal of this >> patch, if that's the case it'll be great to attach the link in the commit >> log. > > There were (mostly offline) discussions on how to sort out some other issues > that PTE-mapped THP are facing, and how to eventually get rid of the subpage > mapcounts (once consumer being _nr_pages_mapped as spelled out in the patch > description). Having a proper total mapcount available was discussed as one > building block. > > I don't think I have anything of value to link that would make sense for the > patch as is, as this patch is mostly independent from all that. >