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 C7F413358DC for ; Mon, 24 Nov 2025 22:30:54 +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=1764023456; cv=none; b=BIghU5HS+o5eHCFfFUroemyZVMDYaEPHic0PIh6r7Y2kinqMEib0J8vzsf5O8OPFnhGjo2sdg1rlDFEQAz15LrOw2gPHnWytY/Lr+dzJZ7BWGRY5777pRffwTSBMHhnQlmuU6ljJM+bDzXJD2s0zQyNM9RwmRVBXBcobqHCX7wU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764023456; c=relaxed/simple; bh=Ma5Gp3Rn9XAktfuix9YxIsx1vONHyvcQA1nIX3sD0uU=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=cUdsC69BC7W0pTo6/Q//nv4gV4lCbP40HroMq23ebqPZkztV8o7nx6/BwwPZrhS2fuR4fDOCX5eMtnu7PdtqnyMzl5VIZx3Hr7kxzIyHaAFqt6JByqWJav8nH3G1auv5Twtkuj+3ojbDiWGU2NNnwrjzn8qT+MVZwKNiODsKfNo= 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=bTmL0J+A; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Nrj11RFw; 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="bTmL0J+A"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Nrj11RFw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764023453; 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=KoP525ssCRg2OKlXGZXKs9q8PWYqzk3vCBsuJGMuCXY=; b=bTmL0J+An0FB4rPQNJPy72PeKomVa6nPIeKqVw8Ukbh4diptKGFzqr5ljk0tuMyuhc3wS+ +AOu4uR3727Thq8SKKPLLKD8mPJtwpSVsaufGwkO0gzPsfrNm+fKprPnCRliROaMSc6MVa ettLeEBJ6rONQc8oHo0BpzlItSv7XOM= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-F-fdpKBXN5ONwrcxGdwdtw-1; Mon, 24 Nov 2025 17:30:52 -0500 X-MC-Unique: F-fdpKBXN5ONwrcxGdwdtw-1 X-Mimecast-MFC-AGG-ID: F-fdpKBXN5ONwrcxGdwdtw_1764023451 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-8b19a112b75so1248265185a.1 for ; Mon, 24 Nov 2025 14:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764023451; x=1764628251; 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=KoP525ssCRg2OKlXGZXKs9q8PWYqzk3vCBsuJGMuCXY=; b=Nrj11RFwXG/49gBejQNwm2b5p10OMRhxdPL7ndC+5ka5c/JgKuUCR4Nue2dCWw33GV T28L3fKFIejpNCmbGUtKTjtTwHmNSMYoLby9NYWNQwXIAc9ybHNCkzbVVH3R9nIZGStG IjtXg2KID7NFRzolnnwhf8NXFvHetksbNmV8azHw65uysxbS3EJ30lGLWuLjQd303wct cm+jSY6w/LXOudASW9uVeA34XrgWJH/B5GrMF0WEG8T82BLcMvSn21xtLWStapyJO0iO V8tMthg5PqY9aVhE16i8loGSWhRZxc2/WSmlgOn42p9ysKwaECuZJ+Pyj0p3HG5PPoeI qm8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764023451; x=1764628251; 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=KoP525ssCRg2OKlXGZXKs9q8PWYqzk3vCBsuJGMuCXY=; b=SsV115DXA14RruKg4kXHdasLkrgNoA0r/+8aR0OReuB2yDfDlT46IhhaoaRYkzmjUS qDUuJ3IOZOPsTERt78Ej7E223lFM5WKt3tuoWQThpG68mqAFVa3+4uwkHXwUOoMZnVlW O3QPkk1DjgFrGI4b27bId45ycee93DfsGijrRGKX983iAVGUaGsTuW3MELey9HytVvPL sf7jjUZFTcuy8T/pj1V5b+8d75o6ILz/Wg/0HGDDrPc3WXq4RrbkMYqIweftnAeTgOfO hzpgKSIV5SsZL7WQ3b+HHu915cZ24cNnMGSBND4XJLQDEFfMP32eY5tKVBIIet24tUHA +Ogg== X-Forwarded-Encrypted: i=1; AJvYcCXuVH81q993Ga8jnqVqAH6On0xgbCoij6O8dpv1LcbnV8mUALlFC+R8z8tL+4ZS/jbDN238zuX+Iak9e4U=@vger.kernel.org X-Gm-Message-State: AOJu0Yy44Qwg6cre4xTy1rqOo5MEOXBpASZmonqJCTt56X+bK+b1Skhj fUmK8IWhxuPGwuEFzMvc1nHqMy+jfQ0KiHLoOLP7Urllr4476c8CWCng58tVypIXm9CffLMzBzg FEJJjQLgIYV7SVQVGpazj6siOUcT1jEk/fRiT8otHgori/M8JrLkkC7vpAjjO1cuOiu88qcjHeQ == X-Gm-Gg: ASbGncvB324nyNEtJvGABWVHTtj980QqeMKwsPdZvk9Bq7P+v18I0ACFuVyDiUHaito D1BFsPjPGgb7IJlOuup1ugIsH4SBL5ZD8wKQhuaXSA7zW2y2Xtdp1yD55vU4jCdMrX9VQ4nBUzq KniWZ7YW35cNIWQ064hbHdIby9XQ7ujeW9uO7/AA9+YV670q+DCZKSb4MIkgRsjzVH7LK4TlQ9y CQczamajl2N6E/Rra+nyPtlIvdZMeYiA3zZ9MPDtmgnW8b5usi6PEpM8wnR/Ma1GgrQ6BZim3IZ wP81B0ri3sisBK5JVnLVA2TStZKr4ve1SGC+QyN5eKWjlPbVTM5iDM3yDQucVAm63/pLswBMQDU fIw3kdu91Pze6XuWAFQv++bQd2PICrjEQXTSUoRqHA+91s6snEiJTU4Fu X-Received: by 2002:a05:620a:4103:b0:8b2:e986:2707 with SMTP id af79cd13be357-8b33d469944mr1613873885a.45.1764023450623; Mon, 24 Nov 2025 14:30:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxDBzOKv9gEGaZee+4kgDDEfxbFXSsDuGuND/YR/+VTzDbJflyatKadpotTWCFz9xhV/bULA== X-Received: by 2002:a05:620a:4103:b0:8b2:e986:2707 with SMTP id af79cd13be357-8b33d469944mr1613867585a.45.1764023449993; Mon, 24 Nov 2025 14:30:49 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8b3295c13ccsm1035133785a.26.2025.11.24.14.30.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Nov 2025 14:30:49 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Mon, 24 Nov 2025 17:30:47 -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: [PATCH v5] cpuset: Avoid invalidating sibling partitions on cpuset.cpus conflict. To: Sun Shaojie , llong@redhat.com, chenridong@huaweicloud.com, mkoutny@suse.com Cc: cgroups@vger.kernel.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, tj@kernel.org References: <20251119105749.1385946-1-sunshaojie@kylinos.cn> Content-Language: en-US In-Reply-To: <20251119105749.1385946-1-sunshaojie@kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/19/25 5:57 AM, Sun Shaojie wrote: > Currently, when setting a cpuset's cpuset.cpus to a value that conflicts > with its sibling partition, the sibling's partition state becomes invalid. > However, this invalidation is often unnecessary. If the cpuset being > modified is exclusive, it should invalidate itself upon conflict. > > This patch applies only to the following two cases: > > Assume the machine has 4 CPUs (0-3). > > root cgroup > / \ > A1 B1 > > Case 1: A1 is exclusive, B1 is non-exclusive, set B1's cpuset.cpus > > Table 1.1: Before applying this patch > Step | A1's prstate | B1's prstate | > #1> echo "0-1" > A1/cpuset.cpus | member | member | > #2> echo "root" > A1/cpuset.cpus.partition | root | member | > #3> echo "0" > B1/cpuset.cpus | root invalid | member | > > After step #3, A1 changes from "root" to "root invalid" because its CPUs > (0-1) overlap with those requested by B1 (0). However, B1 can actually > use CPUs 2-3(from B1's parent), so it would be more reasonable for A1 to > remain as "root." > > Table 1.2: After applying this patch > Step | A1's prstate | B1's prstate | > #1> echo "0-1" > A1/cpuset.cpus | member | member | > #2> echo "root" > A1/cpuset.cpus.partition | root | member | > #3> echo "0" > B1/cpuset.cpus | root | member | > > Case 2: Both A1 and B1 are exclusive, set B1's cpuset.cpus > > Table 2.1: Before applying this patch > Step | A1's prstate | B1's prstate | > #1> echo "0-1" > A1/cpuset.cpus | member | member | > #2> echo "root" > A1/cpuset.cpus.partition | root | member | > #3> echo "2" > B1/cpuset.cpus | root | member | > #4> echo "root" > B1/cpuset.cpus.partition | root | root | > #5> echo "1-2" > B1/cpuset.cpus | root invalid | root invalid | > > After step #4, B1 can exclusively use CPU 2. Therefore, at step #5, > regardless of what conflicting value B1 writes to cpuset.cpus, it will > always have at least CPU 2 available. This makes it unnecessary to mark > A1 as "root invalid". > > Table 2.2: After applying this patch > Step | A1's prstate | B1's prstate | > #1> echo "0-1" > A1/cpuset.cpus | member | member | > #2> echo "root" > A1/cpuset.cpus.partition | root | member | > #3> echo "2" > B1/cpuset.cpus | root | member | > #4> echo "root" > B1/cpuset.cpus.partition | root | root | > #5> echo "1-2" > B1/cpuset.cpus | root | root invalid | > > In summary, regardless of how B1 configures its cpuset.cpus, there will > always be available CPUs in B1's cpuset.cpus.effective. Therefore, there > is no need to change A1 from "root" to "root invalid". > > All other cases remain unaffected. For example, cgroup-v1. This patch is relatively simple. As others have pointed out, there are inconsistency depending on the operation ordering. In the example above, the final configuration is A1:0-1 & B1:1-2. As the cpu lists overlap, we can't have both of them as valid partition roots. So either one of A1 or B1 is valid or they are both invalid. The current code makes them both invalid no matter the operation ordering.  This patch will make one of them valid given the operation ordering above. To minimize partition invalidation, we will have to live with the fact that it will be first-come first-serve as noted by Michal. I am not against this, we just have to document it. However, the following operation order will still make both of them invalid: # echo "0-1" >A1/cpuset.cpus # echo "2" > B1/cpuset.cpus # echo "1-2" > B1/cpuset.cpus # echo "root" > A1/cpuset.cpus.partition # echo "root" > B1/cpuset.cpus.partition To follow the "first-come first-serve" rule, A1 should be valid and B1 invalid. That is the inconsistency with your current patch. To fix that, we still need to relax the overlap checking rule similar to your v4 patch. Cheers, Longman