From nobody Sun Dec 14 07:58:07 2025 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (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 7A16A234964; Fri, 8 Aug 2025 09:39:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754645985; cv=none; b=PL+3i5gKpkqqIovi0Vh7qX2hrw9FVrR5xJWaC2eYn3qEyQ5gkwRaBJ6saF+10A1wdhzrm0i1L2uZpcHgnOI4bcaHFBAQbl/vOHiW/LkeqY+USIHuhNnMC+LFJj+yg4YiEOlrU9xzGgckOPJcAIB7AezJfBPzRzTgNo35prhejZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754645985; c=relaxed/simple; bh=nuvDQkTuXmlWPc3BCR56LkiqLEc43VVTTjcKcdBiriQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EZgm5Y89K3qpOmxxVgL7NywSNf6jaMlLOGGQ9x9EkoAvg6Oz8eJFnjhne0KffIMK8qLv4c67D/w0WA7Z1/hEucOrUrtTFOlptK7iqL7dr4PiNcT2ACTcaMbYoWNunhsA09GV7T0WdXz3DBS+xN8a3J9GwF2z+bSCQ2paGfbulG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4byzWy04TBzKHMsQ; Fri, 8 Aug 2025 17:39:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 1FACC1A1C15; Fri, 8 Aug 2025 17:39:41 +0800 (CST) Received: from hulk-vt.huawei.com (unknown [10.67.174.121]) by APP2 (Coremail) with SMTP id Syh0CgCXo7XPxZVooOS_Cw--.51716S4; Fri, 08 Aug 2025 17:39:40 +0800 (CST) From: Chen Ridong To: tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, longman@redhat.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, lujialin4@huawei.com, chenridong@huawei.com Subject: [PATCH -next 2/4] cpuset: add helpers for cpuset related locks Date: Fri, 8 Aug 2025 09:25:13 +0000 Message-Id: <20250808092515.764820-3-chenridong@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250808092515.764820-1-chenridong@huaweicloud.com> References: <20250808092515.764820-1-chenridong@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: Syh0CgCXo7XPxZVooOS_Cw--.51716S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr4kZF4DKF1DCFWUGrW5Awb_yoW8Zw48pF yDK347JrW5AF18u343Gw1Uua48Kw1kWa1UG3WkJa4rZFy2vF1q9F1DCr9xXr15Kr47CF1U AFsI93ya9a4DJrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7CjxVAaw2AFwI 0_GFv_Wryl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a6rW5MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0jN t3UUUUU== X-CM-SenderInfo: hfkh02xlgr0w46kxt4xhlfz01xgou0bp/ Content-Type: text/plain; charset="utf-8" From: Chen Ridong Add guard_cpus_read_and_cpuset and guard_cpuset helpers for cpuset, which will be user for subsequent patched to make code concise; Signed-off-by: Chen Ridong --- include/linux/cpuset.h | 1 + kernel/cgroup/cpuset-internal.h | 2 ++ kernel/cgroup/cpuset.c | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 2ddb256187b5..6153de28acf0 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h @@ -74,6 +74,7 @@ extern void inc_dl_tasks_cs(struct task_struct *task); extern void dec_dl_tasks_cs(struct task_struct *task); extern void cpuset_lock(void); extern void cpuset_unlock(void); +extern void guard_cpuset(void); extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mas= k); extern bool cpuset_cpus_allowed_fallback(struct task_struct *p); extern bool cpuset_cpu_is_isolated(int cpu); diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-interna= l.h index 75b3aef39231..084e19fe33d5 100644 --- a/kernel/cgroup/cpuset-internal.h +++ b/kernel/cgroup/cpuset-internal.h @@ -277,6 +277,8 @@ ssize_t cpuset_write_resmask(struct kernfs_open_file *o= f, char *buf, size_t nbytes, loff_t off); int cpuset_common_seq_show(struct seq_file *sf, void *v); =20 +void guard_cpus_read_and_cpuset(void); + /* * cpuset-v1.c */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index cf7cd2255265..f6cdb5cdffe8 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -260,6 +260,17 @@ void cpuset_unlock(void) mutex_unlock(&cpuset_mutex); } =20 +void guard_cpuset(void) +{ + guard(mutex)(&cpuset_mutex); +} + +void guard_cpus_read_and_cpuset(void) +{ + guard(cpus_read_lock)(); + guard(mutex)(&cpuset_mutex); +} + static DEFINE_SPINLOCK(callback_lock); =20 void cpuset_callback_lock_irq(void) --=20 2.34.1