linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: show_mem: show number of zspages in show_free_areas
@ 2025-09-01 18:37 Thadeu Lima de Souza Cascardo
  2025-09-01 18:54 ` Vlastimil Babka
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2025-09-01 18:37 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, Andrew Morton, Vlastimil Babka, Suren Baghdasaryan,
	Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan,
	kernel-dev, Thadeu Lima de Souza Cascardo

When OOM is triggered, it will show where the pages might be for each zone.
When using zram, it might look like lots of pages are missing. After this
patch, zspages are shown as below.

[   48.792859] Node 0 DMA free:2812kB boost:0kB min:60kB low:72kB high:84kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB zspages:11160kB present:15992kB managed:15360kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[   48.792962] lowmem_reserve[]: 0 956 956 956 956
[   48.792988] Node 0 DMA32 free:3512kB boost:0kB min:3912kB low:4888kB high:5864kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:28kB active_file:8kB inactive_file:16kB unevictable:0kB writepending:0kB zspages:916780kB present:1032064kB managed:978944kB mlocked:0kB bounce:0kB free_pcp:500kB local_pcp:248kB free_cma:0kB
[   48.793118] lowmem_reserve[]: 0 0 0 0 0

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
---
 mm/show_mem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/show_mem.c b/mm/show_mem.c
index 41999e94a56d..ecf20a93ea54 100644
--- a/mm/show_mem.c
+++ b/mm/show_mem.c
@@ -310,6 +310,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
 			" inactive_file:%lukB"
 			" unevictable:%lukB"
 			" writepending:%lukB"
+			" zspages:%lukB"
 			" present:%lukB"
 			" managed:%lukB"
 			" mlocked:%lukB"
@@ -332,6 +333,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
 			K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
 			K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
 			K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
+			K(zone_page_state(zone, NR_ZSPAGES)),
 			K(zone->present_pages),
 			K(zone_managed_pages(zone)),
 			K(zone_page_state(zone, NR_MLOCK)),
-- 
2.47.2



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

* Re: [PATCH] mm: show_mem: show number of zspages in show_free_areas
  2025-09-01 18:37 [PATCH] mm: show_mem: show number of zspages in show_free_areas Thadeu Lima de Souza Cascardo
@ 2025-09-01 18:54 ` Vlastimil Babka
  2025-09-02  2:10   ` Sergey Senozhatsky
  2025-09-02  1:49 ` SeongJae Park
  2025-09-02  4:56 ` Lorenzo Stoakes
  2 siblings, 1 reply; 6+ messages in thread
From: Vlastimil Babka @ 2025-09-01 18:54 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo, linux-kernel
  Cc: linux-mm, Andrew Morton, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan, kernel-dev, Minchan Kim,
	Sergey Senozhatsky, Yosry Ahmed, Nhat Pham, Chengming Zhou

On 9/1/25 20:37, Thadeu Lima de Souza Cascardo wrote:
> When OOM is triggered, it will show where the pages might be for each zone.
> When using zram, it might look like lots of pages are missing. After this
> patch, zspages are shown as below.

AFAIK zswap can also use zsmalloc so this would be reported for zswap with
the same effect too, right?

> [   48.792859] Node 0 DMA free:2812kB boost:0kB min:60kB low:72kB high:84kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB zspages:11160kB present:15992kB managed:15360kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
> [   48.792962] lowmem_reserve[]: 0 956 956 956 956
> [   48.792988] Node 0 DMA32 free:3512kB boost:0kB min:3912kB low:4888kB high:5864kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:28kB active_file:8kB inactive_file:16kB unevictable:0kB writepending:0kB zspages:916780kB present:1032064kB managed:978944kB mlocked:0kB bounce:0kB free_pcp:500kB local_pcp:248kB free_cma:0kB
> [   48.793118] lowmem_reserve[]: 0 0 0 0 0
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  mm/show_mem.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/show_mem.c b/mm/show_mem.c
> index 41999e94a56d..ecf20a93ea54 100644
> --- a/mm/show_mem.c
> +++ b/mm/show_mem.c
> @@ -310,6 +310,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			" inactive_file:%lukB"
>  			" unevictable:%lukB"
>  			" writepending:%lukB"
> +			" zspages:%lukB"
>  			" present:%lukB"
>  			" managed:%lukB"
>  			" mlocked:%lukB"
> @@ -332,6 +333,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
>  			K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
>  			K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
> +			K(zone_page_state(zone, NR_ZSPAGES)),
>  			K(zone->present_pages),
>  			K(zone_managed_pages(zone)),
>  			K(zone_page_state(zone, NR_MLOCK)),



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

* Re: [PATCH] mm: show_mem: show number of zspages in show_free_areas
  2025-09-01 18:37 [PATCH] mm: show_mem: show number of zspages in show_free_areas Thadeu Lima de Souza Cascardo
  2025-09-01 18:54 ` Vlastimil Babka
@ 2025-09-02  1:49 ` SeongJae Park
  2025-09-02  3:13   ` SeongJae Park
  2025-09-02  4:56 ` Lorenzo Stoakes
  2 siblings, 1 reply; 6+ messages in thread
From: SeongJae Park @ 2025-09-02  1:49 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: SeongJae Park, linux-kernel, linux-mm, Andrew Morton,
	Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan, kernel-dev

Hello,

On Mon,  1 Sep 2025 15:37:28 -0300 Thadeu Lima de Souza Cascardo <cascardo@igalia.com> wrote:

> When OOM is triggered, it will show where the pages might be for each zone.
> When using zram, it might look like lots of pages are missing. After this
> patch, zspages are shown as below.
[...]
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> ---
>  mm/show_mem.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/show_mem.c b/mm/show_mem.c
> index 41999e94a56d..ecf20a93ea54 100644
> --- a/mm/show_mem.c
> +++ b/mm/show_mem.c
> @@ -310,6 +310,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			" inactive_file:%lukB"
>  			" unevictable:%lukB"
>  			" writepending:%lukB"
> +			" zspages:%lukB"
>  			" present:%lukB"
>  			" managed:%lukB"
>  			" mlocked:%lukB"
> @@ -332,6 +333,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
>  			K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
>  			K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
> +			K(zone_page_state(zone, NR_ZSPAGES)),

I found latest mm-new fails kunit's um build as below, and 'git bisect' points
this patch.

    $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=40
    ERROR:root:In file included from ../mm/show_mem.c:18:
    ../mm/show_mem.c: In function ‘show_free_areas’:
    ../mm/show_mem.c:336:49: error: ‘NR_ZSPAGES’ undeclared (first use in this function); did you mean ‘NR_STATS’?
      336 |                         K(zone_page_state(zone, NR_ZSPAGES)),
          |                                                 ^~~~~~~~~~
    [...]

Maybe some CONFIG_ZSMALLOC undeclard case handling, like below, is needed?

    --- a/mm/show_mem.c
    +++ b/mm/show_mem.c
    @@ -333,7 +333,9 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
                            K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
                            K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
                            K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
    +#if IS_ENABLED(CONFIG_ZSMALLOC)
                            K(zone_page_state(zone, NR_ZSPAGES)),
    +#endif
                            K(zone->present_pages),
                            K(zone_managed_pages(zone)),
                            K(zone_page_state(zone, NR_MLOCK)),


Thanks,
SJ

[...]


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

* Re: [PATCH] mm: show_mem: show number of zspages in show_free_areas
  2025-09-01 18:54 ` Vlastimil Babka
@ 2025-09-02  2:10   ` Sergey Senozhatsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sergey Senozhatsky @ 2025-09-02  2:10 UTC (permalink / raw)
  To: Vlastimil Babka, Thadeu Lima de Souza Cascardo
  Cc: linux-kernel, linux-mm, Andrew Morton, Suren Baghdasaryan,
	Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan,
	kernel-dev, Minchan Kim, Sergey Senozhatsky, Yosry Ahmed,
	Nhat Pham, Chengming Zhou

On (25/09/01 20:54), Vlastimil Babka wrote:
> On 9/1/25 20:37, Thadeu Lima de Souza Cascardo wrote:
> > When OOM is triggered, it will show where the pages might be for each zone.
> > When using zram, it might look like lots of pages are missing. After this
> > patch, zspages are shown as below.
> 
> AFAIK zswap can also use zsmalloc so this would be reported for zswap with
> the same effect too, right?

Correct.

> > [   48.792859] Node 0 DMA free:2812kB boost:0kB min:60kB low:72kB high:84kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB zspages:11160kB present:15992kB managed:15360kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
> > [   48.792962] lowmem_reserve[]: 0 956 956 956 956
> > [   48.792988] Node 0 DMA32 free:3512kB boost:0kB min:3912kB low:4888kB high:5864kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:28kB active_file:8kB inactive_file:16kB unevictable:0kB writepending:0kB zspages:916780kB present:1032064kB managed:978944kB mlocked:0kB bounce:0kB free_pcp:500kB local_pcp:248kB free_cma:0kB
> > [   48.793118] lowmem_reserve[]: 0 0 0 0 0
> > 
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> 
> Acked-by: Vlastimil Babka <vbabka@suse.cz>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>


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

* Re: [PATCH] mm: show_mem: show number of zspages in show_free_areas
  2025-09-02  1:49 ` SeongJae Park
@ 2025-09-02  3:13   ` SeongJae Park
  0 siblings, 0 replies; 6+ messages in thread
From: SeongJae Park @ 2025-09-02  3:13 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Thadeu Lima de Souza Cascardo, linux-kernel, linux-mm,
	Andrew Morton, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko,
	Brendan Jackman, Johannes Weiner, Zi Yan, kernel-dev

On Mon,  1 Sep 2025 18:49:33 -0700 SeongJae Park <sj@kernel.org> wrote:

> Hello,
> 
> On Mon,  1 Sep 2025 15:37:28 -0300 Thadeu Lima de Souza Cascardo <cascardo@igalia.com> wrote:
> 
> > When OOM is triggered, it will show where the pages might be for each zone.
> > When using zram, it might look like lots of pages are missing. After this
> > patch, zspages are shown as below.
> [...]
> > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> > ---
> >  mm/show_mem.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/mm/show_mem.c b/mm/show_mem.c
> > index 41999e94a56d..ecf20a93ea54 100644
> > --- a/mm/show_mem.c
> > +++ b/mm/show_mem.c
> > @@ -310,6 +310,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
> >  			" inactive_file:%lukB"
> >  			" unevictable:%lukB"
> >  			" writepending:%lukB"
> > +			" zspages:%lukB"
> >  			" present:%lukB"
> >  			" managed:%lukB"
> >  			" mlocked:%lukB"
> > @@ -332,6 +333,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
> >  			K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
> >  			K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
> >  			K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
> > +			K(zone_page_state(zone, NR_ZSPAGES)),
> 
> I found latest mm-new fails kunit's um build as below, and 'git bisect' points
> this patch.
> 
>     $ make all compile_commands.json scripts_gdb ARCH=um O=.kunit --jobs=40
>     ERROR:root:In file included from ../mm/show_mem.c:18:
>     ../mm/show_mem.c: In function ‘show_free_areas’:
>     ../mm/show_mem.c:336:49: error: ‘NR_ZSPAGES’ undeclared (first use in this function); did you mean ‘NR_STATS’?
>       336 |                         K(zone_page_state(zone, NR_ZSPAGES)),
>           |                                                 ^~~~~~~~~~
>     [...]
> 
> Maybe some CONFIG_ZSMALLOC undeclard case handling, like below, is needed?
> 
>     --- a/mm/show_mem.c
>     +++ b/mm/show_mem.c
>     @@ -333,7 +333,9 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>                             K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
>                             K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
>                             K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
>     +#if IS_ENABLED(CONFIG_ZSMALLOC)
>                             K(zone_page_state(zone, NR_ZSPAGES)),
>     +#endif

Of course, the above example will make the output shows wrong values on
'zspages:' and later fields when ZSMALLOC is unset.  Maybe below change on top
of the above diff makes sense?

    --- a/mm/show_mem.c
    +++ b/mm/show_mem.c
    @@ -335,6 +335,8 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
                            K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),
     #if IS_ENABLED(CONFIG_ZSMALLOC)
                            K(zone_page_state(zone, NR_ZSPAGES)),
    +#else
    +                       0,
     #endif
                            K(zone->present_pages),
                            K(zone_managed_pages(zone)),


Thanks,
SJ

[...]


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

* Re: [PATCH] mm: show_mem: show number of zspages in show_free_areas
  2025-09-01 18:37 [PATCH] mm: show_mem: show number of zspages in show_free_areas Thadeu Lima de Souza Cascardo
  2025-09-01 18:54 ` Vlastimil Babka
  2025-09-02  1:49 ` SeongJae Park
@ 2025-09-02  4:56 ` Lorenzo Stoakes
  2 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Stoakes @ 2025-09-02  4:56 UTC (permalink / raw)
  To: Thadeu Lima de Souza Cascardo
  Cc: linux-kernel, linux-mm, Andrew Morton, Vlastimil Babka,
	Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
	Johannes Weiner, Zi Yan, kernel-dev

Andrew - could we drop this, it's breaking mm-new.


On Mon, Sep 01, 2025 at 03:37:28PM -0300, Thadeu Lima de Souza Cascardo wrote:
> When OOM is triggered, it will show where the pages might be for each zone.
> When using zram, it might look like lots of pages are missing. After this
> patch, zspages are shown as below.
>
> [   48.792859] Node 0 DMA free:2812kB boost:0kB min:60kB low:72kB high:84kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB zspages:11160kB present:15992kB managed:15360kB mlocked:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
> [   48.792962] lowmem_reserve[]: 0 956 956 956 956
> [   48.792988] Node 0 DMA32 free:3512kB boost:0kB min:3912kB low:4888kB high:5864kB reserved_highatomic:0KB free_highatomic:0KB active_anon:0kB inactive_anon:28kB active_file:8kB inactive_file:16kB unevictable:0kB writepending:0kB zspages:916780kB present:1032064kB managed:978944kB mlocked:0kB bounce:0kB free_pcp:500kB local_pcp:248kB free_cma:0kB
> [   48.793118] lowmem_reserve[]: 0 0 0 0 0
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
> ---
>  mm/show_mem.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/mm/show_mem.c b/mm/show_mem.c
> index 41999e94a56d..ecf20a93ea54 100644
> --- a/mm/show_mem.c
> +++ b/mm/show_mem.c
> @@ -310,6 +310,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			" inactive_file:%lukB"
>  			" unevictable:%lukB"
>  			" writepending:%lukB"
> +			" zspages:%lukB"
>  			" present:%lukB"
>  			" managed:%lukB"
>  			" mlocked:%lukB"
> @@ -332,6 +333,7 @@ static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_z
>  			K(zone_page_state(zone, NR_ZONE_INACTIVE_FILE)),
>  			K(zone_page_state(zone, NR_ZONE_UNEVICTABLE)),
>  			K(zone_page_state(zone, NR_ZONE_WRITE_PENDING)),

#ifdef CONFIG_ZSMALLOC

> +			K(zone_page_state(zone, NR_ZSPAGES)),

#endif

:)

This is breaking the build, please fix cheers!

>  			K(zone->present_pages),
>  			K(zone_managed_pages(zone)),
>  			K(zone_page_state(zone, NR_MLOCK)),
> --
> 2.47.2
>
>


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

end of thread, other threads:[~2025-09-02  4:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 18:37 [PATCH] mm: show_mem: show number of zspages in show_free_areas Thadeu Lima de Souza Cascardo
2025-09-01 18:54 ` Vlastimil Babka
2025-09-02  2:10   ` Sergey Senozhatsky
2025-09-02  1:49 ` SeongJae Park
2025-09-02  3:13   ` SeongJae Park
2025-09-02  4:56 ` Lorenzo Stoakes

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).