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 C1F01C30653 for ; Thu, 4 Jul 2024 15:23:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 039866B0095; Thu, 4 Jul 2024 11:23:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2B966B0096; Thu, 4 Jul 2024 11:23:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA61A6B0098; Thu, 4 Jul 2024 11:23:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BD5216B0095 for ; Thu, 4 Jul 2024 11:23:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 55A58A23DA for ; Thu, 4 Jul 2024 15:23:38 +0000 (UTC) X-FDA: 82302439716.03.D407E17 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 132D0A000A for ; Thu, 4 Jul 2024 15:23:35 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VEa1c5Ou; spf=pass (imf15.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=1720106596; 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=ciNpI4biZuLDpCsmTQeZWiRYi6l4tqxyig75r9C5Nhc=; b=UGkPA5SulyVEz9duMsxbhlA4IhqkxduMvoURxK6ykt2G4zWAvqC7zVXr6E1wOE49JTuVwE lhk7ZTsK5x/5Jsmf+cCgdjQC3clme205S8CmL/VYDZCobEo0zWHr2VDJLxgwjM1hn4HSZ8 AlUI9dnCBTndbCqy5rDH9GsR4bDBXMs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VEa1c5Ou; spf=pass (imf15.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=1720106596; a=rsa-sha256; cv=none; b=EJihDNarOdewXKqEk5W33NWqYzW9IukLDcK/A7jwdlLd4lTEzv8+VgiCLUqm9gUrINrJsq 4EJ+AJpVNM//cG3CoauY9WPgTOdogm+kqh/Vy7ii62yXQmSq9svg61Cs8XldROkpXXLO+z 3sJRQC+wdUIE3MGAnedwU/ZlLeWmOi0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720106615; 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:autocrypt:autocrypt; bh=ciNpI4biZuLDpCsmTQeZWiRYi6l4tqxyig75r9C5Nhc=; b=VEa1c5OucsbrjqSZ6Ts23XZA6+OzWeq6bvigrQWxq8w7cr8R+374GwayyK3SvQJdm0nvOH rDqMXQKeA7iNMWn7rT1ElzIZVIL0MPSl3UzKYP7aVPwpgCMJCeOYFbC5vO/z04t4LkAFLS rh6htBwFxY7DpuRFjsg8y0eEnJFllX0= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-mtcbfrvKPfCToO17aSzpgw-1; Thu, 04 Jul 2024 11:23:33 -0400 X-MC-Unique: mtcbfrvKPfCToO17aSzpgw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ee8e0dab26so7922651fa.0 for ; Thu, 04 Jul 2024 08:23:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720106612; x=1720711412; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from: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=ciNpI4biZuLDpCsmTQeZWiRYi6l4tqxyig75r9C5Nhc=; b=vI81ghWIcuGnxm33laUJGIzHniWMggImzXddVgRQK8xc1E4o/ZkaWNuSQuqrA152Ts A2QhjrBKAPE3RLGiKNFBrGMoJy6kSw6anNaLO3rrB2UlJ+BmuuLZqYN3I+YLvVrO6bO/ QfPET/tzkxcogcV/Y8e8AXwEOwq3DQeLvltR1R/rD0vBenFlThAnmeSvIwDSF22okOiz PSBMQ+4V8Qp7P0yBVUj7K7wOxdbJpAT1NnFoTp5oYnM6Nbubd6imQ4eEfPA9/Q7Jl0Uw JP3KxF2u9WldixXF4oRbyl30mj5jS6SvSAlJNmPeh5cNodkFmUsnOWDRwMzJgXN1Qp02 m6LA== X-Forwarded-Encrypted: i=1; AJvYcCWrJ4DV1UztpA1TNEldF12/JrVHTt12O3Ehv1tERiIxJ/zXpkqFEblnB3b49fEe07/8hqxNbjmXZQMD12tis2n8UqU= X-Gm-Message-State: AOJu0Yw0Uez58JEAlydj6t0ZHoAw+VWQWRR9CiYXAdFCrZgC0I4IHkjs oQHigeZI7Y5Sph686LIXTM1Hcg5/Xjw9dY7EI0oLAffAeQTUxFMOxj8FdB94e3cVJh6qn/qm26J CAKe/5u51MVloB3ssS7q+iD7W/kpMm14S6Ggs8eB9QgtWKSWh X-Received: by 2002:a2e:b1c4:0:b0:2ee:896d:2408 with SMTP id 38308e7fff4ca-2ee8ee001c6mr13627191fa.37.1720106612365; Thu, 04 Jul 2024 08:23:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ92AVhPvt7IGMw05PPOJd/errJXQT56kku3/y2KcQeSVDaRGnMAMRUnocazvAmAO3gqCcYQ== X-Received: by 2002:a2e:b1c4:0:b0:2ee:896d:2408 with SMTP id 38308e7fff4ca-2ee8ee001c6mr13626971fa.37.1720106611896; Thu, 04 Jul 2024 08:23:31 -0700 (PDT) Received: from ?IPV6:2003:cb:c715:8600:f05d:97b6:fb98:2bc1? (p200300cbc7158600f05d97b6fb982bc1.dip0.t-ipconnect.de. [2003:cb:c715:8600:f05d:97b6:fb98:2bc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a25b5edsm28247945e9.37.2024.07.04.08.23.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Jul 2024 08:23:31 -0700 (PDT) Message-ID: <84d4e799-90da-487e-adba-6174096283b5@redhat.com> Date: Thu, 4 Jul 2024 17:23:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/45] hugetlb pagewalk unification To: Peter Xu Cc: Oscar Salvador , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song , SeongJae Park , Miaohe Lin , Michal Hocko , Matthew Wilcox , Christophe Leroy , Jason Gunthorpe References: <20240704043132.28501-1-osalvador@suse.de> <617169bc-e18c-40fa-be3a-99c118a6d7fe@redhat.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou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gb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== 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: wstq6mmjb59f3f11axtkk65z89dqabbt X-Rspam-User: X-Rspamd-Queue-Id: 132D0A000A X-Rspamd-Server: rspam02 X-HE-Tag: 1720106615-810112 X-HE-Meta: U2FsdGVkX1/GQpycdopu6n5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msecnlJ3Yrn7RhX040Acx8J2W8XJzfd1c/sdw2fPwqgZ3Hy0Lvtx8X/JvpYlbiegCTwYyHqZKuqS89Fp1l9YD2S4eR7D9fvptL4xD0pXAFyuByUd+D0mF97+7q7gp9VUf8FYRTMC4Tr8vbsywWjBc3F1k5hwHXt2cTktTFY8+dSDFSOd4unuA4tU6sWgz9cdnMHOIQTit5zZQMtyWTs9X7kK+L8pSvLcMEuqKs6UT7fynQ7Ee8Hz/kfQyjcvIG3eNZmRN5DjCudxElQ== 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: List-Subscribe: List-Unsubscribe: On 04.07.24 16:30, Peter Xu wrote: > Hey, David, > Hi! > On Thu, Jul 04, 2024 at 12:44:38PM +0200, David Hildenbrand wrote: >> There are roughly two categories of page table walkers we have: >> >> 1) We actually only want to walk present folios (to be precise, page >> ranges of folios). We should look into moving away from the walk the >> page walker API where possible, and have something better that >> directly gives us the folio (page ranges). Any PTE batching would be >> done internally. >> >> 2) We want to deal with non-present folios as well (swp entries and all >> kinds of other stuff). We should maybe implement our custom page >> table walker and move away from walk_page_range(). We are not walking >> "pages" after all but everything else included :) >> >> Then, there is a subset of 1) where we only want to walk to a single address >> (a single folio). I'm working on that right now to get rid of follow_page() >> and some (IIRC 3: KSM an daemon) walk_page_range() users. Hugetlb will still >> remain a bit special, but I'm afraid we cannot hide that completely. > > Maybe you are talking about the generic concept of "page table walker", not > walk_page_range() explicitly? > > I'd agree if it's about the generic concept. For example, follow_page() > definitely is tailored for getting the page/folio. But just to mention > Oscar's series is only working on the page_walk API itself. What I see so > far is most of the walk_page API users aren't described above - most of > them do not fall into category 1) at all, if any. And they either need to > fetch something from the pgtable where having the folio isn't enough, or > modify the pgtable for different reasons. Right, but having 1) does not imply that we won't be having access to the page table entry in an abstracted form, the folio is simply the primary source of information that these users care about. 2) is an extension of 1), but walking+exposing all (or most) other page table entries as well in some form, which is certainly harder to get right. Taking a look at some examples: * madvise_cold_or_pageout_pte_range() only cares about present folios. * madvise_free_pte_range() only cares about present folios. * break_ksm_ops() only cares about present folios. * mlock_walk_ops() only cares about present folios. * damon_mkold_ops() only cares about present folios. * damon_young_ops() only cares about present folios. There are certainly other page_walk API users that are more involved and need to do way more magic, which fall into category 2). In particular things like swapin_walk_ops(), hmm_walk_ops() and most fs/proc/task_mmu.c. Likely there are plenty of them. Taking a look at vmscan.c/walk_mm(), I'm not sure how much benefit there even is left in using walk_page_range() :) > > A generic pgtable walker looks still wanted at some point, but it can be > too involved to be introduced together with this "remove hugetlb_entry" > effort. My thinking was if "remove hugetlb_entry" cannot wait for "remove page_walk", because we found a reasonable way to do it better and convert the individual users. Maybe it can't. I've not given up hope that we can end up with something better and clearer than the current page_walk API :) > > To me, that future work is not yet about "get the folio, ignore the > pgtable", but about how to abstract different layers of pgtables, so the > caller may get a generic concept of "one pgtable entry" with the level/size > information attached, and process it at a single place / hook, and perhaps > hopefully even work with a device pgtable, as long as it's a radix tree. To me 2) is an extension of 1). My thinking is that we can start with 1) without having to are about all details of 2). If we have to make it as generic that we can walk any page table layout out there in this world, I'm not so sure. -- Cheers, David / dhildenb