* [PATCH] s390/mm: get total ram pages from memblock
@ 2024-06-16 1:35 Wei Yang
2024-06-18 9:57 ` David Hildenbrand
0 siblings, 1 reply; 3+ messages in thread
From: Wei Yang @ 2024-06-16 1:35 UTC (permalink / raw)
To: agordeev, gerald.schaefer, hca, gor, borntraeger, svens
Cc: linux-s390, linux-mm, Wei Yang, Mike Rapoport, David Hildenbrand
On s390, zero page's size relies on total ram pages.
Since we plan to move the accounting into __free_pages_core(),
totalram_pages may not represent the total usable pages on system
at this point when defer_init is enabled.
We can get the total usable pages from memblock directly. The size maybe
not accurate due to the alignment, but enough for the calculation.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Mike Rapoport (IBM) <rppt@kernel.org>
CC: David Hildenbrand <david@redhat.com>
---
Not tested on a machine, hope it is fine.
---
arch/s390/mm/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index e769d2726f4e..d811ffa5e147 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -65,12 +65,13 @@ static void __init setup_zero_pages(void)
unsigned int order;
struct page *page;
int i;
+ unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size());
/* Latest machines require a mapping granularity of 512KB */
order = 7;
/* Limit number of empty zero pages for small memory sizes */
- while (order > 2 && (totalram_pages() >> 10) < (1UL << order))
+ while (order > 2 && (total_pages >> 10) < (1UL << order))
order--;
empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] s390/mm: get total ram pages from memblock
2024-06-16 1:35 [PATCH] s390/mm: get total ram pages from memblock Wei Yang
@ 2024-06-18 9:57 ` David Hildenbrand
2024-06-19 22:43 ` Vasily Gorbik
0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand @ 2024-06-18 9:57 UTC (permalink / raw)
To: Wei Yang, agordeev, gerald.schaefer, hca, gor, borntraeger, svens
Cc: linux-s390, linux-mm, Mike Rapoport
On 16.06.24 03:35, Wei Yang wrote:
> On s390, zero page's size relies on total ram pages.
>
> Since we plan to move the accounting into __free_pages_core(),
> totalram_pages may not represent the total usable pages on system
> at this point when defer_init is enabled.
>
> We can get the total usable pages from memblock directly. The size maybe
> not accurate due to the alignment, but enough for the calculation.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Mike Rapoport (IBM) <rppt@kernel.org>
> CC: David Hildenbrand <david@redhat.com>
>
> ---
> Not tested on a machine, hope it is fine.
> ---
> arch/s390/mm/init.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index e769d2726f4e..d811ffa5e147 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -65,12 +65,13 @@ static void __init setup_zero_pages(void)
> unsigned int order;
> struct page *page;
> int i;
> + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size());
>
> /* Latest machines require a mapping granularity of 512KB */
> order = 7;
>
> /* Limit number of empty zero pages for small memory sizes */
> - while (order > 2 && (totalram_pages() >> 10) < (1UL << order))
> + while (order > 2 && (total_pages >> 10) < (1UL << order))
> order--;
>
> empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
I suspect that this is good enough as an approximation for that purpose.
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] s390/mm: get total ram pages from memblock
2024-06-18 9:57 ` David Hildenbrand
@ 2024-06-19 22:43 ` Vasily Gorbik
0 siblings, 0 replies; 3+ messages in thread
From: Vasily Gorbik @ 2024-06-19 22:43 UTC (permalink / raw)
To: David Hildenbrand
Cc: Wei Yang, agordeev, gerald.schaefer, hca, borntraeger, svens,
linux-s390, linux-mm, Mike Rapoport
On Tue, Jun 18, 2024 at 11:57:19AM +0200, David Hildenbrand wrote:
> On 16.06.24 03:35, Wei Yang wrote:
> > On s390, zero page's size relies on total ram pages.
> >
> > Since we plan to move the accounting into __free_pages_core(),
> > totalram_pages may not represent the total usable pages on system
> > at this point when defer_init is enabled.
> >
> > We can get the total usable pages from memblock directly. The size maybe
> > not accurate due to the alignment, but enough for the calculation.
> >
> > Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> > CC: Mike Rapoport (IBM) <rppt@kernel.org>
> > CC: David Hildenbrand <david@redhat.com>
> >
> > ---
> > Not tested on a machine, hope it is fine.
> > ---
> > arch/s390/mm/init.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> > index e769d2726f4e..d811ffa5e147 100644
> > --- a/arch/s390/mm/init.c
> > +++ b/arch/s390/mm/init.c
> > @@ -65,12 +65,13 @@ static void __init setup_zero_pages(void)
> > unsigned int order;
> > struct page *page;
> > int i;
> > + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size());
> > /* Latest machines require a mapping granularity of 512KB */
> > order = 7;
> > /* Limit number of empty zero pages for small memory sizes */
> > - while (order > 2 && (totalram_pages() >> 10) < (1UL << order))
> > + while (order > 2 && (total_pages >> 10) < (1UL << order))
> > order--;
> > empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
>
> I suspect that this is good enough as an approximation for that purpose.
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-19 22:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-16 1:35 [PATCH] s390/mm: get total ram pages from memblock Wei Yang
2024-06-18 9:57 ` David Hildenbrand
2024-06-19 22:43 ` Vasily Gorbik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox