From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] arm64/mm/hotplug: Drop redundant [pgd|p4d]_present()
Date: Wed, 19 Mar 2025 11:32:25 +0530 [thread overview]
Message-ID: <1c35a8c5-324b-4c60-9bf1-a5414481e5ad@arm.com> (raw)
In-Reply-To: <Z9lWJsA2hg2UKZ0T@J2N7QTR9R3>
On 3/18/25 16:46, Mark Rutland wrote:
> On Fri, Feb 21, 2025 at 03:14:48PM +0530, Anshuman Khandual wrote:
>> [pgd|p4d]_present() are inverse to their corresponding [pgd|p4d]_none().
>
> Maybe their implementations happen to be inverse today, but the semantic
> of pXX_present() is not the inverse of the semantic of pXX_none(). In
> general, !pXX_none() does not imply pXX_present().
Agreed.
>
>> So [pgd|p4d]_present() test right after corresponding [pgd|p4d]_none()
>> inverse test does not make sense. Hence just drop these redundant
>> checks.
>
> I think the checks make sense in abstract, even if they're redundant
> today
Okay.
>
> Is there any reason to remove these specific case?
Just for optimization.
>
> Surely the compiler optimizes these out when they're redundant?
Agreed. Although wondering if p4d_present() is the right thing to test.
Should it be replaced with a p4d_bad() check instead because subsequent
calls into either unmap_hotplug_pud_range() or free_empty_pud_table()
requires given entry to be a table to proceed further successfully.
>
> Mark.
>
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Ard Biesheuvel <ardb@kernel.org>
>> Cc: Ryan Roberts <ryan.roberts@arm.com>
>> Cc: Mark Rutland <mark.rutland@arm.com>
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> 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, unsigned long addr,
>> if (p4d_none(p4d))
>> continue;
>>
>> - WARN_ON(!p4d_present(p4d));
>> unmap_hotplug_pud_range(p4dp, addr, next, free_mapped, altmap);
>> } while (addr = next, addr < end);
>> }
>> @@ -978,7 +977,6 @@ static void unmap_hotplug_range(unsigned long addr, unsigned long end,
>> if (pgd_none(pgd))
>> continue;
>>
>> - WARN_ON(!pgd_present(pgd));
>> unmap_hotplug_p4d_range(pgdp, addr, next, free_mapped, altmap);
>> } while (addr = next, addr < end);
>> }
>> @@ -1114,7 +1112,6 @@ static void free_empty_p4d_table(pgd_t *pgdp, unsigned long addr,
>> if (p4d_none(p4d))
>> continue;
>>
>> - WARN_ON(!p4d_present(p4d));
>> free_empty_pud_table(p4dp, addr, next, floor, ceiling);
>> } while (addr = next, addr < end);
>>
>> @@ -1153,7 +1150,6 @@ static void free_empty_tables(unsigned long addr, unsigned long end,
>> if (pgd_none(pgd))
>> continue;
>>
>> - WARN_ON(!pgd_present(pgd));
>> free_empty_p4d_table(pgdp, addr, next, floor, ceiling);
>> } while (addr = next, addr < end);
>> }
>> --
>> 2.30.2
>>
next prev parent reply other threads:[~2025-03-19 6:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 9:44 [PATCH 0/2] arm64/mm/hotplug: Drop some redundant WARN_ON() Anshuman Khandual
2025-02-21 9:44 ` [PATCH 1/2] arm64/mm/hotplug: Drop redundant [pgd|p4d]_present() Anshuman Khandual
2025-02-21 17:37 ` Dev Jain
2025-03-18 11:16 ` Mark Rutland
2025-03-19 6:02 ` Anshuman Khandual [this message]
2025-02-21 9:44 ` [PATCH 2/2] arm64/mm/hotplug: Replace pxx_present() with pxx_valid() Anshuman Khandual
2025-03-18 5:54 ` [PATCH 0/2] arm64/mm/hotplug: Drop some redundant WARN_ON() Anshuman Khandual
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1c35a8c5-324b-4c60-9bf1-a5414481e5ad@arm.com \
--to=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=ryan.roberts@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox