From nobody Wed Feb 5 21:53:23 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 283071E3DE4 for ; Mon, 20 Jan 2025 14:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737385085; cv=none; b=RiHeXPPTirBvjVFc24BOGod/Fn+zW/tUXy0vWcA27pYSQsfJmBQIuECLFq2pOiyMskHaqE4bnRQjRHlxHx/fjvb8wB3AFlpgEOwfoGEmnVUJNmiE3XV93laatsiV3Rn93hUfr7B2gzUqgA294IN+0+8MCk30KMrGVabOBLzj3OU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737385085; c=relaxed/simple; bh=56WlhH6jPzqZByuiYdl4jsWwIAL/Ut6r6VEEsRXxnpo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=fqaVs8iE8fg/dInQzVFgUKNM3emdOcY9pIvL4dKeVcAlIiTBHBacudT8YasBZUz1aJja9Qtrap5yrnXnkb7DIyDdDm9tjoPOWHjqLIasHPtml7IMPpwtpInu/u3y3tZ6Dp2a2Kaz15loJsCEUm4M1u1K6W/6bwBhp/nODi8gVFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=aaabB0Df; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="aaabB0Df" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4361b6f9faeso29087495e9.1 for ; Mon, 20 Jan 2025 06:58:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1737385080; x=1737989880; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DigW40pwT4nOr0qZtSkWArRwF+H88GufczXyIQiDM4M=; b=aaabB0DfD/FM1quX1LDzMra+vtge5CEOdF/PBC9EPr6WaxOMzgopi+DhM2/GLRpfwX JG0K72l7kPIxvWr27fQOVF2OWgqpF6WS7CN6yEP+GNkEAYX+pCMkxZd9Ksp3O9a401BG NNpqaz/HGfOVliBLDTmFWqQzp+Fbi365V0wguwf3H8zS/tyBefsqB7FKhfUyhEEdDfyE 0XdMXX4vpLTVyG5i6gLYVaPGNRuGgNXl/iinNpjwb1reovWrp9+Pa5S9koYVbfTl1zTg 5CO/IAoK6w0omAy/gSvAEw4Fl3YFt4Rjt3ECuDc66II28cvHlyAptnhYuuFKyDQAGjUP tJ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737385080; x=1737989880; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DigW40pwT4nOr0qZtSkWArRwF+H88GufczXyIQiDM4M=; b=hDqdPoavChPqFkV0FPbO20Xpe1eIJJEeUCUxcYhgJoVz0JD5TPc718/acJYwy7AysP O/YNDuTQ7Ell4dIh08drTs2GB6p1UZGapy20R7WuOZ4eSXmzGjbIT6KQLVajQENS0HKK 0TCmi314qI62mLD9LFjt211WEo+P7+/1b0iUW5XZJCWvFCILnRe0FNGGlrk35+0RITdG 2DMwfQ+5hPlO0OtUUdVnKoTJL4LEPVQa3EcVsBVFp5Ww9jsgHt7SdRiEGI8ZwBTFZGzJ IUvLt8kO85bkpSEqFHwLzVq02lRnneZiDU8zpeRWxp2omOFnMTM2g8OWHHr/cdjSmA1F NUkw== X-Gm-Message-State: AOJu0YzPZ+MFI3HcYgDBKY0dqKTW1DqXInU72aGvfH2hT4KuJfCGJZ5I ZrwPtWw1IQXfu4uhP23Vn3H/374XFF/cW+zQQEmpC4twDWlse2barssnDJz7j0sN65HlNdgTFwE O X-Gm-Gg: ASbGncvDLaur7/Vzl4+NkOccBjyKyhV7vJWU8edHUzKzkP3NR1hGMCowLjSyNggVgkR baWKNI2i7HSjs+8E8xeEgkhS2UFAJZLeRAfgi708AehJ4uHfNxmrnZWVhKKrXr3PeWZWcnAfIC2 WVz1giZsqx7Alz2VaKrkYatGw8o3+rrSsAvFc+dXUqHLOXbJl9FzMWC6rNAFJCE8SoVSnfKeUJE /0M0kxyQ9S5UjTvSCzB9DmP9ss5lSkHktUI2e824PvHALt9prAkauQqLkq6GVNXc9a559xE X-Google-Smtp-Source: AGHT+IHBaC/4UsqbYBLrADk+m53X/Kk6KfBMm3DCefyXtGlRjIO7eMUNfspDKGEeUfKGRNdqKRmDSQ== X-Received: by 2002:a05:600c:218e:b0:434:e65e:457b with SMTP id 5b1f17b1804b1-437c6ae9bdcmr194004685e9.3.1737385080284; Mon, 20 Jan 2025 06:58:00 -0800 (PST) Received: from blackdock.suse.cz ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438904087cbsm146156245e9.3.2025.01.20.06.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 06:58:00 -0800 (PST) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Cc: Waiman Long , Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Chen Ridong Subject: [PATCH v3] cgroup/cpuset: Move procfs cpuset attribute under cgroup-v1.c Date: Mon, 20 Jan 2025 15:57:49 +0100 Message-ID: <20250120145749.925170-1-mkoutny@suse.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The cpuset file is a legacy attribute that is bound primarily to cpuset v1 hierarchy (equivalent information is available in /proc/$pid/cgroup path on the unified hierarchy in conjunction with respective cgroup.controllers showing where cpuset controller is enabled). Followup to commit b0ced9d378d49 ("cgroup/cpuset: move v1 interfaces to cpuset-v1.c") and hide CONFIG_PROC_PID_CPUSET under CONFIG_CPUSETS_V1. Drop an obsolete comment too. Signed-off-by: Michal Koutn=C3=BD Acked-by: Waiman Long --- init/Kconfig | 5 +++-- kernel/cgroup/cpuset-v1.c | 41 +++++++++++++++++++++++++++++++++++ kernel/cgroup/cpuset.c | 45 --------------------------------------- 3 files changed, 44 insertions(+), 47 deletions(-) v3 changes: - move dependency on internal cgroup-internal.h to v1-only too Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202501180315.KcDn5BG5-lkp@int= el.com/ v2 changes: - explicitly say what's part of CPUSETS_V1 - commit message wrt effective paths diff --git a/init/Kconfig b/init/Kconfig index a20e6efd3f0fb..2f3121c49ed23 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1182,7 +1182,8 @@ config CPUSETS_V1 help Legacy cgroup v1 cpusets controller which has been deprecated by cgroup v2 implementation. The v1 is there for legacy applications - which haven't migrated to the new cgroup v2 interface yet. If you + which haven't migrated to the new cgroup v2 interface yet. Legacy + interface includes cpuset filesystem and /proc//cpuset. If you do not have any such application then you are completely fine leaving this option disabled. =20 @@ -1190,7 +1191,7 @@ config CPUSETS_V1 =20 config PROC_PID_CPUSET bool "Include legacy /proc//cpuset file" - depends on CPUSETS + depends on CPUSETS_V1 default y =20 config CGROUP_DEVICE diff --git a/kernel/cgroup/cpuset-v1.c b/kernel/cgroup/cpuset-v1.c index 25c1d7b77e2f2..81b5e2a50d587 100644 --- a/kernel/cgroup/cpuset-v1.c +++ b/kernel/cgroup/cpuset-v1.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 +#include "cgroup-internal.h" #include "cpuset-internal.h" =20 /* @@ -373,6 +374,46 @@ int cpuset1_validate_change(struct cpuset *cur, struct= cpuset *trial) return ret; } =20 +#ifdef CONFIG_PROC_PID_CPUSET +/* + * proc_cpuset_show() + * - Print tasks cpuset path into seq_file. + * - Used for /proc//cpuset. + */ +int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, + struct pid *pid, struct task_struct *tsk) +{ + char *buf; + struct cgroup_subsys_state *css; + int retval; + + retval =3D -ENOMEM; + buf =3D kmalloc(PATH_MAX, GFP_KERNEL); + if (!buf) + goto out; + + rcu_read_lock(); + spin_lock_irq(&css_set_lock); + css =3D task_css(tsk, cpuset_cgrp_id); + retval =3D cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, + current->nsproxy->cgroup_ns); + spin_unlock_irq(&css_set_lock); + rcu_read_unlock(); + + if (retval =3D=3D -E2BIG) + retval =3D -ENAMETOOLONG; + if (retval < 0) + goto out_free; + seq_puts(m, buf); + seq_putc(m, '\n'); + retval =3D 0; +out_free: + kfree(buf); +out: + return retval; +} +#endif /* CONFIG_PROC_PID_CPUSET */ + static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype = *cft) { struct cpuset *cs =3D css_cs(css); diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 0f910c828973a..5a637292faa20 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -21,7 +21,6 @@ * License. See the file COPYING in the main directory of the Linux * distribution for more details. */ -#include "cgroup-internal.h" #include "cpuset-internal.h" =20 #include @@ -4244,50 +4243,6 @@ void cpuset_print_current_mems_allowed(void) rcu_read_unlock(); } =20 -#ifdef CONFIG_PROC_PID_CPUSET -/* - * proc_cpuset_show() - * - Print tasks cpuset path into seq_file. - * - Used for /proc//cpuset. - * - No need to task_lock(tsk) on this tsk->cpuset reference, as it - * doesn't really matter if tsk->cpuset changes after we read it, - * and we take cpuset_mutex, keeping cpuset_attach() from changing it - * anyway. - */ -int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, - struct pid *pid, struct task_struct *tsk) -{ - char *buf; - struct cgroup_subsys_state *css; - int retval; - - retval =3D -ENOMEM; - buf =3D kmalloc(PATH_MAX, GFP_KERNEL); - if (!buf) - goto out; - - rcu_read_lock(); - spin_lock_irq(&css_set_lock); - css =3D task_css(tsk, cpuset_cgrp_id); - retval =3D cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, - current->nsproxy->cgroup_ns); - spin_unlock_irq(&css_set_lock); - rcu_read_unlock(); - - if (retval =3D=3D -E2BIG) - retval =3D -ENAMETOOLONG; - if (retval < 0) - goto out_free; - seq_puts(m, buf); - seq_putc(m, '\n'); - retval =3D 0; -out_free: - kfree(buf); -out: - return retval; -} -#endif /* CONFIG_PROC_PID_CPUSET */ - /* Display task mems_allowed in /proc//status file. */ void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *ta= sk) { --=20 2.47.1