linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Feng Tang <feng.tang@intel.com>
Cc: Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@kernel.org>,
	Dave Hansen <dave.hansen@intel.com>,
	ying.huang@intel.com, stable@vger.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: Remove redundant cpu/node masks setup in cpuset_init_smp()
Date: Mon, 25 Apr 2022 10:43:16 -0400	[thread overview]
Message-ID: <690fb0ac-6f8c-7e52-2485-4acc030bbc07@redhat.com> (raw)
In-Reply-To: <20220425073011.GJ46405@shbuild999.sh.intel.com>

On 4/25/22 03:30, Feng Tang wrote:
> Hi Waiman,
>
> Thanks for the patch!
>
> On Sun, Apr 24, 2022 at 10:09:26PM -0400, Waiman Long wrote:
>> There are 3 places where the cpu and node masks of the top cpuset can
>> be initialized in the order they are executed:
>>   1) start_kernel -> cpuset_init()
>>   2) start_kernel -> cgroup_init() -> cpuset_bind()
>>   3) kernel_init_freeable() -> do_basic_setup() -> cpuset_init_smp()
>>
>> The first cpuset_init() function just sets all the bits in the masks.
>> The last one executed is cpuset_init_smp() which sets up cpu and node
>> masks suitable for v1, but not v2.  cpuset_bind() does the right setup
>> for both v1 and v2 assuming that effective_mems and effective_cpus have
>> been set up properly which is not strictly the case here. As a result,
>> cpu and memory node hot add may fail to update the cpu and node masks
>> of the top cpuset to include the newly added cpu or node in a cgroup
>> v2 environment.
>>
>> To fix this problem, the redundant cpus_allowed and mems_allowed
>> mask setup in cpuset_init_smp() are removed. The effective_cpus and
>> effective_mems setup there are moved to cpuset_bind().
>>
>> cc: stable@vger.kernel.org
>> Signed-off-by: Waiman Long <longman@redhat.com>
>> ---
>>   kernel/cgroup/cpuset.c | 10 +++-------
>>   1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 9390bfd9f1cd..a2e15a43397e 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -2961,6 +2961,9 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
>>   	percpu_down_write(&cpuset_rwsem);
>>   	spin_lock_irq(&callback_lock);
>>   
>> +	cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
>> +	top_cpuset.effective_mems = node_states[N_MEMORY];
>> +
>>   	if (is_in_v2_mode()) {
>>   		cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask);
>>   		top_cpuset.mems_allowed = node_possible_map;
>> @@ -3390,13 +3393,6 @@ static struct notifier_block cpuset_track_online_nodes_nb = {
>>    */
>>   void __init cpuset_init_smp(void)
>>   {
>> -	cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask);
>> -	top_cpuset.mems_allowed = node_states[N_MEMORY];
>> -	top_cpuset.old_mems_allowed = top_cpuset.mems_allowed;
>> -
>> -	cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);
>> -	top_cpuset.effective_mems = node_states[N_MEMORY];
> IIUC, the init order is:
> 	cpuset_bind()
> 	smp_init()
> 	cpuset_init_smp()
>
> while all cpus except boot cpu is brought up in smp_init(), so I'm
> thinking moving the cpus_allowed init from cpuset_init_smp() to
> cpuset_bind() may cause some problem.

Good point. So cpuset_init_smp() is still useful for setting the right 
effective_cpus and probably effective_mems. I will update the patch 
accordingly.

Thanks,
Longman

>
> Thanks,
> Feng
>



  reply	other threads:[~2022-04-25 14:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25  2:09 [PATCH] cgroup/cpuset: Remove redundant cpu/node masks setup in cpuset_init_smp() Waiman Long
2022-04-25  7:30 ` Feng Tang
2022-04-25 14:43   ` Waiman Long [this message]
2022-05-13  6:33 ` [cgroup/cpuset] 7aaa45f837: kbuild.buildtime_per_iteration 2583.0% regression kernel test robot
2022-05-16  3:02   ` Waiman Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=690fb0ac-6f8c-7e52-2485-4acc030bbc07@redhat.com \
    --to=longman@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=dave.hansen@intel.com \
    --cc=feng.tang@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizefan.x@bytedance.com \
    --cc=mhocko@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).