* [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping()
@ 2019-11-03 12:35 Masahiro Yamada
2019-11-05 9:37 ` Mark Rutland
2019-11-06 11:17 ` Catalin Marinas
0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2019-11-03 12:35 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, linux-arm-kernel
Cc: Masahiro Yamada, Andrew Morton, Anshuman Khandual,
Ard Biesheuvel, David Hildenbrand, Hsin-Yi Wang, Mark Rutland,
Robin Murphy, Steve Capper, Thomas Gleixner, Yu Zhao,
linux-kernel
Calculate the page-aligned end address more simply.
The local variable, "length" is unneeded.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
arch/arm64/mm/mmu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 60c929f3683b..a9f541912289 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -338,7 +338,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
phys_addr_t (*pgtable_alloc)(int),
int flags)
{
- unsigned long addr, length, end, next;
+ unsigned long addr, end, next;
pgd_t *pgdp = pgd_offset_raw(pgdir, virt);
/*
@@ -350,9 +350,8 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
phys &= PAGE_MASK;
addr = virt & PAGE_MASK;
- length = PAGE_ALIGN(size + (virt & ~PAGE_MASK));
+ end = PAGE_ALIGN(virt + size);
- end = addr + length;
do {
next = pgd_addr_end(addr, end);
alloc_init_pud(pgdp, addr, next, phys, prot, pgtable_alloc,
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping()
2019-11-03 12:35 [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping() Masahiro Yamada
@ 2019-11-05 9:37 ` Mark Rutland
2019-11-06 11:17 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2019-11-05 9:37 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Catalin Marinas, Will Deacon, linux-arm-kernel, Andrew Morton,
Anshuman Khandual, Ard Biesheuvel, David Hildenbrand,
Hsin-Yi Wang, Robin Murphy, Steve Capper, Thomas Gleixner,
Yu Zhao, linux-kernel
On Sun, Nov 03, 2019 at 09:35:58PM +0900, Masahiro Yamada wrote:
> Calculate the page-aligned end address more simply.
>
> The local variable, "length" is unneeded.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> arch/arm64/mm/mmu.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 60c929f3683b..a9f541912289 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -338,7 +338,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
> phys_addr_t (*pgtable_alloc)(int),
> int flags)
> {
> - unsigned long addr, length, end, next;
> + unsigned long addr, end, next;
> pgd_t *pgdp = pgd_offset_raw(pgdir, virt);
>
> /*
> @@ -350,9 +350,8 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
>
> phys &= PAGE_MASK;
> addr = virt & PAGE_MASK;
> - length = PAGE_ALIGN(size + (virt & ~PAGE_MASK));
> + end = PAGE_ALIGN(virt + size);
>
> - end = addr + length;
While looking at this, I got confused by the old code and thought that
there was an existing bug, but I now see that's not the case, and the
old and new code are equivalent.
The new code looks cleaner, and leaves less room for confusion, so I
think that's preferable:
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> do {
> next = pgd_addr_end(addr, end);
> alloc_init_pud(pgdp, addr, next, phys, prot, pgtable_alloc,
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping()
2019-11-03 12:35 [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping() Masahiro Yamada
2019-11-05 9:37 ` Mark Rutland
@ 2019-11-06 11:17 ` Catalin Marinas
1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2019-11-06 11:17 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Will Deacon, linux-arm-kernel, Andrew Morton, Anshuman Khandual,
Ard Biesheuvel, David Hildenbrand, Hsin-Yi Wang, Mark Rutland,
Robin Murphy, Steve Capper, Thomas Gleixner, Yu Zhao,
linux-kernel
On Sun, Nov 03, 2019 at 09:35:58PM +0900, Masahiro Yamada wrote:
> Calculate the page-aligned end address more simply.
>
> The local variable, "length" is unneeded.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Queued for 5.5. Thanks.
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-06 11:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-03 12:35 [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping() Masahiro Yamada
2019-11-05 9:37 ` Mark Rutland
2019-11-06 11:17 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).