Re: [PATCH -next v2] mm, proc: collect percpu free pages into the free pages

From: Liu Shixin
Date: Tue Aug 23 2022 - 12:44:06 EST


On 2022/8/23 5:13, Andrew Morton wrote:
> On Mon, 22 Aug 2022 14:12:07 -0700 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
>> Prevention of races against zone/node hotplug?
> I meant "cpu/node", of course.
> .
Thanks for your advice, but I didn't quite understand what you meant.
Do you mean that I should use cpus_read_lock() to protect cpu hotplug just like this?
+ cpus_read_lock();
for_each_online_cpu(cpu)
sum += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count;
+ cpus_read_unlock();

I see there is some areas were not protected by the cpus_{read/write}_lock, so I was confused
as to whether I should add it.

I want to replace for_each_zone with for_each_populated_zone, what else should I do to protect
node hotplug.

Thanks.