cgroup/cpuset: Remove the unnecessary css_get/put() in cpuset_partition_write()
authorWaiman Long <longman@redhat.com>
Wed, 6 Aug 2025 17:24:30 +0000 (13:24 -0400)
committerTejun Heo <tj@kernel.org>
Sat, 9 Aug 2025 18:42:47 +0000 (08:42 -1000)
The css_get/put() calls in cpuset_partition_write() are unnecessary as
an active reference of the kernfs node will be taken which will prevent
its removal and guarantee the existence of the css. Only the online
check is needed.

Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c

index d993e058a66394088cfc49d7757cc61a8a18f2f4..27adb04df675d4521ae1589632a1831892b16422 100644 (file)
@@ -3358,14 +3358,12 @@ static ssize_t cpuset_partition_write(struct kernfs_open_file *of, char *buf,
        else
                return -EINVAL;
 
-       css_get(&cs->css);
        cpus_read_lock();
        mutex_lock(&cpuset_mutex);
        if (is_cpuset_online(cs))
                retval = update_prstate(cs, val);
        mutex_unlock(&cpuset_mutex);
        cpus_read_unlock();
-       css_put(&cs->css);
        return retval ?: nbytes;
 }