OSDN Git Service

Merge branch 'for-5.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Feb 2020 01:07:05 +0000 (17:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 11 Feb 2020 01:07:05 +0000 (17:07 -0800)
Pull cgroup fix from Tejun Heo:
 "I made a mistake while removing cgroup task list lazy init
  optimization making the root cgroup.procs show entries for the
  init_tasks. The zero entries doesn't cause critical failures but does
  make systemd print out warning messages during boot.

  Fix it by omitting init_tasks as they should be"

* 'for-5.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup: init_tasks shouldn't be linked to the root cgroup

1  2 
kernel/cgroup/cgroup.c

diff --combined kernel/cgroup/cgroup.c
@@@ -1816,19 -1816,24 +1816,19 @@@ enum cgroup2_param 
        nr__cgroup2_params
  };
  
 -static const struct fs_parameter_spec cgroup2_param_specs[] = {
 +static const struct fs_parameter_spec cgroup2_fs_parameters[] = {
        fsparam_flag("nsdelegate",              Opt_nsdelegate),
        fsparam_flag("memory_localevents",      Opt_memory_localevents),
        {}
  };
  
 -static const struct fs_parameter_description cgroup2_fs_parameters = {
 -      .name           = "cgroup2",
 -      .specs          = cgroup2_param_specs,
 -};
 -
  static int cgroup2_parse_param(struct fs_context *fc, struct fs_parameter *param)
  {
        struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
        struct fs_parse_result result;
        int opt;
  
 -      opt = fs_parse(fc, &cgroup2_fs_parameters, param, &result);
 +      opt = fs_parse(fc, cgroup2_fs_parameters, param, &result);
        if (opt < 0)
                return opt;
  
@@@ -2151,7 -2156,7 +2151,7 @@@ static void cgroup_kill_sb(struct super
  struct file_system_type cgroup_fs_type = {
        .name                   = "cgroup",
        .init_fs_context        = cgroup_init_fs_context,
 -      .parameters             = &cgroup1_fs_parameters,
 +      .parameters             = cgroup1_fs_parameters,
        .kill_sb                = cgroup_kill_sb,
        .fs_flags               = FS_USERNS_MOUNT,
  };
  static struct file_system_type cgroup2_fs_type = {
        .name                   = "cgroup2",
        .init_fs_context        = cgroup_init_fs_context,
 -      .parameters             = &cgroup2_fs_parameters,
 +      .parameters             = cgroup2_fs_parameters,
        .kill_sb                = cgroup_kill_sb,
        .fs_flags               = FS_USERNS_MOUNT,
  };
@@@ -5927,11 -5932,14 +5927,14 @@@ void cgroup_post_fork(struct task_struc
  
        spin_lock_irq(&css_set_lock);
  
-       WARN_ON_ONCE(!list_empty(&child->cg_list));
-       cset = task_css_set(current); /* current is @child's parent */
-       get_css_set(cset);
-       cset->nr_tasks++;
-       css_set_move_task(child, NULL, cset, false);
+       /* init tasks are special, only link regular threads */
+       if (likely(child->pid)) {
+               WARN_ON_ONCE(!list_empty(&child->cg_list));
+               cset = task_css_set(current); /* current is @child's parent */
+               get_css_set(cset);
+               cset->nr_tasks++;
+               css_set_move_task(child, NULL, cset, false);
+       }
  
        /*
         * If the cgroup has to be frozen, the new task has too.  Let's set