From nobody Thu Oct 2 09:19:19 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 08E9925CC5E for ; Fri, 19 Sep 2025 05:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758260577; cv=none; b=AMTGX0QD4NwzrlWLqHv05y/sQdDS23o+4LXp5EpWU3UTNcMNSRJQGQrCFPl2k1gOW5yCSciBkQ2u8c0UCHkDlFkILySM7YtZrqPXhdTNUp5V8emAF2462SN/M7XQYnY+blovxR6eOmREvbT1vqGAROf6wIvIm6vDPN7bV2dAalg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758260577; c=relaxed/simple; bh=q4orb/9TcIzBYjB1lAxgyFEtZV3WTz8lFO2q41GLlcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UwEwt8kJ2+gvNPE6vDaOkaO9Rp9kvgfGLQENkjeQe75Q6HESoEtvYMHrFal5IdO/2p+LOkU6S5Nk4u7jbPa2EJi9uquTN0TWI77htWFVj74pHbRqNj+lXhGHLuZbUqsOpB+veje5M8X9BZ4hW+XSiv0CrVJOLVwIVCL8pfaUy7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=c4cQagnb; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="c4cQagnb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758260576; x=1789796576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q4orb/9TcIzBYjB1lAxgyFEtZV3WTz8lFO2q41GLlcw=; b=c4cQagnbN+k7O6JjWSXIky0k5XXk8dfb358C+HH78x9UHZwVn+euRjIl oREIFD7mHxXI1jID4dxmjZF8s4IIqh96vSPZsr6aDsHeJ9feENEzhq5lD w0N79DJ1lyUtha2yUSfty0J6mKd+dty48iNNTyIfTvppBB+72RFsOBvRn NgS4DPcCIWKfg9PN8+ojitwJNUbBph6N4PXMRv9e1BLlf9wYfZXut4KC7 I8Thr1jhI39htQ+1Y6npZi0Po1rzZIAZiRnK1pA3B2WyouTQwr6zYgZEr oft/XDGSQbdbYB2ZDMRYV+kCTZB9FL+a4H6b7QUZZ7wUH7Y+HQZ+xIT8J w==; X-CSE-ConnectionGUID: 9YC19UekTqKvXSknnPQ1qA== X-CSE-MsgGUID: Tq3iyoAyRLaw6EGe0NCY5A== X-IronPort-AV: E=McAfee;i="6800,10657,11557"; a="63235789" X-IronPort-AV: E=Sophos;i="6.18,277,1751266800"; d="scan'208";a="63235789" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2025 22:42:56 -0700 X-CSE-ConnectionGUID: +Vms+rOBQSqxVfmiElkoKg== X-CSE-MsgGUID: Q6CmgcwOT0Wklf9A8kA2kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,277,1751266800"; d="scan'208";a="180858678" Received: from allen-box.sh.intel.com ([10.239.159.52]) by orviesa005.jf.intel.com with ESMTP; 18 Sep 2025 22:42:50 -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 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 v5 4/8] mm: Introduce pure page table freeing function Date: Fri, 19 Sep 2025 13:40:02 +0800 Message-ID: <20250919054007.472493-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250919054007.472493-1-baolu.lu@linux.intel.com> References: <20250919054007.472493-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 --- 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 f3db3a5ebefe..668d519edc0f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2884,6 +2884,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 @@ -2893,12 +2900,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