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 AC4B3C61DA0 for ; Thu, 26 Jan 2023 08:38:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 273426B0071; Thu, 26 Jan 2023 03:38:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2239A6B0072; Thu, 26 Jan 2023 03:38:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C43B6B0073; Thu, 26 Jan 2023 03:38:02 -0500 (EST) 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 EF1386B0071 for ; Thu, 26 Jan 2023 03:38:01 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B7A2C1A0189 for ; Thu, 26 Jan 2023 08:38:01 +0000 (UTC) X-FDA: 80396297562.23.9D188A0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 8D680A0004 for ; Thu, 26 Jan 2023 08:37:59 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FWqtu4MW; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674722279; 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=03govaco/k7QRuYG8wH+zgOyem44zOrE/2g3qGYBeec=; b=QWuy7FTeIwstcAg6/sOHj1VBzPiFdK6+ttWucM+TWvRvkca3yq5KY0GcCBvsdBD2sfyl2V Ub6CONAjuR7X4WJUjCm8y0nkvPGGbArYgJ2ib3e3OBqQVwRB4dS9ee1rt2Jyd4ARPpHU78 piBe632BLoNtrxrMmTn3jjXUPzmUt3w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FWqtu4MW; spf=pass (imf25.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674722279; a=rsa-sha256; cv=none; b=pw2ACdO9MXFlpKD/WsBI3Gj0XxuFxS10mqTjD+cHCOHpW1LV9iHiIWIesFXGs2ut6F0W26 t1+LPgiAq61EDacoQWFCr+JGJeyISVga6ELDE6TZZ+OiljOjnbk2oPkqAWckUf40MUMtiV JgYtJakWJqe7b1iObubE/yWExC1Litg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674722278; 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=03govaco/k7QRuYG8wH+zgOyem44zOrE/2g3qGYBeec=; b=FWqtu4MW7Sx/608JPLVCggviPdHcgpHYc3GlhLf0tfUZCuclY6o7zOgg4Yy1zZUuJekJt4 A+Jmf/TK55QXZwD5WxPTH6Ily505lVNN5GVyixx9PYGoUCmZO/1VDiLk9VYMH8OOM+pJbS K+6v/KIC9smuG5wp3WX1pENFBMLb7Rs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-297-WXYJWR84Nyq6BM306FECEw-1; Thu, 26 Jan 2023 03:37:57 -0500 X-MC-Unique: WXYJWR84Nyq6BM306FECEw-1 Received: by mail-wm1-f69.google.com with SMTP id fl5-20020a05600c0b8500b003db12112fdeso698825wmb.5 for ; Thu, 26 Jan 2023 00:37:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=03govaco/k7QRuYG8wH+zgOyem44zOrE/2g3qGYBeec=; b=bfs4w5ymrRyqG4X0NxH6YzELotuyXrkvE81kQhUf3VoYEBxhUjCnMvwdg+vBwJCuKM fWyO3pALJH6KzX70Oc/ikcO1IaYozuXeW2LK/cTCgUh7TmLh4k7aoPXbns2JwA33qX1P mT/7c2Ya7OFruYgp4BP8u5nWphTi8rYLKDu2gO133ShcyTF9DAfyUGp8guPUHfa4heun C2BFWb6CvhgitIBlPbNr/8lKX6gUrTadNqc3GQ1cxYIOT6FkzADjA8W0owc1ZmuJEsW1 vlRlZlgcP/gLrgWEvervamchsKk1PMMG48KScXAoaLqowz70m0EUSegxD5SaISspreEW opzA== X-Gm-Message-State: AO0yUKWKwznT1kCB1NEM9N521mlJWEVe3ca0+0JvaNZPhaDdqyrahxB5 JlYoQjzWz7IPAO7oSvT3M71NrhsXbBJoxdJcXWHEio3qFFUB74i2POYMvI69E4f4u4xLGFzXkXA mRcBeMJSQCsE= X-Received: by 2002:a05:600c:46cb:b0:3dc:1d62:1e9c with SMTP id q11-20020a05600c46cb00b003dc1d621e9cmr4576483wmo.41.1674722276212; Thu, 26 Jan 2023 00:37:56 -0800 (PST) X-Google-Smtp-Source: AK7set8iyfb7Q4H7MkzbfZ3IksQgPv9DTJio1Pn6vTBNqXG4VFnEqYcPyKuzkUvU34RxL6c9T07KNw== X-Received: by 2002:a05:600c:46cb:b0:3dc:1d62:1e9c with SMTP id q11-20020a05600c46cb00b003dc1d621e9cmr4576466wmo.41.1674722275766; Thu, 26 Jan 2023 00:37:55 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c351400b003dc1300eab0sm4508629wmq.33.2023.01.26.00.37.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Jan 2023 00:37:55 -0800 (PST) Message-ID: <52af321f-175b-9fa9-10f0-ac2bba04c677@redhat.com> Date: Thu, 26 Jan 2023 09:37:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH mm-unstable v2 1/6] mm: Add folio_estimated_mapcount() To: Vishal Moola Cc: linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org References: <20230124012210.13963-1-vishal.moola@gmail.com> <20230124012210.13963-2-vishal.moola@gmail.com> <477bbc1e-a60a-cfce-d31e-0b4bdd5f6429@redhat.com> <526e5156-6c4b-9f2c-1637-2f83c1dfea1e@redhat.com> <53d86764-d155-8d97-1a4d-7e701848c950@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8D680A0004 X-Stat-Signature: mfzz4ig6abuzjj4ddze4fh3ykd3zcy5a X-Rspam-User: X-HE-Tag: 1674722279-534809 X-HE-Meta: U2FsdGVkX19f/Jam6mSH9fJtYs343zyoZzJWJXbaG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alyczJzupIL72LR2SrzEby0/ZRRMGTUM3gVrlGm17RX3hfWf77nUZktJPdH0wz0fKg4v1twcJ4m29oX+1d2C+VfyIe37OJbzAfr65x87ckPfSUqTPH4+jBjJ8pX/+WW2onjqXknAObYYjYduhRg/42SUtilfCeULTU34ka4VdXludCOikdPNxpitM9DSGZcfrdLjX8AEGCBZuvVZ24rEbD3kdIzVeQQyGEbplDDnkxPPN6Bgv+hoS8lDY+RP67if6N/wxZFYvEqqPH2HQZiscj+BWfu7+UFIVqEPobak3QciijHG9wwOdM1mWKdS8cpoIhgMPpRcrReZPG8K3N41NjAMbJcqo6S3QN4ZZ34DPf29wn5hXmJ3HxP+Ap8zLQEw0WYTUWS4J6sRb8DtVsiRegDqVvryKDbpPTb6W2S9uRdSbD/kaexpAuGGj2g== 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 25.01.23 23:09, Vishal Moola wrote: > On Wed, Jan 25, 2023 at 1:29 PM David Hildenbrand wrote: >> >> On 25.01.23 11:24, David Hildenbrand wrote: >>> On 25.01.23 11:20, David Hildenbrand wrote: >>>> On 24.01.23 02:22, Vishal Moola (Oracle) wrote: >>>>> folio_estimated_mapcount() takes in a folio and calls page_mapcount() on >>>>> the first page of that folio. >>>>> >>>>> This is necessary for folio conversions where we only care about either the >>>>> entire_mapcount of a large folio, or the mapcount of a not large folio. >>>>> >>>>> This is in contrast to folio_mapcount() which calculates the total >>>>> number of the times a folio and its subpages are mapped. >>>>> >>>>> Signed-off-by: Vishal Moola (Oracle) >>>>> --- >>>>> include/linux/mm.h | 5 +++++ >>>>> 1 file changed, 5 insertions(+) >>>>> >>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>>> index c9db257f09b3..543c360f7ecc 100644 >>>>> --- a/include/linux/mm.h >>>>> +++ b/include/linux/mm.h >>>>> @@ -875,6 +875,11 @@ static inline int page_mapcount(struct page *page) >>>>> return mapcount; >>>>> } >>>>> >>>>> +static inline int folio_estimated_mapcount(struct folio *folio) >>>>> +{ >>>>> + return page_mapcount(folio_page(folio, 0)); >>>>> +} >>>>> + >>>>> int folio_total_mapcount(struct folio *folio); >>>>> >>>>> /** >>>> >>>> I'm sorry, but "estimated" as absolutely unclear semantics. You could >>>> have a THP mapped into 9999 processes using THP and the estimation would >>>> be "0". >>> >>> ... or would it be 9999 ? What about a PMD-mapped THP? What about a >>> partially unmapped THP? >>> >>> What are we estimating? >> >> Thinking about mapcounts again, might not have been my smartest moment. >> >> What we return here is the precise number of times the first subpage is >> mapped (via the large folio and directly). That's supposed to be an >> estimate for the number of times any subpage part of the folio is mapped. >> >> I really don't know a better name, but folio_estimated_mapcount() does >> not feel completely right to me and triggere dmy confusion in the first >> place ... hm ... > > I can understand the confusion, but I can't think of a better name > either myself. I'll go ahead and add a comment to make the purpose > of this function more clear. Looks like I'll have to move it to get rid > of the build warnings/errors anyway. The issue is that we're not estimating the mapcount of the folio, so the name is very misleading ... I think you really want to avoid the term mapcount completely in that context. We're just using the #mappings of the first subpage to determine something differently. Thinking about it, I guess "folio_estimated_sharers()" might be what we actually want to name it. Then you can comment how we estimate sharers by looking at into how many page tables the first subpage is currently mapped, and assume the same holds true for the other subpages. It's unreliable because other subpages might behave differently, we might not be holding the pagelock to stabilize, and we're not looking at indirect mappings via the swapcache. But it's a comapratively good estimate for most scenarios I guess. -- Thanks, David / dhildenb