From nobody Thu Apr 2 15:36:24 2026 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 72E5C364E86 for ; Sat, 28 Feb 2026 07:15:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772262927; cv=none; b=HDilF1Qs1khZNSGJe2k7dpBoB5Tv5bcXQOVzjr6z2fsj1agIvOZqVsKPoJUoveXsIMqa94Oh6xIfRZRAT5XPP6wwTEts38mVJ8cg6g8GGt3piB67Azcps6G1qRU1MRJNWmpjjyLcCsR/7dnq1TX1nE+aoiw28VkjUWXOCnX+Epw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772262927; c=relaxed/simple; bh=GPuWPDISYZmK35SCG29E5oqXw4WYLtBJbqlvtb/De5I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j2dbO7/hwTgMaWPfMRERDuVNEfVbUAccUK5wPEotceR6jIjV2dgAs+I1qtGHMUoLOQcfTFnXUrJBVWTryicOb1bfmjUXp4D+IdKm7OEjmkjJQBRJfPHkklsMbP0bAphOBuupJk3A52Q1snNKMRYEwlbXR7QTbjU5JSb6vnk6d30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=b221ls31; arc=none smtp.client-ip=113.46.200.222 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="b221ls31" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=SOSDprgL0d5fs/XXHSWHAOQEs7sQM/PZoje0g5bejM4=; b=b221ls319orrwaq2qXPX2X0zO6JRk7cd5joqvN2G2Lw2Z1N4/h1DK7lO7egszzySI87F0+NCZ O0HVVtR/kXiJ5iHfgXHC74jXTGkIoz4xJ2UEd7vIeGKxB7f9+6BZDG0zz6yp0mKfUcKwuVer6nW 1joxT8IUuxM8Vaj5HB3NzDQ= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fNGYh4GDDzLlT6; Sat, 28 Feb 2026 15:10:32 +0800 (CST) Received: from kwepemr500001.china.huawei.com (unknown [7.202.194.229]) by mail.maildlp.com (Postfix) with ESMTPS id 1684A40565; Sat, 28 Feb 2026 15:15:21 +0800 (CST) Received: from huawei.com (10.50.87.63) by kwepemr500001.china.huawei.com (7.202.194.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 28 Feb 2026 15:15:19 +0800 From: Yin Tirui To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , Subject: [PATCH RFC v3 3/4] x86/mm: Remove pte_clrhuge() and clean up init_64.c Date: Sat, 28 Feb 2026 15:09:05 +0800 Message-ID: <20260228070906.1418911-4-yintirui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260228070906.1418911-1-yintirui@huawei.com> References: <20260228070906.1418911-1-yintirui@huawei.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 X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemr500001.china.huawei.com (7.202.194.229) Content-Type: text/plain; charset="utf-8" With `pfn_pte()` now guaranteeing that it will natively filter out huge page attributes like `_PAGE_PSE`, the `pte_clrhuge()` helper has become obsolete. Remove `pte_clrhuge()` entirely. Concurrently, clean up the ugly type-casti= ng anti-pattern in `arch/x86/mm/init_64.c` where `(pte_t *)` was forcibly cast from `pmd_t *` to call `pte_clrhuge()`. Now, we can simply extract the pgprot directly via `pmd_pgprot()` and safely pass it downstream, knowi= ng that `pfn_pte()` will strip the huge bit automatically. Signed-off-by: Yin Tirui --- arch/x86/include/asm/pgtable.h | 5 ----- arch/x86/mm/init_64.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index a4dbd81d42bf..e8564d4ce318 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -483,11 +483,6 @@ static inline pte_t pte_mkhuge(pte_t pte) return pte_set_flags(pte, _PAGE_PSE); } =20 -static inline pte_t pte_clrhuge(pte_t pte) -{ - return pte_clear_flags(pte, _PAGE_PSE); -} - static inline pte_t pte_mkglobal(pte_t pte) { return pte_set_flags(pte, _PAGE_GLOBAL); diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index d65f3d05c66f..a1ddcf793a8a 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -572,7 +572,7 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long paddr, uns= igned long paddr_end, paddr_last =3D paddr_next; continue; } - new_prot =3D pte_pgprot(pte_clrhuge(*(pte_t *)pmd)); + new_prot =3D pmd_pgprot(*pmd); } =20 if (page_size_mask & (1<