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 D3C85C001DE for ; Thu, 10 Aug 2023 08:59:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D4D76B0074; Thu, 10 Aug 2023 04:59:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 685456B0075; Thu, 10 Aug 2023 04:59:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54C676B0078; Thu, 10 Aug 2023 04:59:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 44DE86B0074 for ; Thu, 10 Aug 2023 04:59:59 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1B48FB2A40 for ; Thu, 10 Aug 2023 08:59:59 +0000 (UTC) X-FDA: 81107597718.28.314A0E8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf16.hostedemail.com (Postfix) with ESMTP id A42B618000A for ; Thu, 10 Aug 2023 08:59:56 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GEhqXHlT; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1691657996; 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=4mg2JCBqsL99mMNAl8TPlreyaVZP4GA221Xi/aiCfPU=; b=O9EN4kiC9dFOF2/TMfa6aeORyeoPx+sgnPDfU+5iMNx5SBmVBSgwOmatBEyZvMFPWO6wb7 7rExMxKVEAwSW+WBoyZLL5fW/70v1uzAtfD43jPa++RmMFjjT/R1ertJdhFOCMoD6H5aVq 17Fil3BdAdcm+xv9KsFnf6KEArOEbhM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GEhqXHlT; spf=pass (imf16.hostedemail.com: domain of david@redhat.com designates 170.10.133.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=1691657996; a=rsa-sha256; cv=none; b=RGvbDwm+gOUtq7O+hC5DBxhxC0RFeWGBWy9IpbmRNaOaPEtXfjeL0vE28nclOCluGkJ69U TOI/kZCt4Ot5WVW4YZ3wRc0pANz02CoYbhCi3F+CsRY2k3EaR0hbDau8/Vp32QSD3Hm5bT pV86zbgKziA9nA8TbSY+rcp88wxjb5U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691657996; 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=4mg2JCBqsL99mMNAl8TPlreyaVZP4GA221Xi/aiCfPU=; b=GEhqXHlT6F12Gurlq8TSt/v2aU0p/YxJLOgfyod+y8RPbNi4gcBbOaWP35uZIz5QGV4/eF Lpkv/QPrOunkEANWA/TwqXRLRE50ubUj0aXTKYvIQWgpnfN0vxgXL3p0osW9NDyKafMs09 OhRulbu7gY4ERnmSlmL2wmIdh5FisGo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-Q5Pgy-I7OVqMUIuMJ5X3xQ-1; Thu, 10 Aug 2023 04:59:50 -0400 X-MC-Unique: Q5Pgy-I7OVqMUIuMJ5X3xQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fe232ba9e5so4176765e9.2 for ; Thu, 10 Aug 2023 01:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691657989; x=1692262789; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4mg2JCBqsL99mMNAl8TPlreyaVZP4GA221Xi/aiCfPU=; b=HuNY1s8Bbgl19lLCnZfKHux6Z7FlnwCZs2B/4PCl2XCJCet6Ry/ZfKIZ6kiAsYzD65 vQzHZnSnAoz/R4hsjuJLWINZyJ1Avx1tOPE0+K7qWN3YYdCbiQzkiie/dn50UJ00/IdB inPLMxdZAeO4+CmAkwkPc2Uv8OQtTBdsUp5ZnKGgWjxmnl7DU+PmARD7Cw/j4Tl1l7If 3QQHOMRs4xuZDpZ+34mt82LCCnqd+WFBd7ecf+fhMCoCeDSXrforFdgpAudTttH0u3hY Idd7crFBfD0yRHo89xux0xpEM6zZdoeC0p8K/Xucm8KC2Ph1bYi5cjEVOw1dNk38zcFa z+/Q== X-Gm-Message-State: AOJu0YytSmKHI/UrT9f1fYlaFRR7TVaR1fN2fj7GnY5l9JfwQJelp2W2 dLBAtg97+gcpfV8X/n73lOhJae6t4tmUF5tGQni9rKouEZMSVPXTbllfyTEJBSCB4wL3Lez7rrl pJ5svaikuoZ0= X-Received: by 2002:a05:600c:152:b0:3fb:b5c0:a079 with SMTP id w18-20020a05600c015200b003fbb5c0a079mr1394153wmm.21.1691657989398; Thu, 10 Aug 2023 01:59:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQtBdu8t2biwmqY3nfOHl7eknPBJXAl+kUsgy5C/reo859h3nbXb6oqXr8VhyfvcvCmtHJKA== X-Received: by 2002:a05:600c:152:b0:3fb:b5c0:a079 with SMTP id w18-20020a05600c015200b003fbb5c0a079mr1394126wmm.21.1691657988980; Thu, 10 Aug 2023 01:59:48 -0700 (PDT) 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 i9-20020a05600c290900b003fe539b83f2sm4349427wmd.42.2023.08.10.01.59.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Aug 2023 01:59:48 -0700 (PDT) Message-ID: Date: Thu, 10 Aug 2023 10:59:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: 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)" , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan References: <20230809083256.699513-1-david@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios 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-Queue-Id: A42B618000A X-Rspam-User: X-Stat-Signature: 5ceo6d8xrpuj88uy89xs3zs875f8ogys X-Rspamd-Server: rspam01 X-HE-Tag: 1691657996-547457 X-HE-Meta: U2FsdGVkX196HEDYyASoF/PSbuvLCX5eHuw1NzclMqonMTXvpdGkBbj9FMzoo4IpVPSaep9nCWjkKv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XYuLAYfbq5/9FNtoZWDDe40MZic/a7BaQlrr4RoTR7cbp+VmRA7UtWl1FSDUQtxPjlRpw14eOL++Xt/9ok1wmYu69UUVzu3W0T+F/vFDm3KlcLH9zK4ECMlRMdmK0D48vySxXvZi7IziZ9BsGEiY26N8P8HH7JEIM/3bbmV9EIjhS1vBTfCdwZ7jPm1M372iJn9twvDY3OH/WNn/V/oXeQ27VEHegPwSBdedjlf1wYLyFphs0TndbdGAqmKZwlDF8 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 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). 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. -- Cheers, David / dhildenb