Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages()
@ 2026-09-08 16:57 Sang-Heon Jeon
  2026-09-10  9:58 ` Mike Rapoport
  0 siblings, 1 reply; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-08 16:57 UTC (permalink / raw)
  To: Andrew Morton, Mike Rapoport; +Cc: linux-mm

reset_all_zones_managed_pages() iterates over the zones of every
online node with a nested loop. for_each_zone() iterates over the same
zones in the same order.

So use for_each_zone() instead and remove reset_node_managed_pages().

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
 mm/memblock.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 4302fb4ab85c..ed6937be8d9f 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2465,22 +2465,14 @@ static unsigned long __init free_low_memory_core_early(void)
 	return count;
 }
 
-static void __init reset_node_managed_pages(pg_data_t *pgdat)
+static void __init reset_all_zones_managed_pages(void)
 {
 	struct zone *z;
 
-	for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
+	for_each_zone(z)
 		atomic_long_set(&z->managed_pages, 0);
 }
 
-static void __init reset_all_zones_managed_pages(void)
-{
-	struct pglist_data *pgdat;
-
-	for_each_online_pgdat(pgdat)
-		reset_node_managed_pages(pgdat);
-}
-
 /**
  * memblock_free_all - release free pages to the buddy allocator
  */

base-commit: dbffc67777cd752ef3f77818109e1d2ef13e2949
-- 
2.43.0



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

* Re: [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages()
  2026-09-08 16:57 [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages() Sang-Heon Jeon
@ 2026-09-10  9:58 ` Mike Rapoport
  2026-09-10 10:13   ` Mike Rapoport
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2026-09-10  9:58 UTC (permalink / raw)
  To: Andrew Morton, Sang-Heon Jeon; +Cc: linux-mm

On Wed, 09 Sep 2026 01:57:32 +0900, Sang-Heon Jeon wrote:
> memblock: use for_each_zone() in reset_all_zones_managed_pages()

Applied to for-next branch of memblock.git tree, thanks!

[1/1] memblock: use for_each_zone() in reset_all_zones_managed_pages()
      commit: 0876b2d8794913c867a1bb0dc3fd22ea1c5f0a95

tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
branch: for-next

--
Sincerely yours,
Mike.




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

* Re: [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages()
  2026-09-10  9:58 ` Mike Rapoport
@ 2026-09-10 10:13   ` Mike Rapoport
  2026-09-10 12:19     ` Sang-Heon Jeon
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2026-09-10 10:13 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, Sang-Heon Jeon, linux-mm

On 2026-09-10 12:58 +0300, Mike Rapoport wrote:
> On Wed, 09 Sep 2026 01:57:32 +0900, Sang-Heon Jeon wrote:
> > memblock: use for_each_zone() in reset_all_zones_managed_pages()
> 
> Applied to for-next branch of memblock.git tree, thanks!
> 
> [1/1] memblock: use for_each_zone() in reset_all_zones_managed_pages()
>       commit: 0876b2d8794913c867a1bb0dc3fd22ea1c5f0a95
> 
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
> branch: for-next

Hmm, I was too hasty.
This breaks mmemblock tests, so I dropped it for now.

> --
> Sincerely yours,
> Mike.
> 
> 
> 
> 
> 




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

* Re: [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages()
  2026-09-10 10:13   ` Mike Rapoport
@ 2026-09-10 12:19     ` Sang-Heon Jeon
  2026-09-10 14:35       ` Sang-Heon Jeon
  0 siblings, 1 reply; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-10 12:19 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-mm

On Thu, Sep 10, 2026 at 7:13 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> On 2026-09-10 12:58 +0300, Mike Rapoport wrote:
> > On Wed, 09 Sep 2026 01:57:32 +0900, Sang-Heon Jeon wrote:
> > > memblock: use for_each_zone() in reset_all_zones_managed_pages()
> >
> > Applied to for-next branch of memblock.git tree, thanks!
> >
> > [1/1] memblock: use for_each_zone() in reset_all_zones_managed_pages()
> >       commit: 0876b2d8794913c867a1bb0dc3fd22ea1c5f0a95
> >
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
> > branch: for-next
>
> Hmm, I was too hasty.
> This breaks mmemblock tests, so I dropped it for now.

Sorry for the noise. I missed it. I will keep it in mind next time.
Just give me a second to check.

> > --
> > Sincerely yours,
> > Mike.
> >
> >
> >
> >
> >
>
>

Best regards
Sang-Heon Jeon


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

* Re: [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages()
  2026-09-10 12:19     ` Sang-Heon Jeon
@ 2026-09-10 14:35       ` Sang-Heon Jeon
  0 siblings, 0 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-09-10 14:35 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-mm

On Thu, Sep 10, 2026 at 9:19 PM Sang-Heon Jeon <ekffu200098@gmail.com> wrote:
>
> On Thu, Sep 10, 2026 at 7:13 PM Mike Rapoport <rppt@kernel.org> wrote:
> >
> > On 2026-09-10 12:58 +0300, Mike Rapoport wrote:
> > > On Wed, 09 Sep 2026 01:57:32 +0900, Sang-Heon Jeon wrote:
> > > > memblock: use for_each_zone() in reset_all_zones_managed_pages()
> > >
> > > Applied to for-next branch of memblock.git tree, thanks!
> > >
> > > [1/1] memblock: use for_each_zone() in reset_all_zones_managed_pages()
> > >       commit: 0876b2d8794913c867a1bb0dc3fd22ea1c5f0a95
> > >
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
> > > branch: for-next
> >
> > Hmm, I was too hasty.
> > This breaks mmemblock tests, so I dropped it for now.
>
> Sorry for the noise. I missed it. I will keep it in mind next time.
> Just give me a second to check.

With the below fixes, tests will be fine again. Is it okay to send the
v2 patchset with below fixes?

diff --git a/tools/testing/memblock/linux/mmzone.h
b/tools/testing/memblock/linux/mmzone.h
index 8d934ff5b080..631fe07923e7 100644
--- a/tools/testing/memblock/linux/mmzone.h
+++ b/tools/testing/memblock/linux/mmzone.h
@@ -7,13 +7,20 @@

 struct pglist_data *first_online_pgdat(void);
 struct pglist_data *next_online_pgdat(struct pglist_data *pgdat);
+struct zone *next_zone(struct zone *zone);

 #define for_each_online_pgdat(pgdat)                   \
        for (pgdat = first_online_pgdat();              \
             pgdat;                                     \
             pgdat = next_online_pgdat(pgdat))

+#define for_each_zone(zone)                            \
+       for (zone = (first_online_pgdat())->node_zones; \
+            zone;                                      \
+            zone = next_zone(zone))
+
 enum zone_type {
+       ZONE_NORMAL,
        __MAX_NR_ZONES
 };

@@ -27,6 +34,7 @@ enum zone_type {
 #define pageblock_start_pfn(pfn)       ALIGN_DOWN((pfn), pageblock_nr_pages)

 struct zone {
+       struct pglist_data      *zone_pgdat;
        atomic_long_t           managed_pages;
 };

diff --git a/tools/testing/memblock/mmzone.c b/tools/testing/memblock/mmzone.c
index e719450f81cb..e73848bdc8d6 100644
--- a/tools/testing/memblock/mmzone.c
+++ b/tools/testing/memblock/mmzone.c
@@ -1,9 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 #include <linux/mmzone.h>

+static pg_data_t dummy_pgdat = {
+       .node_zones = {
+               [0 ... MAX_NR_ZONES - 1] = { .zone_pgdat = &dummy_pgdat },
+       },
+};
+
 struct pglist_data *first_online_pgdat(void)
 {
-       return NULL;
+       return &dummy_pgdat;
 }

 struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
@@ -11,6 +17,22 @@ struct pglist_data *next_online_pgdat(struct
pglist_data *pgdat)
        return NULL;
 }

+struct zone *next_zone(struct zone *zone)
+{
+       pg_data_t *pgdat = zone->zone_pgdat;
+
+       if (zone < pgdat->node_zones + MAX_NR_ZONES - 1)
+               zone++;
+       else {
+               pgdat = next_online_pgdat(pgdat);
+               if (pgdat)
+                       zone = pgdat->node_zones;
+               else
+                       zone = NULL;
+       }
+       return zone;
+}
+
 void atomic_long_set(atomic_long_t *v, long i)
 {
 }

> > > --
> > > Sincerely yours,
> > > Mike.
> > >
> > >
> > >
> > >
> > >
> >
> >
>
> Best regards
> Sang-Heon Jeon

Best regards,
Sang-Heon Jeon


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

end of thread, other threads:[~2026-09-10 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 16:57 [PATCH] memblock: use for_each_zone() in reset_all_zones_managed_pages() Sang-Heon Jeon
2026-09-10  9:58 ` Mike Rapoport
2026-09-10 10:13   ` Mike Rapoport
2026-09-10 12:19     ` Sang-Heon Jeon
2026-09-10 14:35       ` Sang-Heon Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox