* [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
@ 2022-11-25 3:45 Anshuman Khandual
2022-11-28 6:07 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2022-11-25 3:45 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel
In __gmap_segment_gaddr() pmd level page table page is being extracted from
the pmd pointer, similar to pmd_pgtable_page() implementation. This reduces
some redundancy by directly using pmd_pgtable_page() instead, though first
making it available.
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on v6.1-rc6 but after the following patch. Build tested for
s390 plaform (defconfig).
https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/
arch/s390/mm/gmap.c | 5 ++---
include/linux/mm.h | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index 02d15c8dc92e..8947451ae021 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
static unsigned long __gmap_segment_gaddr(unsigned long *entry)
{
struct page *page;
- unsigned long offset, mask;
+ unsigned long offset;
offset = (unsigned long) entry / sizeof(unsigned long);
offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE;
- mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
- page = virt_to_page((void *)((unsigned long) entry & mask));
+ page = pmd_pgtable_page((pmd_t *) entry);
return page->index + offset;
}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e9e387caffac..5ead9e997510 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
#if USE_SPLIT_PMD_PTLOCKS
-static struct page *pmd_pgtable_page(pmd_t *pmd)
+static inline struct page *pmd_pgtable_page(pmd_t *pmd)
{
unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
return virt_to_page((void *)((unsigned long) pmd & mask));
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
2022-11-25 3:45 [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr() Anshuman Khandual
@ 2022-11-28 6:07 ` Alexander Gordeev
2022-11-28 6:31 ` Anshuman Khandual
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2022-11-28 6:07 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-mm, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel
On Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote:
Hi Anshuman,
> In __gmap_segment_gaddr() pmd level page table page is being extracted from
> the pmd pointer, similar to pmd_pgtable_page() implementation. This reduces
> some redundancy by directly using pmd_pgtable_page() instead, though first
> making it available.
[...]
> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
> index 02d15c8dc92e..8947451ae021 100644
> --- a/arch/s390/mm/gmap.c
> +++ b/arch/s390/mm/gmap.c
> @@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
> static unsigned long __gmap_segment_gaddr(unsigned long *entry)
> {
> struct page *page;
> - unsigned long offset, mask;
> + unsigned long offset;
>
> offset = (unsigned long) entry / sizeof(unsigned long);
> offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE;
> - mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> - page = virt_to_page((void *)((unsigned long) entry & mask));
> + page = pmd_pgtable_page((pmd_t *) entry);
> return page->index + offset;
> }
Looks okay to me.
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index e9e387caffac..5ead9e997510 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
>
> #if USE_SPLIT_PMD_PTLOCKS
>
> -static struct page *pmd_pgtable_page(pmd_t *pmd)
> +static inline struct page *pmd_pgtable_page(pmd_t *pmd)
> {
> unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> return virt_to_page((void *)((unsigned long) pmd & mask));
This chunk does not appear to belong to this patch.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
2022-11-28 6:07 ` Alexander Gordeev
@ 2022-11-28 6:31 ` Anshuman Khandual
2022-11-28 7:13 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2022-11-28 6:31 UTC (permalink / raw)
To: Alexander Gordeev
Cc: linux-mm, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel
On 11/28/22 11:37, Alexander Gordeev wrote:
> On Fri, Nov 25, 2022 at 09:15:02AM +0530, Anshuman Khandual wrote:
>
> Hi Anshuman,
>
>> In __gmap_segment_gaddr() pmd level page table page is being extracted from
>> the pmd pointer, similar to pmd_pgtable_page() implementation. This reduces
>> some redundancy by directly using pmd_pgtable_page() instead, though first
>> making it available.
>
> [...]
>
>> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
>> index 02d15c8dc92e..8947451ae021 100644
>> --- a/arch/s390/mm/gmap.c
>> +++ b/arch/s390/mm/gmap.c
>> @@ -336,12 +336,11 @@ static int gmap_alloc_table(struct gmap *gmap, unsigned long *table,
>> static unsigned long __gmap_segment_gaddr(unsigned long *entry)
>> {
>> struct page *page;
>> - unsigned long offset, mask;
>> + unsigned long offset;
>>
>> offset = (unsigned long) entry / sizeof(unsigned long);
>> offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE;
>> - mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
>> - page = virt_to_page((void *)((unsigned long) entry & mask));
>> + page = pmd_pgtable_page((pmd_t *) entry);
>> return page->index + offset;
>> }
>
> Looks okay to me.
>
>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>> index e9e387caffac..5ead9e997510 100644
>> --- a/include/linux/mm.h
>> +++ b/include/linux/mm.h
>> @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
>>
>> #if USE_SPLIT_PMD_PTLOCKS
>>
>> -static struct page *pmd_pgtable_page(pmd_t *pmd)
>> +static inline struct page *pmd_pgtable_page(pmd_t *pmd)
>> {
>> unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
>> return virt_to_page((void *)((unsigned long) pmd & mask));
>
> This chunk does not appear to belong to this patch.
Should not this helper be made a 'static inline' before using it else where ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
2022-11-28 6:31 ` Anshuman Khandual
@ 2022-11-28 7:13 ` Alexander Gordeev
2022-11-28 7:43 ` Anshuman Khandual
0 siblings, 1 reply; 6+ messages in thread
From: Alexander Gordeev @ 2022-11-28 7:13 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-mm, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel
On Mon, Nov 28, 2022 at 12:01:06PM +0530, Anshuman Khandual wrote:
> >> diff --git a/include/linux/mm.h b/include/linux/mm.h
> >> index e9e387caffac..5ead9e997510 100644
> >> --- a/include/linux/mm.h
> >> +++ b/include/linux/mm.h
> >> @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
> >>
> >> #if USE_SPLIT_PMD_PTLOCKS
> >>
> >> -static struct page *pmd_pgtable_page(pmd_t *pmd)
> >> +static inline struct page *pmd_pgtable_page(pmd_t *pmd)
> >> {
> >> unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> >> return virt_to_page((void *)((unsigned long) pmd & mask));
> >
> > This chunk does not appear to belong to this patch.
>
> Should not this helper be made a 'static inline' before using it else where ?
Probably yes, but it is not kvm s390-specific change.
I guess, you wanted to make it together or as a follow-up to this one?
https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
2022-11-28 7:13 ` Alexander Gordeev
@ 2022-11-28 7:43 ` Anshuman Khandual
2022-11-28 8:18 ` Alexander Gordeev
0 siblings, 1 reply; 6+ messages in thread
From: Anshuman Khandual @ 2022-11-28 7:43 UTC (permalink / raw)
To: Alexander Gordeev
Cc: linux-mm, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel
On 11/28/22 12:43, Alexander Gordeev wrote:
> On Mon, Nov 28, 2022 at 12:01:06PM +0530, Anshuman Khandual wrote:
>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h
>>>> index e9e387caffac..5ead9e997510 100644
>>>> --- a/include/linux/mm.h
>>>> +++ b/include/linux/mm.h
>>>> @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
>>>>
>>>> #if USE_SPLIT_PMD_PTLOCKS
>>>>
>>>> -static struct page *pmd_pgtable_page(pmd_t *pmd)
>>>> +static inline struct page *pmd_pgtable_page(pmd_t *pmd)
>>>> {
>>>> unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
>>>> return virt_to_page((void *)((unsigned long) pmd & mask));
>>>
>>> This chunk does not appear to belong to this patch.
>>
>> Should not this helper be made a 'static inline' before using it else where ?
>
> Probably yes, but it is not kvm s390-specific change.
Right, just that the s390 change here is the first instance where this helper
is being used outside the header, hence kept them together.
>
> I guess, you wanted to make it together or as a follow-up to this one?
> https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/
>
Unless too much trouble, could we just keep it here as proposed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr()
2022-11-28 7:43 ` Anshuman Khandual
@ 2022-11-28 8:18 ` Alexander Gordeev
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Gordeev @ 2022-11-28 8:18 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-mm, Christian Borntraeger, David Hildenbrand,
Heiko Carstens, Andrew Morton, kvm, linux-s390, linux-kernel,
Gerald Schaefer
On Mon, Nov 28, 2022 at 01:13:45PM +0530, Anshuman Khandual wrote:
> >>>> index e9e387caffac..5ead9e997510 100644
> >>>> --- a/include/linux/mm.h
> >>>> +++ b/include/linux/mm.h
> >>>> @@ -2403,7 +2403,7 @@ static inline void pgtable_pte_page_dtor(struct page *page)
> >>>>
> >>>> #if USE_SPLIT_PMD_PTLOCKS
> >>>>
> >>>> -static struct page *pmd_pgtable_page(pmd_t *pmd)
> >>>> +static inline struct page *pmd_pgtable_page(pmd_t *pmd)
> >>>> {
> >>>> unsigned long mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1);
> >>>> return virt_to_page((void *)((unsigned long) pmd & mask));
> >>>
> >>> This chunk does not appear to belong to this patch.
> >>
> >> Should not this helper be made a 'static inline' before using it else where ?
> >
> > Probably yes, but it is not kvm s390-specific change.
>
> Right, just that the s390 change here is the first instance where this helper
> is being used outside the header, hence kept them together.
>
> >
> > I guess, you wanted to make it together or as a follow-up to this one?
> > https://lore.kernel.org/all/20221124131641.1523772-1-anshuman.khandual@arm.com/
> >
> Unless too much trouble, could we just keep it here as proposed.
For s390 part:
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-28 8:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 3:45 [PATCH] s390/mm: Use pmd_pgtable_page() helper in __gmap_segment_gaddr() Anshuman Khandual
2022-11-28 6:07 ` Alexander Gordeev
2022-11-28 6:31 ` Anshuman Khandual
2022-11-28 7:13 ` Alexander Gordeev
2022-11-28 7:43 ` Anshuman Khandual
2022-11-28 8:18 ` Alexander Gordeev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.