From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C6402367D9 for ; Wed, 5 Nov 2025 02:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762310507; cv=none; b=TR+glk9LV7GsVEc1bqTdOyyuEvicTzKad//2Jx7fSkKh+f+Fuo6/w+ykYEWR6nlwWGeST+5UpDx/Hm3PjEhrzxscga2NJdBYR2r6OJooIYwTkM9R8VfQ8dN7Pdk+9n5UoluT6bbiIYaot6XOWaMDYfR4Ap1X+6BBQmaB+tqopjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762310507; c=relaxed/simple; bh=PjIh0DtXOzHZkEPK6bUNpRhZZkxl57GmW5vYJSH5bug=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cedVz8CikykQSbh5Nl9stkUy9cGxyw9GSHPcbHCrANtOj/sFOHSHsoQ3YQps0AttEXMiTu6jVSN8h97DbQ0p7ndbHTrfmUFHnsgNeN7EEwnrKFa6ypLZteV1rz9uD3a50CHJUpqbfasV9Y3Q/UOIPP9qskgqh22hGL9+wWd4UNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UEmS+3I9; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UEmS+3I9" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-640b4a52950so3666310a12.1 for ; Tue, 04 Nov 2025 18:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762310504; x=1762915304; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ViiTvlr9WUOouJ2tSO6oIz/u1XimAQZsK9c62kBG2uQ=; b=UEmS+3I9/hWpaA6OKA3gwPYvDGjQZg3IGW1HP/3wCWG9kEB3amaSiTktVjeMwtU9Vz 9OitmKXnGY4KREybzlnGF3d1LK5aAppXOW/gtwszcFFaVxaQEAU4OhjIlvMznlz/0o9E gx5uI4+5U5vS/y2w1lLiOkuG1OtpQw/DLmZ1y6SYCLa6f6aLXq4afsr0QH83PI5p1ki3 pcidTr6r4XlEZEEn/jJd0ovEVJZcsccOYi2ZKeakJ4cAJOmayzAZDiqETB0wfN8oJaBy VIyxTj/cTgPIdSzj0eP4O+TNdsl3W3EVS7SgbqonvxBQ275a7FrSNlaOei4w8TLydHnY K13Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762310504; x=1762915304; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ViiTvlr9WUOouJ2tSO6oIz/u1XimAQZsK9c62kBG2uQ=; b=ADNSF3rK92EtNQjjqALP/9cmO4Poe9OA65N7eRh9bxvEfE2Nxz7jbVbGybBJCdZUyn +NiFLj+XB1E39/DhqyItUzI/YbabXwpDQL0vvsWuBm5dcc9+xsNH8nnjaRjbpkruqFwv BT8KY53hiQ1yv7zBSftf6zRVUTXVnIyReXEU3Ih0prjKlGNus+yIV9siJzH9kcPrB09E ptVfkzGy2BLJuGTkGZFl1oNm4RvEe9CcdAtLXtsOdRV8Z6AmlVpxJHofxydiLOKVnFY1 LRkSlYUfHUB00nEVBueKz1CT+8Zp0baAFQRwop+63p6VK0r3I/fGLu7NabqtdJ0MYdjb u5Zw== X-Forwarded-Encrypted: i=1; AJvYcCX7HLBA6hDQ8tEuyWxAAbz8tGlvY15MRq7s6lPf9UIjxaApel/2CvMBDl5Wc1cuURgG5bvIVdU1A4Zn@vger.kernel.org X-Gm-Message-State: AOJu0Yxm0wFd03mYDz/FNPei0lcubAIJlVxOIvViGVH45Di7e/DBOEpc qaIJRI1uco7rKHeUpF0RFDi4VBePgCf51dtZXM2+NdcQzW7tNlYf8G4c X-Gm-Gg: ASbGncumQI3xwiFyGdvh//fZBgb9IHBNpsgfrCP/ZeO4GUPDg1468Hm0BBTKXh8Sx9u IvdSThiIrj3UASnDWlsoGFYYtRQwn2shlhNhneocsU41KdObuy7oz9xMuKfrrXwqQaO/Z0Jf6JC KVouoBJfIK+lVRk8SXNN4ne4r+9wiPau/mFYm3RPO5Ve3tVobBbm86PFwe/1MLxwikZFcr6mZkm IpqtERuykXXhEnCw8MrtzMxKqpKr4/FhUInCP/S0+Ml30zlJeWumaRWpskTPRCk0BX8r+WXxTJN rgNA08ZdqcrRqjSD1Kv9QBVxeCDpISHI9EelHQL1V9wJKlRJakL47SQKY5DTc9cVSxOvMSq/TMy Ftfas8iPDLpqZbhE0wvlMQddnDaRfnWzP6AEwIf3TovpRMm+cfYEMLA3y50GeguNJ0/SpvYNZFl WHanCMYEgmLw== X-Google-Smtp-Source: AGHT+IEhst8qtfGo16G97VsH5MJRSalariFjSPTu9KPWOjxNsyChIg/n4Cvg6QvPn/kA2H/rBkbMGQ== X-Received: by 2002:a05:6402:450f:b0:640:9b62:a8bb with SMTP id 4fb4d7f45d1cf-64105a44a6amr1195466a12.22.1762310503278; Tue, 04 Nov 2025 18:41:43 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-640e6a5c7e5sm3420577a12.24.2025.11.04.18.41.40 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Nov 2025 18:41:41 -0800 (PST) Date: Wed, 5 Nov 2025 02:41:40 +0000 From: Wei Yang To: Lorenzo Stoakes Cc: Andrew Morton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , 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 , Gregory Price , Ying Huang , Alistair Popple , Axel Rasmussen , Yuanchu Xie , Wei Xu , Kemeng Shi , Kairui Song , Nhat Pham , Baoquan He , Chris Li , SeongJae Park , Matthew Wilcox , 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 Subject: Re: [PATCH 00/16] mm: remove is_swap_[pte, pmd]() + non-swap entries, introduce leaf entries Message-ID: <20251105024140.kmxo4dltsl6toyil@master> Reply-To: Wei Yang References: Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) On Mon, Nov 03, 2025 at 12:31:41PM +0000, Lorenzo Stoakes wrote: >There's an established convention in the kernel that we treat leaf page >tables (so far at the PTE, PMD level) as containing 'swap entries' should >they be neither empty (i.e. p**_none() evaluating true) nor present >(i.e. p**_present() evaluating true). > >However, at the same time we also have helper predicates - is_swap_pte(), >is_swap_pmd() - which are inconsistently used. > >This is problematic, as it is logical to assume that should somebody wish >to operate upon a page table swap entry they should first check to see if >it is in fact one. > >It also implies that perhaps, in future, we might introduce a non-present, >none page table entry that is not a swap entry. > >This series resolves this issue by systematically eliminating all use of >the is_swap_pte() and is swap_pmd() predicates so we retain only the >convention that should a leaf page table entry be neither none nor present >it is a swap entry. > >We also have the further issue that 'swap entry' is unfortunately a really >rather overloaded term and in fact refers to both entries for swap and for >other information such as migration entries, page table markers, and device >private entries. > >We therefore have the rather 'unique' concept of a 'non-swap' swap entry. > >This series therefore introduces the concept of 'leaf entries' to eliminate >this confusion. > >A leaf entry in this sense is any page table entry which is non-present, >and represented by the leaf_entry_t type. > >This includes 'none' or empty entries, which are simply represented by an >zero leaf entry value. > >In order to maintain compatibility as we transition the kernel to this new >type, we simply typedef swp_entry_t to leaf_entry_t. > >We introduce a number of predicates and helpers to interact with leaf >entries in include/linux/leafops.h which, as it imports swapops.h, can be >treated as a drop-in replacement for swapops.h wherever leaf entry helpers >are used. > >Since leafent_from_[pte, pmd]() treats present entries as they were >empty/none leaf entries, this allows for a great deal of simplification of >code throughout the code base, which this series utilises a great deal. > >We additionally change from swap entry to leaf entry handling where it >makes sense to and eliminate functions from swapops.h where leaf entries >obviate the need for the functions. > Hi, Lorenzo Thanks for the effort on cleanup this, which helps me clearing the confusing on checking swap entry. -- Wei Yang Help you, Help me