From nobody Tue Dec 16 21:10:38 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 8891E30AABF for ; Wed, 22 Oct 2025 08:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761121789; cv=none; b=DJoyJhzhXgaq/IJ/JYpoDE8qsL5X0rKKz4Lky96LyTWpIwUOwENZdwz5fvAT1eqKWg5yhsJ2mF/qfy1kXYIGbfKbqcMl+osaIPOuGcdFg+bmaX39X5S0dvK/FK/8HmTNPozdbTo1Ee16jcqLBv4EDqHGwvNizdlEJTvJicpcJ7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761121789; c=relaxed/simple; bh=mbPmTlwTy+FeaIisuAWPXHAhimNAXyev/5jdHXGKqJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OjoU88SoiwmRG14MUsFDpHkK9HmlL9GYq+uXAdQ/zOAOLY0IrPwJ5NBrFxBbTtC3UHjRo+UH7mhhuUb8pH/s2cBCXzgyqJATBACjhOMv84tPO8LG3WYgEDW+iDuuUn1sZcLfY2k4r0vSX2Vostj7+FAOy4CHkfTSS2if4MG6FLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=I58yTDHo; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="I58yTDHo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761121787; x=1792657787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mbPmTlwTy+FeaIisuAWPXHAhimNAXyev/5jdHXGKqJc=; b=I58yTDHoAVNKhegtfL4jH8GCRyV4ufPiGgb/qXN9mYHC86oMKLN3QPTj 3iZPLSXRK5CAckY4L/4SwE/UnJ72Pi40GMwJAvWhsgw2JF+yv/69n5pv8 38AIs+8rSQBw4iuEVbLhX9CtiVae9E1SB4Nxg1fRwMJ2X5OcoAHnSGC6h OoZ28SBt8XZgolnu3kGWMwfiQ8TEF4L462EJqqLQl7IcLF6hGCKOrHV8u 0ctAFiWrpfPBm5kgmsU6FndrR123YUobtTW5IYymRWOoL2aKiT154qCjh ptN2CdD+aBu0nUblw2Gq9DEs8LkYwkmrZ6oMzRrbu4zQ/WAI5ZVuq1E8V A==; X-CSE-ConnectionGUID: EMl554FHTySabr0TT2pbpg== X-CSE-MsgGUID: dUsehEKKTZ6lA4ii+GwlJQ== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="80885545" X-IronPort-AV: E=Sophos;i="6.19,246,1754982000"; d="scan'208";a="80885545" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2025 01:29:47 -0700 X-CSE-ConnectionGUID: mg1a5UIgSHOP6I/XJ15gVA== X-CSE-MsgGUID: YMVBwWzsSoyi79/QzztH9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,246,1754982000"; d="scan'208";a="183516383" Received: from allen-box.sh.intel.com ([10.239.159.52]) by fmviesa007.fm.intel.com with ESMTP; 22 Oct 2025 01:29:40 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jason Gunthorpe , Jann Horn , Vasant Hegde , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Alistair Popple , Peter Zijlstra , Uladzislau Rezki , Jean-Philippe Brucker , Andy Lutomirski , Yi Lai , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Andrew Morton , Vlastimil Babka , Mike Rapoport , Michal Hocko , Matthew Wilcox , Vinicius Costa Gomes Cc: iommu@lists.linux.dev, security@kernel.org, x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , Lu Baolu Subject: [PATCH v7 5/8] mm: Introduce pure page table freeing function Date: Wed, 22 Oct 2025 16:26:31 +0800 Message-ID: <20251022082635.2462433-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251022082635.2462433-1-baolu.lu@linux.intel.com> References: <20251022082635.2462433-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Dave Hansen The pages used for ptdescs are currently freed back to the allocator in a single location. They will shortly be freed from a second location. Create a simple helper that just frees them back to the allocator. Signed-off-by: Dave Hansen Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Acked-by: David Hildenbrand Acked-by: Mike Rapoport (Microsoft) --- include/linux/mm.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index cca5946a9771..52ae551d0eb4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3024,6 +3024,13 @@ static inline struct ptdesc *pagetable_alloc_noprof(= gfp_t gfp, unsigned int orde } #define pagetable_alloc(...) alloc_hooks(pagetable_alloc_noprof(__VA_ARGS_= _)) =20 +static inline void __pagetable_free(struct ptdesc *pt) +{ + struct page *page =3D ptdesc_page(pt); + + __free_pages(page, compound_order(page)); +} + /** * pagetable_free - Free pagetables * @pt: The page table descriptor @@ -3033,12 +3040,10 @@ static inline struct ptdesc *pagetable_alloc_noprof= (gfp_t gfp, unsigned int orde */ static inline void pagetable_free(struct ptdesc *pt) { - struct page *page =3D ptdesc_page(pt); - if (ptdesc_test_kernel(pt)) ptdesc_clear_kernel(pt); =20 - __free_pages(page, compound_order(page)); + __pagetable_free(pt); } =20 #if defined(CONFIG_SPLIT_PTE_PTLOCKS) --=20 2.43.0