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 C0ED2C0218A for ; Thu, 30 Jan 2025 21:37:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF7A42802A2; Thu, 30 Jan 2025 16:36:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA67D28029C; Thu, 30 Jan 2025 16:36:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6EDD2802A2; Thu, 30 Jan 2025 16:36:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A916A28029C for ; Thu, 30 Jan 2025 16:36:59 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 77458140291 for ; Thu, 30 Jan 2025 21:36:57 +0000 (UTC) X-FDA: 83065428474.27.C14876E Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf03.hostedemail.com (Postfix) with ESMTP id 6951220008 for ; Thu, 30 Jan 2025 21:36:55 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=IWNOlha3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mhL3VjM6; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=IWNOlha3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mhL3VjM6; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738273015; 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:in-reply-to: references:dkim-signature; bh=HQ7pg4/iifecVa6ilK4US+qODf3hoimfFNvopCPDJFU=; b=tq+7t2NPa2hSvpGBfVwfy1pJ1Rtcv86kp3FiK/Go15KHKRKBruBjLlXW+QuQdnMmk7NaDD l7prEA4l0mFhg8V17weB1+nRLsvOSZTVhFYaOdyVQ8UpaPs5PBuZBZMrL7T+x4KNlnsXOw ebAQAaQcreI+ktNVYT6CUk6FID8NdPs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=IWNOlha3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mhL3VjM6; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=IWNOlha3; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mhL3VjM6; spf=pass (imf03.hostedemail.com: domain of osalvador@suse.de designates 195.135.223.131 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738273015; a=rsa-sha256; cv=none; b=MTOK2PqXwNSua6r7I2fGKfKqPR+csv6FynBDLOp2HVKCg0KhEQ2wZUcLH2KDesJGdnp6bL 1TUDjdOLQL1mTmVHAKuYNOB482z7+Gcib5M0BWrM0dqRp4npNwb92ZOpGS+w5WnGCJXX3W TxHUWl51XwYh5yiV9BZIditF1J1BiyQ= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A4DCB1F383; Thu, 30 Jan 2025 21:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738273013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=HQ7pg4/iifecVa6ilK4US+qODf3hoimfFNvopCPDJFU=; b=IWNOlha3B28LxwYeCI27IEnPZvO9K5PL+KlNphVA1O6FPa4gmlcLZeT9aAUJpeCyjd+Jao r0TKe7nDoPFfAW1NdbHhEVGhxOhvYf7v7Rqj1SplawRm08QXw+uW+Pqyn9ygwccHCiwK0w +7N5L24E7sxm3nDvH/VhDZANXIowAI0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738273013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=HQ7pg4/iifecVa6ilK4US+qODf3hoimfFNvopCPDJFU=; b=mhL3VjM68RbbjB/it63hRmj+nIAl32F0zhoDQZGZlGZ+PRC/4LKVgbINVJ09utrfYXPVGY GSlgUOQWXt6HmVDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1738273013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=HQ7pg4/iifecVa6ilK4US+qODf3hoimfFNvopCPDJFU=; b=IWNOlha3B28LxwYeCI27IEnPZvO9K5PL+KlNphVA1O6FPa4gmlcLZeT9aAUJpeCyjd+Jao r0TKe7nDoPFfAW1NdbHhEVGhxOhvYf7v7Rqj1SplawRm08QXw+uW+Pqyn9ygwccHCiwK0w +7N5L24E7sxm3nDvH/VhDZANXIowAI0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1738273013; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=HQ7pg4/iifecVa6ilK4US+qODf3hoimfFNvopCPDJFU=; b=mhL3VjM68RbbjB/it63hRmj+nIAl32F0zhoDQZGZlGZ+PRC/4LKVgbINVJ09utrfYXPVGY GSlgUOQWXt6HmVDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 435CE1366F; Thu, 30 Jan 2025 21:36:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id RvKMDfXwm2foZwAAD6G6ig (envelope-from ); Thu, 30 Jan 2025 21:36:53 +0000 Date: Thu, 30 Jan 2025 22:36:51 +0100 From: Oscar Salvador To: lsf-pc@lists.linux-foundation.org Cc: David Hildenbrand , Peter Xu , Muchun Song , linux-mm@kvack.org Subject: [LSF/MM/BPF TOPIC] HugeTLB generic pagewalk Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6951220008 X-Stat-Signature: rq9keoxqbuenju5k1w5h365y9frmdadj X-Rspam-User: X-HE-Tag: 1738273015-38583 X-HE-Meta: U2FsdGVkX1+4VDeFRdzN6VRorAMAAwfPPujoQP6y2brJgbx58avTpqW7AFTh5zNcuE4Nyauqk7u3xqB0MYyVbPunmx6YCMYjnJnFy14mJ7QYdgzjMTX4CqGtQrW2etpwkYGvHyjs3lWA99abikBRt0rQoUHtL5fHbi9KjJtYbKs5sHnHRJfLiRqrkrmzAdAfN+6FyZtF28h5PGj8JeBWwXQY98f3qMPOvx5w+RGrLENdX0O8XyxtohwvrSS6VQdFN4NUj0CSK+3CJbInuEEU50Smf3NiLuqbOErPM747T4N5RGNE91gTB4WFu0vsvRPuzMN0pq+vuHaq6lL7fFNptekN9QYchmjAB8AApoBoz+rf/kDE0vC/tuuP/55upI/nTLY42Sl43ZsDoouKLC4g00hQPmDtVsmWUBNJgo/UEd6RSU5iElaZfyu4ES34bK35b8XijWBonNj+pSJwyjTsPgGDYARVoLXQ2+RC9OAal8eZAhiyjJBAJlU2dN3kQ4u5I66Gyxo2W6Znb3ceN4gB3pVlb19MryEM/82HxMnj1wNHk9zfAfqQIiI1J3NbQFZmhe1kWl9dHs0+iTHWmB3O0A5M4MA6/1cQ1SWVSRILRvvtxEpiMgKw8z4gCCzimJvgUyE4f7cgkoQ79d6TYzxxasTVZgskqSxDQ952H+o3Kt+swpCznGuR2Z3JZY/D+V61bCkCo+NIVyk45gtm0O/WjhZENqHeb5Ja85d1c90mdAvAYMGv0zkwWz2gAo6G9MZzWCMbaPENmWAjJxFZsNKiffkbDyyin9WzY1bRHH2hVurQqLhIqZIn8QX734zOdy8UnNqbwT1+6mEX0s7GB9CmOIz7Zoarp2qaE70W6nOB0ilS5PIArwLjiWvXGgfzyC2NmaHxzFH4Kf65zBG3M9GLZS1ocLuMnVtPo2OPmr2NbpPS/M3IuB44mDt6dHRAYTfhvVF/oz7CoRzNCymePfR oXHNXRY6 7u8l7aX/z1v/YwHY+51zdjr/Oao9jFZMKgCID8uJeNaYmxEG4hh7N47k+n6YewZRfep2u72MJuxmJQVNO0POn8CNfqRAMc+nWdihHcsLey8vFH7Aj6+F7NlRwj/sAcQEEq98c9nYZONMeAKtmcReg2sUlMT/W3mjDRtiZl6o87fHfmM/jUA0Xm9RYebT8HZ8FnBec7NZY7W+lBhMgU2herAC9+lC9dpoo/VwuMzj/WLuRCQoEOgHIgjLFOEW80VaM8H9NYZMriu2J0UpvmzjZn++SbdvO1FhKnwonbNTz/71Pon5mQFfDh6J4SA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.015011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, last year Peter Xu did a presention at LSFM/MM on how to better integrate hugetlb in the mm core. There are several reasons we want to do that, but one could say that the two that matter the most are 1) code duplication and 2) making hugetlb less special. During the last year several patches that went in that direction were merged e.g: gup hugetlb unify [1], mprotect for dax PUDs [2], hugetlb into generic unmapping path [3] to name some. There was also a concern on how to integrate hugetlb into the generic pagewalk, getting rid by doing so of a lot of code and have a generic path that could handle everything. This was first worked in [4] (very basic draft). Although a second version is on the works, I would like to present some concerns I have wrt. that work. HugeTLB has its own way of dealing with things. E.g: HugeTLB interprets everything as a pte: huge_pte_uffd_wp, huge_pte_clear_uffd_wp, huge_pte_dirty, huge_pte_modify, huge_pte_wrprotect etc. One of the challenges that this raises is that if we want pmd/pud walkers to be able to make sense of hugetlb stuff, we need to implement pud/pmd (maybe some pmd we already have because of THP) variants of those. E.g: HugeTLB code uses is_swap_pte and pte_to_swp_entry. If we want PUD walkers to be able to handle hugetlb, this means that we would need some sort of is_swap_pud and pud_to_swp_entry implementations. The same happens with a handful of other functions (e.g: huge_pte_*_uffd_wp, hugetlb pte markers, etc.) This has never been a problem because hugetlb has its way of doing things and we implemented code around that logic, but this falls off the cliff as soon as we want to make it less special and more generic, because we need to start implementing all those pte_* variants for pud/pmd_* I would like to know how people feel about it, whether this is something worth pursuing, or we live with the fact that HugeTLB is special, and so it remains this way. [1] https://patchwork.kernel.org/project/linux-mm/cover/20240327152332.950956-1-peterx@redhat.com/ [2] https://patchwork.kernel.org/project/linux-mm/cover/20240812181225.1360970-1-peterx@redhat.com/ [3] https://patchwork.kernel.org/project/linux-mm/cover/20241007075037.267650-1-osalvador@suse.de/ [4] https://patchwork.kernel.org/project/linux-mm/cover/20240704043132.28501-1-osalvador@suse.de/ -- Oscar Salvador SUSE Labs