From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9072D34403F for ; Wed, 5 Nov 2025 19:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762372603; cv=none; b=bW+orkAnNmzfKOKeUXKXZBaD0nITGE6HUdS9l+C//u4BrenorGeC0aRpZukCZVF57zuK+5Qnudp9pR5erb/g71i/2uM/PQhezSWVD6VW3DT3tHAU4g3WP0dosgJ2J7SSDx+gjgzM/QdtN89s9SxaZP2KmCoxRQjgKS8hi/lfCO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762372603; c=relaxed/simple; bh=y0djx7SaSKxrg38g7Mq/6kY7uEuPs6Y4jirNJDxy4Uo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TuhRO6gqG1lqvJ/rIzuibHXMUrax6iiKKcDN2qYXMz2O7VR5K5RYxr4wx0naPpYw8+ntq1ciI8Ue0H++SdFxNmQCyGVsl4vYmFEv/s6CnRLF7dmYMtpbJKGPM1Zw1UFlWSAAYyGO/dQms3LJyceJi7ZVYKnGxwCmNMR9c3qlYe4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dF03gt7m; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=dCPUd4wU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dF03gt7m"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="dCPUd4wU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762372600; 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=RfRdq0AOLjAvRpFgewWvnXKqu09Gq6WPLf3shQQBn6o=; b=dF03gt7m4v2LFDVNmqva+6rkm0YhCFMPsx8wBni/J2D4U1RLdlMbX0NaRrTheAR+bgutxe +9nqWqBrNJ1kiXdQgeG6eWuhF91HF23ejjMU92gl0mfZw+WY21fiUgQBElhLBGssEzA6jQ D4o130VTH5JSUw32jVW2JPEkUpHiuRo= 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_256_GCM_SHA384) id us-mta-534-yadihL-DNrCXGBenr4uxDg-1; Wed, 05 Nov 2025 14:56:39 -0500 X-MC-Unique: yadihL-DNrCXGBenr4uxDg-1 X-Mimecast-MFC-AGG-ID: yadihL-DNrCXGBenr4uxDg_1762372598 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-47113538d8cso1074125e9.1 for ; Wed, 05 Nov 2025 11:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1762372598; x=1762977398; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=RfRdq0AOLjAvRpFgewWvnXKqu09Gq6WPLf3shQQBn6o=; b=dCPUd4wUDwoikIXTihkjC5+8ZLU9JgtloI7GLZ+q64xLT0biQ8j0HLtCqsfcgEdv2C Brg2q9FoCDZ75vOlnPaGiWxMrqroASjcmmEGay9Lgbzml7QJg5z9EsOvVLPzPb0/Zxcz csRp2rNYObE104mkvvIXsyGV695Rk7inc2VRtxADfH0wkaUJEPHutcSO+6hxqzjtA3po CbFi8+/1Z/F24+2Mu7wOuV0bZ5FWr2uMhZUm40z6JypB9rQbdXJQOOyBUatFq3DDJhHv 0OPyqzoRFeq7Pu5eRWr8RZo7Zk2Jgxmpoaa2ArF1JEmYk3Ksq+3mAZuwchWByKmuJy82 N+ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762372598; x=1762977398; h=content-transfer-encoding:in-reply-to: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=RfRdq0AOLjAvRpFgewWvnXKqu09Gq6WPLf3shQQBn6o=; b=D4x7POy6zjHKoXq5Bt/vwKPgUHSi9s/GOHZzacA64Lr3H4fcJ6PvK9W0T1OAqMyGvL umzkoTGFA0FuvueHI6Wgc5XwMAlztt4AJ33XYncQvSqU4OTsSSB6afBcGMWryVLTzxhQ 7T/OHaxy3RzYDFmck/m5BONvXm85aKPuML3cz5svuFBW+E1Yo/5H3IG7kMoiAlkzfaAM GQSISdywLMcTkYS6gMVs9Uu2u11+m6yxrumneooGevW4zV6GBCUzrtbHcvuC91KedBha dfNIo+2Fh9hk0LrEJJRuUYdJDv1YAvtsVAhCURW9GjDGdNjnWcyq/3Kbvyb5CxWdMNR0 X+TQ== X-Forwarded-Encrypted: i=1; AJvYcCUeHNRPQr0YdYcostfeejatOcLfU6Hh5iuaODi3huiEgUqwJwpX0poFiGMSl0eamQ7LORaIxEdK+pzb@vger.kernel.org X-Gm-Message-State: AOJu0YyWzwzAEL5PwsTsAcJOXI+PN9bFG2dLYfKSAp7drXxp8wKN19k/ eMdFfMu8LpRsNdD8DVnIM1r+tOWDY80RpvXykkinkrI/ZS9wJ+hOg9OKDmp8URdFp8iWZZqhrXh T3yc00pJJ8nhcg9EGqX/V1p4ODgY1S57EF4sgVM1zhdp2LOw8aqiHIkVsbeC3Ico= X-Gm-Gg: ASbGncuXSgnom5WqFfUuJGBTdln5cAMENBn1e3vYPPZkBEEIzdJ4nufuRGVKOvK3+QI Q9JoiQWIOJtMbmaNUl9chqUA56//mswKs/ypvqv4BbzDe82ZlttkBNlqUUkJ6k8xmXj/Qhb8VYO DR0c3wzQDLS0j1zWSqtTtK/X1eLUXWRpRS/jGjtDyAhTBkvsNmVh4VfEfOyTSIXjtV2GxrHoxCE unNIcu4n46fZD0Wh9tKQoUZLXfZHeyXB7sgOBXyep5J3ky49sfCYD0zDo2SBo9S/WScJgZL8kRX /0tfI5tOFXrsDNgq14XNuChusS5ePPgyiQPYmHvgugN26ORBhZtnV0QypdcnOmFBC8PzGlmtjHl 5aswvJ5S9oJYEGj3PTdabmxwtA6IXclH7nmhWNk1JHgawWrlSjqwl4We0aqnIy+5cac9/D8V3Kv AL9setTc4bdZ6RLwq6asOcNA== X-Received: by 2002:a05:600c:348f:b0:46f:b43a:aee1 with SMTP id 5b1f17b1804b1-4775ce2c7eemr29950015e9.38.1762372598038; Wed, 05 Nov 2025 11:56:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHK7yLH47QUN086LZNyuRAD2Zw/GPvRFlywAZeFx22RAaEduz3ojwl4v/Mo8ax5jk1OZayf5g== X-Received: by 2002:a05:600c:348f:b0:46f:b43a:aee1 with SMTP id 5b1f17b1804b1-4775ce2c7eemr29949845e9.38.1762372597551; Wed, 05 Nov 2025 11:56:37 -0800 (PST) Received: from ?IPV6:2003:d8:2f30:b00:cea9:dee:d607:41d? (p200300d82f300b00cea90deed607041d.dip0.t-ipconnect.de. [2003:d8:2f30:b00:cea9:dee:d607:41d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4775cdc33bdsm64219765e9.1.2025.11.05.11.56.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Nov 2025 11:56:36 -0800 (PST) Message-ID: Date: Wed, 5 Nov 2025 20:56:34 +0100 Precedence: bulk X-Mailing-List: linux-arch@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/16] mm: introduce leaf entry type and use to simplify leaf entry logic To: Lorenzo Stoakes , Gregory Price Cc: Matthew Wilcox , Andrew Morton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Sven Schnelle , Peter Xu , Alexander Viro , Christian Brauner , Jan Kara , Arnd Bergmann , Zi Yan , Baolin Wang , "Liam R . Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Muchun Song , Oscar Salvador , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Axel Rasmussen , Yuanchu Xie , Wei Xu , Kemeng Shi , Kairui Song , Nhat Pham , Baoquan He , Chris Li , SeongJae Park , Jason Gunthorpe , Leon Romanovsky , Xu Xin , Chengming Zhou , Jann Horn , Miaohe Lin , Naoya Horiguchi , Pedro Falcato , Pasha Tatashin , Rik van Riel , Harry Yoo , Hugh Dickins , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, damon@lists.linux.dev References: <2c75a316f1b91a502fad718de9b1bb151aafe717.1762171281.git.lorenzo.stoakes@oracle.com> <373a0e43-c9bf-4b5b-8d39-4f71684ef883@lucifer.local> From: David Hildenbrand Content-Language: en-US In-Reply-To: <373a0e43-c9bf-4b5b-8d39-4f71684ef883@lucifer.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 05.11.25 20:52, Lorenzo Stoakes wrote: > On Wed, Nov 05, 2025 at 02:25:34PM -0500, Gregory Price wrote: >> On Wed, Nov 05, 2025 at 07:06:11PM +0000, Matthew Wilcox wrote: >>> On Mon, Nov 03, 2025 at 12:31:43PM +0000, Lorenzo Stoakes wrote: >>>> The kernel maintains leaf page table entries which contain either: >>>> >>>> - Nothing ('none' entries) >>>> - Present entries (that is stuff the hardware can navigate without fault) >>>> - Everything else that will cause a fault which the kernel handles >>> >>> The problem is that we're already using 'pmd leaf entries' to mean "this >>> is a pointer to a PMD entry rather than a table of PTEs". >> >> Having not looked at the implications of this for leafent_t prototypes >> ... >> Can't this be solved by just adding a leafent type "Pointer" which >> implies there's exactly one leaf-ent type which won't cause faults? >> >> is_present() => (table_ptr || leafent_ptr) >> else(): => !leafent_ptr >> >> if is_none() >> do the none-thing >> if is_present() >> if is_leafent(ent) (== is_leafent_ptr) >> do the pointer thing >> else >> do the table thing >> else() >> type = leafent_type(ent) >> switch(type) >> do the software things >> can't be a present entry (see above) >> >> >> A leaf is a leaf :shrug: >> >> ~Gregory > > I thought about doing this but it doesn't really work as the type is > _abstracted_ from the architecture-specific value, _and_ we use what is > currently the swp_type field to identify what this is. > > So we would lose the architecture-specific information that any 'hardware leaf' > entry would require and not be able to reliably identify it without losing bits. > > Trying to preserve the value _and_ correctly identify it as a present entry > would be difficult. > > And I _really_ didn't want to go on a deep dive through all the architectures to > see if we could encode it differently to allow for this. > > Rather I think it's better to differentiate between s/w + h/w leaf entries. (Being rather silent because I'm busy with all kinds of other stuff) I agree :) As Willy said, something that spells out "sw leaf" would be nice. -- Cheers David