* [PATCH] memblock: use the helper macro for_each_zone
@ 2023-06-12 12:51 Peng Zhang
2023-06-14 11:46 ` Mike Rapoport
0 siblings, 1 reply; 3+ messages in thread
From: Peng Zhang @ 2023-06-12 12:51 UTC (permalink / raw)
To: linux-mm, linux-kernel, rppt, akpm; +Cc: wangkefeng.wang, sunnanyong, ZhangPeng
From: ZhangPeng <zhangpeng362@huawei.com>
Let's use the helper macro for_each_zone to iterate over all memory
zones and reset the node managed pages. After that, we can remove the
unused function reset_node_managed_pages.
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
---
mm/memblock.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index da4264528e1e..af552604c3fb 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2122,23 +2122,15 @@ static unsigned long __init free_low_memory_core_early(void)
static int reset_managed_pages_done __initdata;
-static void __init reset_node_managed_pages(pg_data_t *pgdat)
-{
- struct zone *z;
-
- for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
- atomic_long_set(&z->managed_pages, 0);
-}
-
void __init reset_all_zones_managed_pages(void)
{
- struct pglist_data *pgdat;
+ struct zone *z;
if (reset_managed_pages_done)
return;
- for_each_online_pgdat(pgdat)
- reset_node_managed_pages(pgdat);
+ for_each_zone(z)
+ atomic_long_set(&z->managed_pages, 0);
reset_managed_pages_done = 1;
}
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memblock: use the helper macro for_each_zone
2023-06-12 12:51 [PATCH] memblock: use the helper macro for_each_zone Peng Zhang
@ 2023-06-14 11:46 ` Mike Rapoport
2023-06-15 9:22 ` zhangpeng (AS)
0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2023-06-14 11:46 UTC (permalink / raw)
To: Peng Zhang; +Cc: linux-mm, linux-kernel, akpm, wangkefeng.wang, sunnanyong
On Mon, Jun 12, 2023 at 08:51:02PM +0800, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Let's use the helper macro for_each_zone to iterate over all memory
> zones and reset the node managed pages. After that, we can remove the
> unused function reset_node_managed_pages.
Are you sure it's safe to use for_each_zone() in all users of
reset_all_zones_managed_pages()?
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
> mm/memblock.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index da4264528e1e..af552604c3fb 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -2122,23 +2122,15 @@ static unsigned long __init free_low_memory_core_early(void)
>
> static int reset_managed_pages_done __initdata;
>
> -static void __init reset_node_managed_pages(pg_data_t *pgdat)
> -{
> - struct zone *z;
> -
> - for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
> - atomic_long_set(&z->managed_pages, 0);
> -}
> -
> void __init reset_all_zones_managed_pages(void)
> {
> - struct pglist_data *pgdat;
> + struct zone *z;
>
> if (reset_managed_pages_done)
> return;
>
> - for_each_online_pgdat(pgdat)
> - reset_node_managed_pages(pgdat);
> + for_each_zone(z)
> + atomic_long_set(&z->managed_pages, 0);
>
> reset_managed_pages_done = 1;
> }
> --
> 2.25.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] memblock: use the helper macro for_each_zone
2023-06-14 11:46 ` Mike Rapoport
@ 2023-06-15 9:22 ` zhangpeng (AS)
0 siblings, 0 replies; 3+ messages in thread
From: zhangpeng (AS) @ 2023-06-15 9:22 UTC (permalink / raw)
To: Mike Rapoport; +Cc: linux-mm, linux-kernel, akpm, wangkefeng.wang, sunnanyong
On 2023/6/14 19:46, Mike Rapoport wrote:
> On Mon, Jun 12, 2023 at 08:51:02PM +0800, Peng Zhang wrote:
>> From: ZhangPeng <zhangpeng362@huawei.com>
>>
>> Let's use the helper macro for_each_zone to iterate over all memory
>> zones and reset the node managed pages. After that, we can remove the
>> unused function reset_node_managed_pages.
> Are you sure it's safe to use for_each_zone() in all users of
> reset_all_zones_managed_pages()?
>
Thanks for your review.
Using for_each_zone() is indeed unsafe in some users of
reset_all_zones_managed_pages(). Please ignore.
Thanks,
Peng
>> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
>> ---
>> mm/memblock.c | 14 +++-----------
>> 1 file changed, 3 insertions(+), 11 deletions(-)
>>
>> diff --git a/mm/memblock.c b/mm/memblock.c
>> index da4264528e1e..af552604c3fb 100644
>> --- a/mm/memblock.c
>> +++ b/mm/memblock.c
>> @@ -2122,23 +2122,15 @@ static unsigned long __init free_low_memory_core_early(void)
>>
>> static int reset_managed_pages_done __initdata;
>>
>> -static void __init reset_node_managed_pages(pg_data_t *pgdat)
>> -{
>> - struct zone *z;
>> -
>> - for (z = pgdat->node_zones; z < pgdat->node_zones + MAX_NR_ZONES; z++)
>> - atomic_long_set(&z->managed_pages, 0);
>> -}
>> -
>> void __init reset_all_zones_managed_pages(void)
>> {
>> - struct pglist_data *pgdat;
>> + struct zone *z;
>>
>> if (reset_managed_pages_done)
>> return;
>>
>> - for_each_online_pgdat(pgdat)
>> - reset_node_managed_pages(pgdat);
>> + for_each_zone(z)
>> + atomic_long_set(&z->managed_pages, 0);
>>
>> reset_managed_pages_done = 1;
>> }
>> --
>> 2.25.1
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-15 9:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 12:51 [PATCH] memblock: use the helper macro for_each_zone Peng Zhang
2023-06-14 11:46 ` Mike Rapoport
2023-06-15 9:22 ` zhangpeng (AS)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox