From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26A1921FF55 for ; Sat, 27 Dec 2025 07:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766821359; cv=none; b=i5Smj1SLshvgmLZKxZ7cv1qa9diNmw4ZAdU/WDEb7fokle9MyY6WTMCPQhWqOQKwSoKDjKCnBs/ilQZNJoQqI1bw7mTphVNrICTSwz39qVa1JiyJY7F6muXUyGgFnYbDPiZZ6GtSdTgZ2Djpp1iMXr2oZTzj6l9U49T53kiwGDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766821359; c=relaxed/simple; bh=BocZbYRq6z/au+ST87u3K7kwQZG0Z/SXAcjr75/GKmo=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=LU5jLWsbY/f7hrgdBjkb+rFkIEkylV9AaybarRX+udAH0EWNZt8P7u0jmUzMUpklwqeaTIhOO67QnOO2QNsdnOoTd1WnD034EXrODMocC2J9cD1jkXiC7RpR+AF3bZ0Q/m1H/UqowvlrBybCER6KBfTq2OhdPP4Dc46bY4ongPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YX52qJ0D; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=oSxuZa5v; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YX52qJ0D"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="oSxuZa5v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1766821357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ai5QZoNo9dRmzRpnYcu62kdxHtsGiqg1pjhwu4q+YNg=; b=YX52qJ0DPEwbY5aXX522mi3j98XfZbu2jJdpVgNwZ0f+btUvhrMeLIbJwqmXvdY92k7R0H goRfNzeAn9toTXOs7rf520X8galLKzQDUT1LTNNq6qM4HghyVsoz2nQaeA/rJyOoTh2lDl dCHSZwQWMYOciqMNbCsh5m3C9W9XZt8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-MFbu70AANqWLN91OY_KGLA-1; Sat, 27 Dec 2025 02:42:35 -0500 X-MC-Unique: MFbu70AANqWLN91OY_KGLA-1 X-Mimecast-MFC-AGG-ID: MFbu70AANqWLN91OY_KGLA_1766821355 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8b24383b680so2609100285a.0 for ; Fri, 26 Dec 2025 23:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1766821355; x=1767426155; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=ai5QZoNo9dRmzRpnYcu62kdxHtsGiqg1pjhwu4q+YNg=; b=oSxuZa5vzKUr+dMw1Ahha0TB0QpuQXGgHk7N28EP1Qu2ALB7F94naW7TrEC+WSJfKu dRNx7ZrVj6IkrcKYOet0FiLoZnxSKdkT/MFVm6JNrhIH1FJXzLMXV/12PKqttK+Sqg6+ nunyWwvxXcSZljJLa21eF6CDYcfg+DRvv/6c4Z3I/i8uDvq/ksd7s6LV9g+/x9yJ1dFx P2gUTJzlTKqeOoIgWSIjC4PuT6B7h4NdSqcfkqbNt5WW9lXhxVJB4LretWXbsjKVbtgE mAA7YcQ2Qm8CnUDThe5ThL28YZfFY6aIP1rxnmOSmkwlEjrqgkcJV211Adx+iHV0z+qv 9l1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766821355; x=1767426155; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ai5QZoNo9dRmzRpnYcu62kdxHtsGiqg1pjhwu4q+YNg=; b=OGsf387IYPWttFV3RKYdifhVADZemvRNIR9F9tgmQY/rHIrVB0A6eSfSfLhqQx0Pwz Q2CrXUz2upROEqqzNIrOBmc+ooZnpxVwfg2XFIYwhj6aEzTi5Y3FN3t3D2eRySoezRpK Gk+TcydOZ9M1eBOWcIstuqBZd4aqWU+zy1k4tiNxIDzdX5KvSUMrp3lJ07j+rSii2sOl fLLQVg5a04Doqib0emdm1YO0jc9LzXGy4G4DVIvvGLTLoz1soeCxqiZeSFqbAUNHNW57 w5Wxf8A46/Xh0SIfXIIe7bwO/k4XzhcRnz118OJtyGVhYvkADdL310B1AszD8xYjkeeJ FV3A== X-Gm-Message-State: AOJu0YyBaPViF01KeGWDIIkBekajB9tHPeTpVLdyCErkoQ80XjZ/PwEC 73vFFh40zKmXQtDzXA2ru5FSaQn1zTh3kDsZz+7sGrRHDlw+muS9I18We9NRL1ytOKVHtT+DiyC 2VQLzHjzy+rsifXYABVabEu0szg4BO9r2VdYvDNcEbSAabXcEblP0joDCW8XY+ZmqKA== X-Gm-Gg: AY/fxX69Ma/qYfiSdHyo8gMEOeDxavXtV4MiAdQOWBk07ks9v/Np4n2GW8+mzCWLx9v ZyRlUHRmeV9oTuJ5RjpZvoTR30YaHrkAmc+hX82lwEv6g7eH6LqZkHkHgZFQmB085zdDP8pg6Gn Ul6NFAiRdUST+aQrkqAhf6L3UcMnjiPxbcJu5cI65Znje7WtMYNsVN63pD46pHPiMlvvvHT9Oyn qhp6b10CxJmAdicksvERr+/+wy9Mi3+rOtOXFhBVH8WIlauT2JOzPdAu6sA8ouEO1p6El3jd/du 4OrCS6IdEc1qkOE8rErQvi2DzG0pKxP9Q3b7ZfDhxBD1nPk6BW0dicehPrjkv1gP7Xz0bLXONho f/A/4SBv4bHjVv/OU6/EWNBTCV1VAEYra4v8KHFoVGuXn/WqAeBBOY8iV X-Received: by 2002:a05:620a:691a:b0:8a3:22d7:6ca3 with SMTP id af79cd13be357-8c08f66c311mr4100430685a.31.1766821354704; Fri, 26 Dec 2025 23:42:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgUkS9lhL5RJ5RrznVdm76aY6GDLmzlCdRQHSFG0i9N6BzjWpT0CJfzF++onNseQeBYwVs1A== X-Received: by 2002:a05:620a:691a:b0:8a3:22d7:6ca3 with SMTP id af79cd13be357-8c08f66c311mr4100428585a.31.1766821354210; Fri, 26 Dec 2025 23:42:34 -0800 (PST) Received: from ?IPV6:2601:600:947f:f020:85dc:d2b2:c5ee:e3c4? ([2601:600:947f:f020:85dc:d2b2:c5ee:e3c4]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c0973f08fcsm1897016385a.40.2025.12.26.23.42.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Dec 2025 23:42:33 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: <471d1be6-db23-42b2-a5e8-5207fb4dcaeb@redhat.com> Date: Sat, 27 Dec 2025 02:42:32 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [cgroup/for-6.20 PATCH 3/4] cgroup/cpuset: Don't fail cpuset.cpus change in v2 To: Chen Ridong , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, Sun Shaojie References: <20251225073056.30789-1-longman@redhat.com> <20251225073056.30789-4-longman@redhat.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/25/25 4:30 AM, Chen Ridong wrote: > > On 2025/12/25 15:30, Waiman Long wrote: >> Commit fe8cd2736e75 ("cgroup/cpuset: Delay setting of CS_CPU_EXCLUSIVE >> until valid partition") introduced a new check to disallow the setting >> of a new cpuset.cpus.exclusive value that is a superset of a sibling's >> cpuset.cpus value so that there will at least be one CPU left in the >> sibling in case the cpuset becomes a valid partition root. This new >> check does have the side effect of failing a cpuset.cpus change that >> make it a subset of a sibling's cpuset.cpus.exclusive value. >> >> With v2, users are supposed to be allowed to set whatever value they >> want in cpuset.cpus without failure. To maintain this rule, the check >> is now restricted to only when cpuset.cpus.exclusive is being changed >> not when cpuset.cpus is changed. >> >> Signed-off-by: Waiman Long >> --- >> kernel/cgroup/cpuset.c | 30 +++++++++++++++--------------- >> 1 file changed, 15 insertions(+), 15 deletions(-) >> >> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >> index 850334dbc36a..83bf6b588e5f 100644 >> --- a/kernel/cgroup/cpuset.c >> +++ b/kernel/cgroup/cpuset.c >> @@ -609,33 +609,31 @@ static inline bool cpusets_are_exclusive(struct cpuset *cs1, struct cpuset *cs2) >> >> /** >> * cpus_excl_conflict - Check if two cpusets have exclusive CPU conflicts >> - * @cs1: first cpuset to check >> - * @cs2: second cpuset to check >> + * @trial: the trial cpuset to be checked >> + * @sibling: a sibling cpuset to be checked against >> + * @new_xcpus: new exclusive_cpus in trial cpuset >> * > Can we rename it to xcpus_changed? > > The current name new_xcpus gives me the impression that CPUs are being added. > For example: if exclusive_cpus is 1, and it changes to 1-7, then new_xcpus would be 2-7. Sure. I will make the change in the next version. Cheers, Longman > >> * Returns: true if CPU exclusivity conflict exists, false otherwise >> * >> * Conflict detection rules: >> * 1. If either cpuset is CPU exclusive, they must be mutually exclusive >> * 2. exclusive_cpus masks cannot intersect between cpusets >> - * 3. The allowed CPUs of one cpuset cannot be a subset of another's exclusive CPUs >> + * 3. The allowed CPUs of a sibling cpuset cannot be a subset of the new exclusive CPUs >> */ >> -static inline bool cpus_excl_conflict(struct cpuset *cs1, struct cpuset *cs2) >> +static inline bool cpus_excl_conflict(struct cpuset *trial, struct cpuset *sibling, >> + bool new_xcpus) >> { >> /* If either cpuset is exclusive, check if they are mutually exclusive */ >> - if (is_cpu_exclusive(cs1) || is_cpu_exclusive(cs2)) >> - return !cpusets_are_exclusive(cs1, cs2); >> + if (is_cpu_exclusive(trial) || is_cpu_exclusive(sibling)) >> + return !cpusets_are_exclusive(trial, sibling); >> >> /* Exclusive_cpus cannot intersect */ >> - if (cpumask_intersects(cs1->exclusive_cpus, cs2->exclusive_cpus)) >> + if (cpumask_intersects(trial->exclusive_cpus, sibling->exclusive_cpus)) >> return true; >> >> - /* The cpus_allowed of one cpuset cannot be a subset of another cpuset's exclusive_cpus */ >> - if (!cpumask_empty(cs1->cpus_allowed) && >> - cpumask_subset(cs1->cpus_allowed, cs2->exclusive_cpus)) >> - return true; >> - >> - if (!cpumask_empty(cs2->cpus_allowed) && >> - cpumask_subset(cs2->cpus_allowed, cs1->exclusive_cpus)) >> + /* The cpus_allowed of a sibling cpuset cannot be a subset of the new exclusive_cpus */ >> + if (new_xcpus && !cpumask_empty(sibling->cpus_allowed) && >> + cpumask_subset(sibling->cpus_allowed, trial->exclusive_cpus)) >> return true; >> >> return false; >> @@ -672,6 +670,7 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) >> { >> struct cgroup_subsys_state *css; >> struct cpuset *c, *par; >> + bool new_xcpus; >> int ret = 0; >> >> rcu_read_lock(); >> @@ -728,10 +727,11 @@ static int validate_change(struct cpuset *cur, struct cpuset *trial) >> * overlap. exclusive_cpus cannot overlap with each other if set. >> */ >> ret = -EINVAL; >> + new_xcpus = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus); >> cpuset_for_each_child(c, css, par) { >> if (c == cur) >> continue; >> - if (cpus_excl_conflict(trial, c)) >> + if (cpus_excl_conflict(trial, c, new_xcpus)) >> goto out; >> if (mems_excl_conflict(trial, c)) >> goto out;