All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Prateek Sood <prsood-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	sramana-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	apkm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Subject: Re: [PATCH] Workqueue lockup: Circular dependency in threads
Date: Tue, 5 Sep 2017 06:22:43 -0700	[thread overview]
Message-ID: <20170905132242.GA1774378@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <bc1016ee-792e-87f8-5158-777b7f9405b8-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

Hello,

On Thu, Aug 31, 2017 at 06:43:56PM +0530, Prateek Sood wrote:
> > 6) cpuset_mutex is acquired by task init:1 and is waiting for cpuhotplug lock.

Yeah, this is the problematic one.

> > We can reorder the sequence of locks as in the below diff to avoid this
> > deadlock. But I am looking for inputs/better solution to fix this deadlock.
> > 
> > ---
> > diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> >  /**
> >   * update_tasks_cpumask - Update the cpumasks of tasks in the cpuset.
> >   * @cs: the cpuset in which each task's cpus_allowed mask needs to be changed
> > @@ -930,7 +946,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
> >  	rcu_read_unlock();
> >  
> >  	if (need_rebuild_sched_domains)
> > -		rebuild_sched_domains_locked();
> > +		rebuild_sched_domains_unlocked()(without taking cpuhotplug.lock)
> >  }
> >  
> >  /**
> > @@ -1719,6 +1735,7 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
> > +	get_online_cpus();
> >  	mutex_lock(&cpuset_mutex);
> >  	if (!is_cpuset_online(cs))
> >  		goto out_unlock;
> > @@ -1744,6 +1761,7 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
> >  	mutex_unlock(&cpuset_mutex);
> > +	put_online_cpus();
> >  	kernfs_unbreak_active_protection(of->kn);
> >  	css_put(&cs->css);
> >  	flush_workqueue(cpuset_migrate_mm_wq);
> > 

And the patch looks good to me.  Can you please format the patch with
proper description and sob?

Thanks.

-- 
tejun

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Prateek Sood <prsood@codeaurora.org>
Cc: lizefan@huawei.com, cgroups@vger.kernel.org,
	linux-kernel@vger.kernel.org, sramana@codeaurora.org,
	mingo@kernel.org, longman@redhat.com, apkm@linux-foundation.org
Subject: Re: [PATCH] Workqueue lockup: Circular dependency in threads
Date: Tue, 5 Sep 2017 06:22:43 -0700	[thread overview]
Message-ID: <20170905132242.GA1774378@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <bc1016ee-792e-87f8-5158-777b7f9405b8@codeaurora.org>

Hello,

On Thu, Aug 31, 2017 at 06:43:56PM +0530, Prateek Sood wrote:
> > 6) cpuset_mutex is acquired by task init:1 and is waiting for cpuhotplug lock.

Yeah, this is the problematic one.

> > We can reorder the sequence of locks as in the below diff to avoid this
> > deadlock. But I am looking for inputs/better solution to fix this deadlock.
> > 
> > ---
> > diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> >  /**
> >   * update_tasks_cpumask - Update the cpumasks of tasks in the cpuset.
> >   * @cs: the cpuset in which each task's cpus_allowed mask needs to be changed
> > @@ -930,7 +946,7 @@ static void update_cpumasks_hier(struct cpuset *cs, struct cpumask *new_cpus)
> >  	rcu_read_unlock();
> >  
> >  	if (need_rebuild_sched_domains)
> > -		rebuild_sched_domains_locked();
> > +		rebuild_sched_domains_unlocked()(without taking cpuhotplug.lock)
> >  }
> >  
> >  /**
> > @@ -1719,6 +1735,7 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
> > +	get_online_cpus();
> >  	mutex_lock(&cpuset_mutex);
> >  	if (!is_cpuset_online(cs))
> >  		goto out_unlock;
> > @@ -1744,6 +1761,7 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
> >  	mutex_unlock(&cpuset_mutex);
> > +	put_online_cpus();
> >  	kernfs_unbreak_active_protection(of->kn);
> >  	css_put(&cs->css);
> >  	flush_workqueue(cpuset_migrate_mm_wq);
> > 

And the patch looks good to me.  Can you please format the patch with
proper description and sob?

Thanks.

-- 
tejun

  parent reply	other threads:[~2017-09-05 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 13:58 [PATCH] Workqueue lockup: Circular dependency in threads Prateek Sood
2017-08-30 13:58 ` Prateek Sood
2017-08-31 13:13 ` Prateek Sood
     [not found]   ` <bc1016ee-792e-87f8-5158-777b7f9405b8-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-09-05 13:22     ` Tejun Heo [this message]
2017-09-05 13:22       ` Tejun Heo
2017-09-06 11:17       ` Prateek Sood

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=20170905132242.GA1774378@devbig577.frc2.facebook.com \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=apkm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    --cc=longman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=prsood-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=sramana-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.