Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2831726pxb; Mon, 25 Apr 2022 03:36:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyg//vqBMw9VFr82IMZJGTPqzzU69zxHKzH4XNkArEgM4JqkG2wEVU2JnplX2KHMTyqb5C X-Received: by 2002:a05:6a00:181c:b0:50a:b9bb:dc6e with SMTP id y28-20020a056a00181c00b0050ab9bbdc6emr18144372pfa.81.1650882996054; Mon, 25 Apr 2022 03:36:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650882996; cv=none; d=google.com; s=arc-20160816; b=X8zwp5J6/OpAzQRtkQfnI10aeaG5KoujrSwReSJGsWV9KHB8THnASp5ZPrZcGWdMYQ VnBLvA1l1PEFBx6WrI/Gt2InEuvqhnzMcCe1HgTShJVfbdjOo1ytTY4V4hF1V2tZnHJE haMKSA4vzLp2dlL7eYbU70Jg6SrLHKpA0tCVvnSpOPbFeIKi5/CN0vPkUGR9u2SoshKr MSID4u05fL14z9T1XsRmx40fVE1IrZqnwWc9YqDMn9QVo4tfZfdbFsW3w+XLfnFbRDLV YEkhZ42mu5+2NZXZizpRdCnJUR+KZnVSy2E+61TO5LL3ooE8+wsIVGvLiGz9A8qmn3GY dPNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OBRVLrbQJekWU4JAMVstu3RAO+DZC2gFqR0HPdeaKx4=; b=DaFZSTF8Gjf0e59rG1DXdK7aoDz7etPLTGb3HWjr79vx/aySSStBgAm+ompMhBHEoT uB069CkmlG9bfuAM9eGB6flcXv83VUJPFUT5nL+0pOBlO2lTaxR5MzSzffSTjoFTOpbS dSgpPeXHG8lDloC4EHxWFLkqTtVefEA6DMm7HgQTsEbIxyoQfzJnD8CdvTlnbYXs5oDD SY5ePPCuQJ7KHki5ZT6Rpo+X7PhA3rLub6QlxuHbqH5ObYOmv9LtIDl9id1Xf2NXiCnW FVGlE31TeY5V2DxClXAqdMaiD6y80UhWfDROzjLWH3Pb7yV2MGe2KdpvMaCEwNIOi0gy nYbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GcLe6cA8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u38-20020a634566000000b003a9eb7ecffcsi15708915pgk.181.2022.04.25.03.36.19; Mon, 25 Apr 2022 03:36:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GcLe6cA8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233759AbiDYHdV (ORCPT + 99 others); Mon, 25 Apr 2022 03:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiDYHdT (ORCPT ); Mon, 25 Apr 2022 03:33:19 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF059BF47; Mon, 25 Apr 2022 00:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650871816; x=1682407816; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=v33AZ1EXAwq6WXUADhV0AAEUbQzxeq80/j/EQgk+qSk=; b=GcLe6cA8Oz831plPs1tKGai0rsyJvaxL+HIzHF4pm9QbxwB0/5Ph1bfZ hONxxu9hwQKzBUnT0nttmD5ToYxpvD4A4w8N0vsSnElYu4g2MFyl8HQuz 0F9zT6WCWGaLe3EeMDOrFtcuVBYOpMBbH4tUwe35qevbZT7diowiwsTC9 fqKuo0fln+m81N/eXOis7juto9TUTpZRcsngXAroNhAk1c94oJXuMipsG KKoTYi5VfKlCusJwPWU9qOGBFVujF+M31WHTvT/y1oGstXFxy1Cmu9r/l a/xq14s6yZjdCw+ir0Ol7J1G8ZBwoXwqMA0FutDH/hMh4+LFAr14bg729 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10327"; a="325656067" X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="325656067" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Apr 2022 00:30:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,287,1643702400"; d="scan'208";a="531983853" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.138]) by orsmga006.jf.intel.com with ESMTP; 25 Apr 2022 00:30:12 -0700 Date: Mon, 25 Apr 2022 15:30:11 +0800 From: Feng Tang To: Waiman Long Cc: Tejun Heo , Zefan Li , Johannes Weiner , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Michal Hocko , Dave Hansen , ying.huang@intel.com, stable@vger.kernel.org Subject: Re: [PATCH] cgroup/cpuset: Remove redundant cpu/node masks setup in cpuset_init_smp() Message-ID: <20220425073011.GJ46405@shbuild999.sh.intel.com> References: <20220425020926.1264611-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220425020926.1264611-1-longman@redhat.com> X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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. Thanks, Feng