Merge branch 'for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Feb 2021 00:50:56 +0000 (16:50 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 23 Feb 2021 00:50:56 +0000 (16:50 -0800)
Pull cgroup updates from Tejun Heo:
 "Nothing interesting. Just two minor patches"

* 'for-5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cpuset: fix typos in comments
  cgroup: cgroup.{procs,threads} factor out common parts

1  2 
kernel/cgroup/cgroup.c

diff --combined kernel/cgroup/cgroup.c
@@@ -3564,7 -3564,6 +3564,7 @@@ static ssize_t cgroup_pressure_write(st
  {
        struct psi_trigger *new;
        struct cgroup *cgrp;
 +      struct psi_group *psi;
  
        cgrp = cgroup_kn_lock_live(of->kn, false);
        if (!cgrp)
        cgroup_get(cgrp);
        cgroup_kn_unlock(of->kn);
  
 -      new = psi_trigger_create(&cgrp->psi, buf, nbytes, res);
 +      psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi;
 +      new = psi_trigger_create(psi, buf, nbytes, res);
        if (IS_ERR(new)) {
                cgroup_put(cgrp);
                return PTR_ERR(new);
@@@ -4728,8 -4726,8 +4728,8 @@@ static int cgroup_attach_permissions(st
        return ret;
  }
  
- static ssize_t cgroup_procs_write(struct kernfs_open_file *of,
-                                 char *buf, size_t nbytes, loff_t off)
+ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
+                                   bool threadgroup)
  {
        struct cgroup *src_cgrp, *dst_cgrp;
        struct task_struct *task;
        if (!dst_cgrp)
                return -ENODEV;
  
-       task = cgroup_procs_write_start(buf, true, &locked);
+       task = cgroup_procs_write_start(buf, threadgroup, &locked);
        ret = PTR_ERR_OR_ZERO(task);
        if (ret)
                goto out_unlock;
        src_cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
        spin_unlock_irq(&css_set_lock);
  
+       /* process and thread migrations follow same delegation rule */
        ret = cgroup_attach_permissions(src_cgrp, dst_cgrp,
-                                       of->file->f_path.dentry->d_sb, true);
+                                       of->file->f_path.dentry->d_sb, threadgroup);
        if (ret)
                goto out_finish;
  
-       ret = cgroup_attach_task(dst_cgrp, task, true);
+       ret = cgroup_attach_task(dst_cgrp, task, threadgroup);
  
  out_finish:
        cgroup_procs_write_finish(task, locked);
  out_unlock:
        cgroup_kn_unlock(of->kn);
  
-       return ret ?: nbytes;
+       return ret;
+ }
+ static ssize_t cgroup_procs_write(struct kernfs_open_file *of,
+                                 char *buf, size_t nbytes, loff_t off)
+ {
+       return __cgroup_procs_write(of, buf, true) ?: nbytes;
  }
  
  static void *cgroup_threads_start(struct seq_file *s, loff_t *pos)
  static ssize_t cgroup_threads_write(struct kernfs_open_file *of,
                                    char *buf, size_t nbytes, loff_t off)
  {
-       struct cgroup *src_cgrp, *dst_cgrp;
-       struct task_struct *task;
-       ssize_t ret;
-       bool locked;
-       buf = strstrip(buf);
-       dst_cgrp = cgroup_kn_lock_live(of->kn, false);
-       if (!dst_cgrp)
-               return -ENODEV;
-       task = cgroup_procs_write_start(buf, false, &locked);
-       ret = PTR_ERR_OR_ZERO(task);
-       if (ret)
-               goto out_unlock;
-       /* find the source cgroup */
-       spin_lock_irq(&css_set_lock);
-       src_cgrp = task_cgroup_from_root(task, &cgrp_dfl_root);
-       spin_unlock_irq(&css_set_lock);
-       /* thread migrations follow the cgroup.procs delegation rule */
-       ret = cgroup_attach_permissions(src_cgrp, dst_cgrp,
-                                       of->file->f_path.dentry->d_sb, false);
-       if (ret)
-               goto out_finish;
-       ret = cgroup_attach_task(dst_cgrp, task, false);
- out_finish:
-       cgroup_procs_write_finish(task, locked);
- out_unlock:
-       cgroup_kn_unlock(of->kn);
-       return ret ?: nbytes;
+       return __cgroup_procs_write(of, buf, false) ?: nbytes;
  }
  
  /* cgroup core interface files for the default hierarchy */