Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3512752iob; Tue, 17 May 2022 01:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAAV9/keL1nf2MQnhmi923WIDjsOZBxF7swAa/tbgJHknmijjQa0uTI61EVyOyo49QQscI X-Received: by 2002:a17:907:169f:b0:6f4:2a57:e1c4 with SMTP id hc31-20020a170907169f00b006f42a57e1c4mr19459165ejc.490.1652776034641; Tue, 17 May 2022 01:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652776034; cv=none; d=google.com; s=arc-20160816; b=hp3CujXXT0LSwp2WAhVi5UawPSf77jmmsqzZnrc6KFWk8H++TB+0rAKhmXWr1FMYAA Apvh7e7ngL4M8SydWL0ryPMz9Y+6uCPSzAnD/PExN/7PBajISjkE/VHTYlAdEmOJ14yP 3EVf4BcCGZecO9M541nKf9remffpfsvvn2vFiK8q6L9l3fRBktRin/0qwfBnLS5d4Ask geXciZZ2dTERYoVksF+CD2tkzekaT6Qh0TCiKKZ30t1v0w3IsgXl998OiwyDkQRFA1zJ lyKnsfQc9YvpislM6RA4XV+wiIirClAyRn+kZLT388o0DwVFEdm8/KXdNETEVO7kkSdE nQBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PE8T2Mfaz0/61zkYv07A8vX0esQcZ9qCvAsFI38bToo=; b=u2rYF9yvAdEcD0Edlvcx8juL8Vcq+aBFxsG6zqLiXljFZqbNKfRadkA4ekEAtwTYPG K+T8GsuNtTBYko8RGbS4jWO8mnIpGICkYDkcw6CtzNvqq7FEkCT0CTAfK3/FYeQmqxpx g0BO0yGaHlt+z9e17GXhO/zoDVfR/JntgPEWRLS+11tmh8MAgVdnB5eYhSbVk65s06Px MeVW1BWxSJF7ueZg01Ki/VrI/IwRkT4km+0Pj0FdNS6xN1hHMIWSOHZjquGvUZv3FlVs oaG34dvbhvmJJL59XoFJEcjgvTD9q7eDItGA1oh3bD06jh45jgETErf9YreLR0NTRBYY bBDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DI8kQbxT; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dv8-20020a170906b80800b006f3a2a53c3asi2015094ejb.172.2022.05.17.01.26.46; Tue, 17 May 2022 01:27:14 -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=@linuxfoundation.org header.s=korg header.b=DI8kQbxT; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347925AbiEPTwc (ORCPT + 99 others); Mon, 16 May 2022 15:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346425AbiEPTqO (ORCPT ); Mon, 16 May 2022 15:46:14 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2DB441330; Mon, 16 May 2022 12:43:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 360A7CE1795; Mon, 16 May 2022 19:43:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FBC9C34115; Mon, 16 May 2022 19:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730215; bh=eNeYEQzZlS21APqbNXgI7gda0OfLzSZQEYKhOTtXuio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DI8kQbxT5bPtYaHNkbe79DkAdMDVgrkP2gZwZ6NIA7mrHbowXXsiEnz/TTWO5f5Pi 0tx0QOMHbHp4sVyDmoPkkyL6So3BlO7l2bTBmpU0inOcsNCq4rSe7q5sI1nrX3TMdj 12GHFT6nh/L8Huau5g4XnK4CEV/lE900lKWl1Osg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Feng Tang , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Tejun Heo Subject: [PATCH 5.4 37/43] cgroup/cpuset: Remove cpus_allowed/mems_allowed setup in cpuset_init_smp() Date: Mon, 16 May 2022 21:36:48 +0200 Message-Id: <20220516193615.814914177@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193614.714657361@linuxfoundation.org> References: <20220516193614.714657361@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,TVD_SUBJ_WIPE_DEBT,T_SCC_BODY_TEXT_LINE 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 From: Waiman Long commit 2685027fca387b602ae565bff17895188b803988 upstream. 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() call just sets all the bits in the masks. The second cpuset_bind() call sets cpus_allowed and mems_allowed to the default v2 values. The third cpuset_init_smp() call sets them back to v1 values. For systems with cgroup v2 setup, cpuset_bind() is called once. 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. For systems with cgroup v1 setup, cpuset_bind() is called again by rebind_subsystem() when the v1 cpuset filesystem is mounted as shown in the dmesg log below with an instrumented kernel. [ 2.609781] cpuset_bind() called - v2 = 1 [ 3.079473] cpuset_init_smp() called [ 7.103710] cpuset_bind() called - v2 = 0 smp_init() is called after the first two init functions. So we don't have a complete list of active cpus and memory nodes until later in cpuset_init_smp() which is the right time to set up effective_cpus and effective_mems. To fix this cgroup v2 mask setup problem, the potentially incorrect cpus_allowed & mems_allowed setting in cpuset_init_smp() are removed. For cgroup v2 systems, the initial cpuset_bind() call will set the masks correctly. For cgroup v1 systems, the second call to cpuset_bind() will do the right setup. cc: stable@vger.kernel.org Signed-off-by: Waiman Long Tested-by: Feng Tang Reviewed-by: Michal Koutný Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- kernel/cgroup/cpuset.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3289,8 +3289,11 @@ static struct notifier_block cpuset_trac */ void __init cpuset_init_smp(void) { - cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask); - top_cpuset.mems_allowed = node_states[N_MEMORY]; + /* + * cpus_allowd/mems_allowed set to v2 values in the initial + * cpuset_bind() call will be reset to v1 values in another + * cpuset_bind() call when v1 cpuset is mounted. + */ top_cpuset.old_mems_allowed = top_cpuset.mems_allowed; cpumask_copy(top_cpuset.effective_cpus, cpu_active_mask);