public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] arm64/mm: Drop redundant addr increment in set_huge_pte_at()
@ 2025-07-15  4:39 Anshuman Khandual
  2025-07-15  5:58 ` Dev Jain
  0 siblings, 1 reply; 3+ messages in thread
From: Anshuman Khandual @ 2025-07-15  4:39 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, Ryan Roberts,
	linux-kernel

The 'addr' need not be incremented while operating on single entry basis as
BBM is not required for such updates.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Ryan Roberts <ryan.roberts@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/hugetlbpage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
index 0c8737f4f2ce..1d90a7e75333 100644
--- a/arch/arm64/mm/hugetlbpage.c
+++ b/arch/arm64/mm/hugetlbpage.c
@@ -225,7 +225,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
 	ncontig = num_contig_ptes(sz, &pgsize);
 
 	if (!pte_present(pte)) {
-		for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)
+		for (i = 0; i < ncontig; i++, ptep++)
 			__set_ptes_anysz(mm, ptep, pte, 1, pgsize);
 		return;
 	}
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64/mm: Drop redundant addr increment in set_huge_pte_at()
  2025-07-15  4:39 [PATCH] arm64/mm: Drop redundant addr increment in set_huge_pte_at() Anshuman Khandual
@ 2025-07-15  5:58 ` Dev Jain
  2025-07-15  6:36   ` Anshuman Khandual
  0 siblings, 1 reply; 3+ messages in thread
From: Dev Jain @ 2025-07-15  5:58 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, Ryan Roberts, linux-kernel


On 15/07/25 10:09 am, Anshuman Khandual wrote:
> The 'addr' need not be incremented while operating on single entry basis as
> BBM is not required for such updates.

"while operating on a single entry basis" should be replaced with
"when transitioning from invalid to valid pte"; BBM is required
for single entry updates when the cont bit is set, as described
in the comment immediately below. In fact, let us not even mention
BBM at all - the reasoning is that the code is written in a way
that, the loop incrementing addr, immediately has a return after
it, and it does not actually use the addr, so let's drop the
increment. It is not immediately obvious from the commit description
that the addr is passed ultimately to flush_tlb_range friends which
is involved in BBM.

Reviewed-by: Dev Jain <dev.jain@arm.com>

>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Ryan Roberts <ryan.roberts@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/hugetlbpage.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
> index 0c8737f4f2ce..1d90a7e75333 100644
> --- a/arch/arm64/mm/hugetlbpage.c
> +++ b/arch/arm64/mm/hugetlbpage.c
> @@ -225,7 +225,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
>   	ncontig = num_contig_ptes(sz, &pgsize);
>   
>   	if (!pte_present(pte)) {
> -		for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)
> +		for (i = 0; i < ncontig; i++, ptep++)
>   			__set_ptes_anysz(mm, ptep, pte, 1, pgsize);
>   		return;
>   	}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64/mm: Drop redundant addr increment in set_huge_pte_at()
  2025-07-15  5:58 ` Dev Jain
@ 2025-07-15  6:36   ` Anshuman Khandual
  0 siblings, 0 replies; 3+ messages in thread
From: Anshuman Khandual @ 2025-07-15  6:36 UTC (permalink / raw)
  To: Dev Jain, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, Ryan Roberts, linux-kernel



On 15/07/25 11:28 AM, Dev Jain wrote:
> 
> On 15/07/25 10:09 am, Anshuman Khandual wrote:
>> The 'addr' need not be incremented while operating on single entry basis as
>> BBM is not required for such updates.
> 
> "while operating on a single entry basis" should be replaced with
> "when transitioning from invalid to valid pte"; BBM is required
> for single entry updates when the cont bit is set, as described
> in the comment immediately below. In fact, let us not even mention
> BBM at all - the reasoning is that the code is written in a way
> that, the loop incrementing addr, immediately has a return after
> it, and it does not actually use the addr, so let's drop the
> increment. It is not immediately obvious from the commit description
> that the addr is passed ultimately to flush_tlb_range friends which
> is involved in BBM.

Agreed, the mention about BBM can be dropped as it is not really
relevant. Rather 'addr' variable being unused in the conditional
block, which exits right after is the real reason. I will update
the commit description as required.  

> 
> Reviewed-by: Dev Jain <dev.jain@arm.com>
> 
>>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Ryan Roberts <ryan.roberts@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/hugetlbpage.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c
>> index 0c8737f4f2ce..1d90a7e75333 100644
>> --- a/arch/arm64/mm/hugetlbpage.c
>> +++ b/arch/arm64/mm/hugetlbpage.c
>> @@ -225,7 +225,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
>>       ncontig = num_contig_ptes(sz, &pgsize);
>>         if (!pte_present(pte)) {
>> -        for (i = 0; i < ncontig; i++, ptep++, addr += pgsize)
>> +        for (i = 0; i < ncontig; i++, ptep++)
>>               __set_ptes_anysz(mm, ptep, pte, 1, pgsize);
>>           return;
>>       }


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-15  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15  4:39 [PATCH] arm64/mm: Drop redundant addr increment in set_huge_pte_at() Anshuman Khandual
2025-07-15  5:58 ` Dev Jain
2025-07-15  6:36   ` Anshuman Khandual

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox