* [PATCH] arm64/mm: Use phys_to_page() to access pgtable memory
@ 2020-04-24 4:48 Gavin Shan
2020-04-24 9:22 ` Mark Rutland
0 siblings, 1 reply; 3+ messages in thread
From: Gavin Shan @ 2020-04-24 4:48 UTC (permalink / raw)
To: linux-arm-kernel
Cc: linux-kernel, catalin.marinas, will, mark.rutland, shan.gavin
The macros {pgd, pud, pmd}_page() retrieves the page struct of the
corresponding page frame, which is reserved as page table. There
is already a macro (phys_to_page), defined in memory.h, to convert
the physical address to the page struct. So it's reasonable to
use that in pgtable.h.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
arch/arm64/include/asm/pgtable.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 538c85e62f86..8c20e2bd6287 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -508,7 +508,7 @@ static inline void pte_unmap(pte_t *pte) { }
#define pte_set_fixmap_offset(pmd, addr) pte_set_fixmap(pte_offset_phys(pmd, addr))
#define pte_clear_fixmap() clear_fixmap(FIX_PTE)
-#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(__pmd_to_phys(pmd)))
+#define pmd_page(pmd) phys_to_page(__pmd_to_phys(pmd))
/* use ONLY for statically allocated translation tables */
#define pte_offset_kimg(dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr))))
@@ -566,7 +566,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
#define pmd_set_fixmap_offset(pud, addr) pmd_set_fixmap(pmd_offset_phys(pud, addr))
#define pmd_clear_fixmap() clear_fixmap(FIX_PMD)
-#define pud_page(pud) pfn_to_page(__phys_to_pfn(__pud_to_phys(pud)))
+#define pud_page(pud) phys_to_page(__pud_to_phys(pud))
/* use ONLY for statically allocated translation tables */
#define pmd_offset_kimg(dir,addr) ((pmd_t *)__phys_to_kimg(pmd_offset_phys((dir), (addr))))
@@ -624,7 +624,7 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
#define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr))
#define pud_clear_fixmap() clear_fixmap(FIX_PUD)
-#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(__pgd_to_phys(pgd)))
+#define pgd_page(pgd) phys_to_page(__pgd_to_phys(pgd))
/* use ONLY for statically allocated translation tables */
#define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64/mm: Use phys_to_page() to access pgtable memory
2020-04-24 4:48 [PATCH] arm64/mm: Use phys_to_page() to access pgtable memory Gavin Shan
@ 2020-04-24 9:22 ` Mark Rutland
2020-04-27 23:45 ` Gavin Shan
0 siblings, 1 reply; 3+ messages in thread
From: Mark Rutland @ 2020-04-24 9:22 UTC (permalink / raw)
To: Gavin Shan
Cc: linux-arm-kernel, linux-kernel, catalin.marinas, will, shan.gavin
On Fri, Apr 24, 2020 at 02:48:54PM +1000, Gavin Shan wrote:
> The macros {pgd, pud, pmd}_page() retrieves the page struct of the
> corresponding page frame, which is reserved as page table. There
> is already a macro (phys_to_page), defined in memory.h, to convert
> the physical address to the page struct. So it's reasonable to
> use that in pgtable.h.
>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
It might be worth pointing out that phys_to_page() is defined as:
#define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
... so this is obviously equivalent.
Given that, and given we already explicitly include <asm/memory.h>, this
looks like a nice cleanup to me.
With or without the commit message addition:
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> arch/arm64/include/asm/pgtable.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index 538c85e62f86..8c20e2bd6287 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -508,7 +508,7 @@ static inline void pte_unmap(pte_t *pte) { }
> #define pte_set_fixmap_offset(pmd, addr) pte_set_fixmap(pte_offset_phys(pmd, addr))
> #define pte_clear_fixmap() clear_fixmap(FIX_PTE)
>
> -#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(__pmd_to_phys(pmd)))
> +#define pmd_page(pmd) phys_to_page(__pmd_to_phys(pmd))
>
> /* use ONLY for statically allocated translation tables */
> #define pte_offset_kimg(dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr))))
> @@ -566,7 +566,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
> #define pmd_set_fixmap_offset(pud, addr) pmd_set_fixmap(pmd_offset_phys(pud, addr))
> #define pmd_clear_fixmap() clear_fixmap(FIX_PMD)
>
> -#define pud_page(pud) pfn_to_page(__phys_to_pfn(__pud_to_phys(pud)))
> +#define pud_page(pud) phys_to_page(__pud_to_phys(pud))
>
> /* use ONLY for statically allocated translation tables */
> #define pmd_offset_kimg(dir,addr) ((pmd_t *)__phys_to_kimg(pmd_offset_phys((dir), (addr))))
> @@ -624,7 +624,7 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
> #define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr))
> #define pud_clear_fixmap() clear_fixmap(FIX_PUD)
>
> -#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(__pgd_to_phys(pgd)))
> +#define pgd_page(pgd) phys_to_page(__pgd_to_phys(pgd))
>
> /* use ONLY for statically allocated translation tables */
> #define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] arm64/mm: Use phys_to_page() to access pgtable memory
2020-04-24 9:22 ` Mark Rutland
@ 2020-04-27 23:45 ` Gavin Shan
0 siblings, 0 replies; 3+ messages in thread
From: Gavin Shan @ 2020-04-27 23:45 UTC (permalink / raw)
To: Mark Rutland
Cc: linux-arm-kernel, linux-kernel, catalin.marinas, will, shan.gavin
Hi Mark,
On 4/24/20 7:22 PM, Mark Rutland wrote:
> On Fri, Apr 24, 2020 at 02:48:54PM +1000, Gavin Shan wrote:
>> The macros {pgd, pud, pmd}_page() retrieves the page struct of the
>> corresponding page frame, which is reserved as page table. There
>> is already a macro (phys_to_page), defined in memory.h, to convert
>> the physical address to the page struct. So it's reasonable to
>> use that in pgtable.h.
>>
>> Signed-off-by: Gavin Shan <gshan@redhat.com>
>
> It might be worth pointing out that phys_to_page() is defined as:
>
> #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys)))
>
> ... so this is obviously equivalent.
>
> Given that, and given we already explicitly include <asm/memory.h>, this
> looks like a nice cleanup to me.
>
> With or without the commit message addition:
>
> Reviewed-by: Mark Rutland <mark.rutland@arm.com>
>
> Mark.
>
Thanks for the comments. I will post v2 shortly, which has the improved
commit log and your reviewed-by.
Thanks,
Gavin
>> ---
>> arch/arm64/include/asm/pgtable.h | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
>> index 538c85e62f86..8c20e2bd6287 100644
>> --- a/arch/arm64/include/asm/pgtable.h
>> +++ b/arch/arm64/include/asm/pgtable.h
>> @@ -508,7 +508,7 @@ static inline void pte_unmap(pte_t *pte) { }
>> #define pte_set_fixmap_offset(pmd, addr) pte_set_fixmap(pte_offset_phys(pmd, addr))
>> #define pte_clear_fixmap() clear_fixmap(FIX_PTE)
>>
>> -#define pmd_page(pmd) pfn_to_page(__phys_to_pfn(__pmd_to_phys(pmd)))
>> +#define pmd_page(pmd) phys_to_page(__pmd_to_phys(pmd))
>>
>> /* use ONLY for statically allocated translation tables */
>> #define pte_offset_kimg(dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr))))
>> @@ -566,7 +566,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud)
>> #define pmd_set_fixmap_offset(pud, addr) pmd_set_fixmap(pmd_offset_phys(pud, addr))
>> #define pmd_clear_fixmap() clear_fixmap(FIX_PMD)
>>
>> -#define pud_page(pud) pfn_to_page(__phys_to_pfn(__pud_to_phys(pud)))
>> +#define pud_page(pud) phys_to_page(__pud_to_phys(pud))
>>
>> /* use ONLY for statically allocated translation tables */
>> #define pmd_offset_kimg(dir,addr) ((pmd_t *)__phys_to_kimg(pmd_offset_phys((dir), (addr))))
>> @@ -624,7 +624,7 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
>> #define pud_set_fixmap_offset(pgd, addr) pud_set_fixmap(pud_offset_phys(pgd, addr))
>> #define pud_clear_fixmap() clear_fixmap(FIX_PUD)
>>
>> -#define pgd_page(pgd) pfn_to_page(__phys_to_pfn(__pgd_to_phys(pgd)))
>> +#define pgd_page(pgd) phys_to_page(__pgd_to_phys(pgd))
>>
>> /* use ONLY for statically allocated translation tables */
>> #define pud_offset_kimg(dir,addr) ((pud_t *)__phys_to_kimg(pud_offset_phys((dir), (addr))))
>> --
>> 2.23.0
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-27 23:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 4:48 [PATCH] arm64/mm: Use phys_to_page() to access pgtable memory Gavin Shan
2020-04-24 9:22 ` Mark Rutland
2020-04-27 23:45 ` Gavin Shan
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).