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 0E52CC001B0 for ; Thu, 10 Aug 2023 21:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39E786B0071; Thu, 10 Aug 2023 17:59:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 327726B0072; Thu, 10 Aug 2023 17:59:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C7B56B0074; Thu, 10 Aug 2023 17:59:33 -0400 (EDT) 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 06F626B0071 for ; Thu, 10 Aug 2023 17:59:33 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C6C42A02B6 for ; Thu, 10 Aug 2023 21:59:32 +0000 (UTC) X-FDA: 81109562184.08.7123167 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 080E1C0008 for ; Thu, 10 Aug 2023 21:59:29 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XoAik9CZ; spf=pass (imf28.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=1691704770; 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=pn9VUoV/eSLZq5O7e4Fm41+26+kVKxbLF9wR68sh5IU=; b=Fmp57yQp0DDOZcZ7zDiA7KFJrPXhv2igiajA24MN7K3vs8Qfvzco4lg8xXDCe2aqO8tSyK Mm/TZtFKezkWqHMDZE+FOxwltztvcWrPiLx1tn/dm63qSrgyNqYJon4BoFjZGRNS5M941u s2z2LNG8U6OzHE28GYWnu4NhGhRZlq8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691704770; a=rsa-sha256; cv=none; b=PaBPfp2Pvg2L9+vn+hLvx7AIQopeGmXIxSMT+7pFV8q8Bo3pZu+xVJmfXPwK4viE+v7Utw 0YTgVyDl8FffNQMLhC3bgJXXZsRNd41MtHQWoHkmKcEogR+V+j1tVPcqlKznaJGftsbdvW Hy6zh4fNrfDd3JcP3Gy+Whz84Pc0++E= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XoAik9CZ; spf=pass (imf28.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691704769; 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=pn9VUoV/eSLZq5O7e4Fm41+26+kVKxbLF9wR68sh5IU=; b=XoAik9CZRNuMcun21cED4dqTZ6EGasC6un3lkcIND5juQLbKGWckqAgkiF2ji9u8+OZSUZ 4HXr6whNGzMYNNgQc6C8IPRfm56Bp8/+EAXAzW2iWaAzmXHQQwFtXPvIB5XvH7v0k8SAH4 TuDd5SFcw67l3VdO7nqoCx+uaCd/Vjk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-MoudN-AiOMKFuU3OzrXgAQ-1; Thu, 10 Aug 2023 17:59:28 -0400 X-MC-Unique: MoudN-AiOMKFuU3OzrXgAQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fe5b94bd62so9376855e9.2 for ; Thu, 10 Aug 2023 14:59:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691704767; x=1692309567; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pn9VUoV/eSLZq5O7e4Fm41+26+kVKxbLF9wR68sh5IU=; b=RjqthS8CPS1SPzTzyCZKM670SMxex/spoIX82VuBeYwsvEQXLunI3UcAuhyxEIQ4YK zyuNTk2ZSEwSXvc4VgjvZNg3jKJpKzwL8h74ri9ii3zoz99V9e64QoOgNdqoXUcLgfqo QFxXr/VmobhutFy7cI3JM1Cmt7Nbg+4s8yggkWeFE8aEmRFdzyXVWkaqAfBglWbWjJLs d4TFdTgDWneQpf2SM24dHAfUUDPpto9O4wt2Yi5C40IUe2tAt2o5wxxbnwZXBlrr3G6p R8g5yRVGiw05aRycCICknxop1g0Zqe8xfnY063sTSRmt0hdJAY+DvGJr6pjuR+kcoufm qesA== X-Gm-Message-State: AOJu0Yz+6gQULSzX1NLDML8nGXuslLMveFVo6CV4uxNBlwfhP1xZtlkb gdeQpyv9TxZtwXNXFkcCKjRbgzTumvHNJTvr3lQqLKarq7EfKYcaznhDCXw9H5ZTHR4IK1x+inA ppzjAXV4hSpE= X-Received: by 2002:a1c:6a14:0:b0:3f5:fff8:d4f3 with SMTP id f20-20020a1c6a14000000b003f5fff8d4f3mr160088wmc.7.1691704766960; Thu, 10 Aug 2023 14:59:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG27+1qIuZbyhSQpmuu6o0syienlQHuMWVzKEFOqt5tcp+2Zd2bcZyuL+PUtwnEgRF0tqbTMg== X-Received: by 2002:a1c:6a14:0:b0:3f5:fff8:d4f3 with SMTP id f20-20020a1c6a14000000b003f5fff8d4f3mr160071wmc.7.1691704766595; Thu, 10 Aug 2023 14:59:26 -0700 (PDT) Received: from ?IPV6:2003:cb:c71a:8a00:8200:f041:4b87:a8be? (p200300cbc71a8a008200f0414b87a8be.dip0.t-ipconnect.de. [2003:cb:c71a:8a00:8200:f041:4b87:a8be]) by smtp.gmail.com with ESMTPSA id s10-20020a05600c044a00b003fbc9d178a8sm6196818wmb.4.2023.08.10.14.59.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Aug 2023 14:59:26 -0700 (PDT) Message-ID: <73d6d29f-9947-9b50-3b94-77f1ee547387@redhat.com> Date: Thu, 10 Aug 2023 23:59:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios To: Matthew Wilcox , 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 , Ryan Roberts , Yin Fengwei , Yang Shi , Zi Yan References: <20230809083256.699513-1-david@redhat.com> <7e31254d-8889-7e79-50e1-2630bd493d59@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-Stat-Signature: 9ipeerdqhhmtqybwtmaz8uh1ykt4ctg6 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 080E1C0008 X-Rspam-User: X-HE-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MNafvrru4fXZ16rIQzI2aVn4LFf1GEaNvAeOzODlOgvL4+z0Tj765aGqI93z20ij2GMOjIcZ+RnatgXE9BLEXBSGWx+JPgp5yIBc3L6bgxy4JPxS/2r54O2PzKnQ30c7EHurHxccXOQBumdZjdtlWz5UN94R4PBtSSH41ksNsOjni9z8RcrdOMiJGtS9MnK/uPcs8erebuVol7q9aw7F3GfYxjfdCN0534ywxyha34JSMXHSiAH34QJwVUFqKXY0+Y8eAdSTyT0K9nTD7ULJdTAR/t2dS9DgG/6cnWE3vlkjih4dFfYY3ktZmos/hR 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 10.08.23 23:54, Matthew Wilcox wrote: > On Thu, Aug 10, 2023 at 05:48:19PM -0400, Peter Xu wrote: >>> Yes, that comment from Hugh primarily discusses how we could possibly >>> optimize the loop, and if relying on folio_nr_pages_mapped() to reduce the >>> iterations would be racy. As far as I can see, there are cases where "it >>> would be certainly a bad idea" :) >> >> Is the race described about mapcount being changed right after it's read? >> Are you aware of anything specific that will be broken, and will be fixed >> with this patch? > > The problem is that people check the mapcount while holding no locks; > not the PTL, not the page lock. So it's an unfixable race. > >> Having a total mapcount does sound helpful if partial folio is common >> indeed. >> >> I'm curious whether that'll be so common after the large anon folio work - >> isn't it be sad if partial folio will be a norm? It sounds to me that's >> the case when small page sizes should be used.. and it's prone to waste? > > The problem is that entire_mapcount isn't really entire_mapcount. > It's pmd_mapcount. I have had thoughts about using it as entire_mapcount, > but it gets gnarly when people do partial unmaps. So the _usual_ case > ends up touching every struct page. Which sucks. Also it's one of the > things which stands in the way of shrinking struct page. Right, so one current idea is to have a single total_mapcount and look into removing the subpage mapcounts (which will require first removing _nr_pages_mapped, because that's still one of the important users). Until we get there, also rmap code has to do eventually "more tracking" and might, unfortunately, end up slower. > > But it's kind of annoying to explain all of this to you individually. > There have been hundreds of emails about it over the last months on > this mailing list. It would be nice if you could catch up instead of > jumping in. To be fair, a lot of the details are not readily available and in the heads of selected people :) Peter, if you're interested, we can discuss the current plans, issues and ideas offline! -- Cheers, David / dhildenb