Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2657846pxb; Tue, 13 Apr 2021 07:13:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHPM9rTWoLZbVSVfBY10jNeCWutXnPLgQySxYBJZ8kk7mqiDpch0WR4Y3mX3kAVMAfnXRJ X-Received: by 2002:a05:600c:198d:: with SMTP id t13mr191442wmq.165.1618323180214; Tue, 13 Apr 2021 07:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618323180; cv=none; d=google.com; s=arc-20160816; b=ZtddHvtyjugkBjSaauiLkbEt+IwTq196p3EH6FL8AQ3+1PHq/cwWfd+nTFmYbplmlN agowwJi0wNWdHvWUQmR5ysrwgAXk/pdzZp90IBg0gQ9MPmjnmXXVQV8CZR3hdnsuepOt V5GVXZEDU48wtrR5+slMa4ESly2rPEJ3TIa3AJDz4blrmHoVfPfU1s8sMKNGt9eejpeA 7S+llG6p3fQ57QaDnkeqUxUBdzVm2wr661FfKfhOMwP7u4BuLZ82Pn/sFivbY4aeOr8+ 9F6CiHiGtLGSQqGlfkeZrPrxxk0LN4PNOWKkZmzTbKhBNC3eAWS48wlJKMkLA0egtd3e WbZg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4iJUYo21aTslz6Z8Ta9PIHGPXdm8gkXi8+0HPXoSBsQ=; b=Paoxc0jHjA780UDaAkeVLDiSYbQODDkGfQW1JAabfBajB8tVeL9q7L/SfnT/CPxpyb J7aX4bX9LCudxxH8vEgYDC6jDTYvF3C+BQq9YJGWEFua1Mbxu5nqnc49FUFBnL9YxdN5 5G3mjQ1OOgg9PGMZ3Ya971wGknl5+jZKjfIvRmTDxX8aV05m6E9LictML9fsZR6vMMGG u8+q+SM1nkAwA4pDS80LE36kMDzF92aH1kw9DL1O8QUQz72uVYUBMZ7k4j9mOhw7XH+e BUIBktus5XqtsCvNj2H04aB8zMQ8B65PwI3NAbSBLGXDgpaJHmL2bjVPS8Y8ynzAuDyr epBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@uged.al header.s=google header.b=VD1IkuKh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hg15si6604803ejc.179.2021.04.13.07.12.36; Tue, 13 Apr 2021 07:13:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@uged.al header.s=google header.b=VD1IkuKh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241558AbhDMJDb (ORCPT + 99 others); Tue, 13 Apr 2021 05:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbhDMJD3 (ORCPT ); Tue, 13 Apr 2021 05:03:29 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9D6CC06175F for ; Tue, 13 Apr 2021 02:03:08 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id f17so19082080lfu.7 for ; Tue, 13 Apr 2021 02:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uged.al; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4iJUYo21aTslz6Z8Ta9PIHGPXdm8gkXi8+0HPXoSBsQ=; b=VD1IkuKhEvpeeF08omMrTP4Zn1dGCpJFSkgyvFwfXaYHJ7c/DULWvIUG3ZDl1jhk5N SrJ/virX6o+L0WmJVF9o57v9OGLLJCUI+2M4H4NXnrW1UINI6LOr1fBFjFDPp7+SOfkH EbC+WgNXCK0PFEllFpyKjnunx9Chn7otj8uCsnlim9/NlCmap6FTOU/p18miIowlpBND HJJIAw7oVmTxLguV2vEsWwH4D2iwYTt7shERHYNrJT+/7kr+sWxK5C8pYlNLYCzfafbZ Dqa7J1ho/Y8msY+HCLR0mmCF0Om9SVM7kw+bt3amoVS+wfzNfBRdIVjcXJ+i1bRcoJd4 25dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4iJUYo21aTslz6Z8Ta9PIHGPXdm8gkXi8+0HPXoSBsQ=; b=frLW3mWuu68GLCs2rwh+umzvWvX876H1yf4WsC++nWdrvJYjSLz4LOtZlXx5T5sTrj 73OyMCZ9WMbjjLlDBrqr1ZJNzKjPrUqyne/SqSW6TI9x306e+wUZWmBnlrXK7AZaIcY6 HUxuAa7OjbYeXkrhDu7db7T0EdAbcvBGy1snTjQpBC9kWf7fdz/yQMWFa8jmVEYK+cc6 tHTd1MF5o9hqcygkXJvjsZQ+sCsffKMtEJzGfLUC7AJ42MuNqT5f1P9pjvgr3Gl9OVrh 337gzoU+Nq6m4nzEpNSiMlUe4a8+BpwKQF1mZmIMCWVF0/4JsYQJgJzAVuiuaRA8T4YO oZsw== X-Gm-Message-State: AOAM530IdhyOXhjEVaoRSAF34GGOvQR5NYSYEmJa5WokjLweq6deaLpr hKgT7VhvkM8iBpuIUt9dUFp4xQ== X-Received: by 2002:a19:6d07:: with SMTP id i7mr21957674lfc.568.1618304587073; Tue, 13 Apr 2021 02:03:07 -0700 (PDT) Received: from xps.wlan.ntnu.no ([2001:700:300:4008:3fb5:15ad:78ca:d9c1]) by smtp.gmail.com with ESMTPSA id o11sm3722912ljg.42.2021.04.13.02.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 02:03:06 -0700 (PDT) From: Odin Ugedal To: tj@kernel.org, lizefan.x@bytedance.com Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Odin Ugedal Subject: [PATCH 1/2] cgroup2: cpuset: Disable subset validation on set Date: Tue, 13 Apr 2021 11:02:34 +0200 Message-Id: <20210413090235.1903026-2-odin@uged.al> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210413090235.1903026-1-odin@uged.al> References: <20210413090235.1903026-1-odin@uged.al> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Due to how cpuset works in v2, there is no need to check if direct children are subsets of the new cpuset. In v2, the effective cpuset of a cgroup is the intersection between the effective value of the parent and the cpuset.cpus value of the cgroup, with a fallback to the effective parent value in case the intersection is an empty set. Therefore, in v2, it is allowed to set cpuset.cpus to a a value that is not a subset of the parents effective value, resulting in inheriting the effective cpuset from the parent. Therefore the validation when updating the parent cpuset (in this case) is not necessary, and can be disabled. Example: /sys/fs/cgroup/A (cpus=1-2,cpus.effective=1-2) /sys/fs/cgroup/A/B (cpus="", cpus.effective=1-2) Setting cpus to 3-4 is possible for A/B /sys/fs/cgroup/A (cpus=1-2,cpus.effective=1-2) /sys/fs/cgroup/A/B (cpus=3-4,cpus.effective=1-2) Setting cpus to 1 for A would result in an -EBUSY error, but with this patch it will work as expected: /sys/fs/cgroup/A (cpus=1, cpus.effective=1) /sys/fs/cgroup/A/B (cpus=3-4,cpus.effective=1) This also applies in a similar manner on cpuset.mems. Signed-off-by: Odin Ugedal --- kernel/cgroup/cpuset.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 5258b68153e0..f543c4c6084a 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -572,11 +572,13 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) rcu_read_lock(); - /* Each of our child cpusets must be a subset of us */ + /* On legacy hierarchy, each of our child cpusets must be a subset of us */ ret = -EBUSY; - cpuset_for_each_child(c, css, cur) - if (!is_cpuset_subset(c, trial)) - goto out; + if (!is_in_v2_mode()) { + cpuset_for_each_child(c, css, cur) + if (!is_cpuset_subset(c, trial)) + goto out; + } /* Remaining checks don't apply to root cpuset */ ret = 0; -- 2.31.0