From nobody Sun Feb 8 16:48:25 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C07A420551D for ; Fri, 21 Feb 2025 09:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740131109; cv=none; b=XKbPj8VAD/Q3by7k6IdEojrpHlrATSP4yurbXTskBaGsqGmMkl5XR2yfJp43upVCTQtrWW7ZgtP2MaV0omHsujXVjiKFLxIB/Emnabc5GyLhyiGfamk6oCApqqrkjGwYeGktJgVWtFjw7EsmWjLdn/AcwCXgdM2QdyOwW92Dy5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740131109; c=relaxed/simple; bh=PfXp5R5o7Je7/PbcelDsQAhWY+QXfQgKBwWvdyTHRqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DQcVqf8KarppBPsAahO2KZhGQAXHivi8SEsGYyevvRXbdtiPmnS0oQjS8YVhFed8FVl2X+BRsiuezkxMBs56yBGXpV7od8c8ljMR4dq/3lt70MYcrt9m3LcSuJ2KLK+T3ZwjbHOMPFWcfd+dqfOkeRWEeJqHGVxRIr6s5lmujr8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 77981113E; Fri, 21 Feb 2025 01:45:19 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.40.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 999703F59E; Fri, 21 Feb 2025 01:44:58 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Ard Biesheuvel , Ryan Roberts , Mark Rutland , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] arm64/mm/hotplug: Drop redundant [pgd|p4d]_present() Date: Fri, 21 Feb 2025 15:14:48 +0530 Message-Id: <20250221094449.1188427-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250221094449.1188427-1-anshuman.khandual@arm.com> References: <20250221094449.1188427-1-anshuman.khandual@arm.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" [pgd|p4d]_present() are inverse to their corresponding [pgd|p4d]_none(). So [pgd|p4d]_present() test right after corresponding [pgd|p4d]_none() inverse test does not make sense. Hence just drop these redundant checks. Cc: Catalin Marinas Cc: Will Deacon Cc: Ard Biesheuvel Cc: Ryan Roberts Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual Reviewed-by: Dev Jain --- arch/arm64/mm/mmu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index b4df5bc5b1b8..66906c45c7f6 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -952,7 +952,6 @@ static void unmap_hotplug_p4d_range(pgd_t *pgdp, unsign= ed long addr, if (p4d_none(p4d)) continue; =20 - WARN_ON(!p4d_present(p4d)); unmap_hotplug_pud_range(p4dp, addr, next, free_mapped, altmap); } while (addr =3D next, addr < end); } @@ -978,7 +977,6 @@ static void unmap_hotplug_range(unsigned long addr, uns= igned long end, if (pgd_none(pgd)) continue; =20 - WARN_ON(!pgd_present(pgd)); unmap_hotplug_p4d_range(pgdp, addr, next, free_mapped, altmap); } while (addr =3D next, addr < end); } @@ -1114,7 +1112,6 @@ static void free_empty_p4d_table(pgd_t *pgdp, unsigne= d long addr, if (p4d_none(p4d)) continue; =20 - WARN_ON(!p4d_present(p4d)); free_empty_pud_table(p4dp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); =20 @@ -1153,7 +1150,6 @@ static void free_empty_tables(unsigned long addr, uns= igned long end, if (pgd_none(pgd)) continue; =20 - WARN_ON(!pgd_present(pgd)); free_empty_p4d_table(pgdp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); } --=20 2.30.2 From nobody Sun Feb 8 16:48:25 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5C5A205509 for ; Fri, 21 Feb 2025 09:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740131108; cv=none; b=aKb9OM1SqVJlKXTFzyCFn5phQO6sfz/by5P0WqLhcbhWPYhF9goKihn2HF8tVA8nIEl2J2YMk1V+LQrYbNmZGD5DgZDO1FxlXNYF5TO+if0f4f2YHtaJOkfNwDIhEdqAr8+RugfselLvhViK+DtGUpnQk6uEjJcyBrrOWaZaJgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740131108; c=relaxed/simple; bh=pTbpsDeO4lMEKiDtq6c1jk9rA1q8xSKS1V5q0oE0oQE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FmLB+TMXRMmKcXnbjzJfwmCpleQqkjjL4CiXYB+xtSYlWVL0ZDpwu9kpdYjWU4saPO5XV0YihYwPWaWhTUL3HgzQ7+Y86/oER3Kb3MtOoX9R07a36aFz9guMive5CmcmLlw6EZzTFsgZYlwnHE6rswJlk2CMwrqUKBFpogmZ4iI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB89A12FC; Fri, 21 Feb 2025 01:45:22 -0800 (PST) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.40.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D4B73F59E; Fri, 21 Feb 2025 01:45:01 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Ard Biesheuvel , Ryan Roberts , Mark Rutland , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] arm64/mm/hotplug: Replace pxx_present() with pxx_valid() Date: Fri, 21 Feb 2025 15:14:49 +0530 Message-Id: <20250221094449.1188427-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250221094449.1188427-1-anshuman.khandual@arm.com> References: <20250221094449.1188427-1-anshuman.khandual@arm.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" pte_present() asserts either the entry has PTE_VALID or PTE_PRESENT_INVALID bit set. Although PTE_PRESENT_INVALID bit only gets set on user space page table entries to represent pxx_present_invalid() state. So present invalid state is not really possible in kernel page table entries including linear and vmemap mapping which get teared down during memory hot remove operation . Hence just check for pxx_valid() instead of pxx_present() in all relevant places. Cc: Catalin Marinas Cc: Will Deacon Cc: Ard Biesheuvel Cc: Ryan Roberts Cc: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/mm/mmu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 66906c45c7f6..33a8b77b5e6b 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -863,7 +863,7 @@ static void unmap_hotplug_pte_range(pmd_t *pmdp, unsign= ed long addr, if (pte_none(pte)) continue; =20 - WARN_ON(!pte_present(pte)); + WARN_ON(!pte_valid(pte)); __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr + PAGE_SIZE); if (free_mapped) @@ -886,7 +886,7 @@ static void unmap_hotplug_pmd_range(pud_t *pudp, unsign= ed long addr, if (pmd_none(pmd)) continue; =20 - WARN_ON(!pmd_present(pmd)); + WARN_ON(!pmd_valid(pmd)); if (pmd_sect(pmd)) { pmd_clear(pmdp); =20 @@ -919,7 +919,7 @@ static void unmap_hotplug_pud_range(p4d_t *p4dp, unsign= ed long addr, if (pud_none(pud)) continue; =20 - WARN_ON(!pud_present(pud)); + WARN_ON(!pud_valid(pud)); if (pud_sect(pud)) { pud_clear(pudp); =20 @@ -1032,7 +1032,7 @@ static void free_empty_pmd_table(pud_t *pudp, unsigne= d long addr, if (pmd_none(pmd)) continue; =20 - WARN_ON(!pmd_present(pmd) || !pmd_table(pmd) || pmd_sect(pmd)); + WARN_ON(!pmd_valid(pmd) || !pmd_table(pmd) || pmd_sect(pmd)); free_empty_pte_table(pmdp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); =20 @@ -1072,7 +1072,7 @@ static void free_empty_pud_table(p4d_t *p4dp, unsigne= d long addr, if (pud_none(pud)) continue; =20 - WARN_ON(!pud_present(pud) || !pud_table(pud) || pud_sect(pud)); + WARN_ON(!pud_valid(pud) || !pud_table(pud) || pud_sect(pud)); free_empty_pmd_table(pudp, addr, next, floor, ceiling); } while (addr =3D next, addr < end); =20 --=20 2.30.2