public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Neeraj Upadhyay <neeraju@codeaurora.org>
Cc: lizefan@huawei.com, mingo@kernel.org, longman@redhat.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	sramana@codeaurora.org, prsood@codeaurora.org
Subject: Re: [PATCH] cgroup: Fix potential race between cgroup_exit and migrate path
Date: Wed, 30 Aug 2017 18:03:19 -0700	[thread overview]
Message-ID: <20170831010319.GB491396@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <20170831005545.GA491396@devbig577.frc2.facebook.com>

On Wed, Aug 30, 2017 at 05:55:45PM -0700, Tejun Heo wrote:
> Would something like the following fix the issue?  Thanks.
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index df2e0f1..cd85ca0 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -683,7 +683,7 @@ static void css_set_move_task(struct task_struct *task,
>  			if (it->task_pos == &task->cg_list)
>  				css_task_iter_advance(it);
>  
> -		list_del_init(&task->cg_list);
> +		list_del(&task->cg_list);
>  		if (!css_set_populated(from_cset))
>  			css_set_update_populated(from_cset, false);
>  	} else {

Oops, more like the following.

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index df2e0f1..6f34025 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -683,7 +683,7 @@ static void css_set_move_task(struct task_struct *task,
 			if (it->task_pos == &task->cg_list)
 				css_task_iter_advance(it);
 
-		list_del_init(&task->cg_list);
+		list_del(&task->cg_list);
 		if (!css_set_populated(from_cset))
 			css_set_update_populated(from_cset, false);
 	} else {
@@ -702,6 +702,8 @@ static void css_set_move_task(struct task_struct *task,
 		rcu_assign_pointer(task->cgroups, to_cset);
 		list_add_tail(&task->cg_list, use_mg_tasks ? &to_cset->mg_tasks :
 							     &to_cset->tasks);
+	} else {
+		INIT_LIST_HEAD(&task->cg_list);
 	}
 }
 

  reply	other threads:[~2017-08-31  1:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 12:54 [PATCH] cgroup: Fix potential race between cgroup_exit and migrate path Neeraj Upadhyay
2017-08-31  0:55 ` Tejun Heo
2017-08-31  1:03   ` Tejun Heo [this message]
2017-08-31  1:12     ` Tejun Heo
2017-09-04 13:23       ` Neeraj Upadhyay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170831010319.GB491396@devbig577.frc2.facebook.com \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=longman@redhat.com \
    --cc=mingo@kernel.org \
    --cc=neeraju@codeaurora.org \
    --cc=prsood@codeaurora.org \
    --cc=sramana@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox