Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1726621
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem |
| Date | 2017-09-05 13:10 +0200 |
| Message-ID | <umjTY-1V1-19@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <ukc0y-Vu-17@gated-at.bofh.it> <ukdpD-1Ib-7@gated-at.bofh.it> <um0eC-6ug-7@gated-at.bofh.it> <umhfs-el-13@gated-at.bofh.it> <umjhf-1rC-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, 5 Sep 2017, Michal Hocko wrote:
> On Tue 05-09-17 10:19:13, Thomas Gleixner wrote:
> > On Mon, 4 Sep 2017, Michal Hocko wrote:
> >
> > > Thomas, Johannes,
> > > could you double check my thinking here? I will repost the patch to
> > > Andrew if you are OK with this.
> > > > + /*
> > > > + * The only protection from memory hotplug vs. drain_stock races is
> > > > + * that we always operate on local CPU stock here with IRQ disabled
> > > > + */
> > > > local_irq_save(flags);
> > > >
> > > > stock = this_cpu_ptr(&memcg_stock);
> > > > @@ -1807,26 +1811,27 @@ static void drain_all_stock(struct mem_cgroup *root_memcg)
> > > > if (!mutex_trylock(&percpu_charge_mutex))
> > > > return;
> > > > /* Notify other cpus that system-wide "drain" is running */
> > > > - get_online_cpus();
> > > > curcpu = get_cpu();
> >
> > The problem here is that this does only protect you against a CPU being
> > unplugged, but not against a CPU coming online concurrently.
>
> Yes but same as the drain_all_pages we do not have any cpu up specific
> intialization so there is no specific action to race against AFAICS.
>
> > I have no idea
> > whether that might be a problem, but at least you should put a comment in
> > which explains why it is not.
>
> What about this?
Looks good.
> ---
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 5c70f47abb3d..ff9b0979ccc3 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1810,7 +1810,12 @@ static void drain_all_stock(struct mem_cgroup *root_memcg)
> /* If someone's already draining, avoid adding running more workers. */
> if (!mutex_trylock(&percpu_charge_mutex))
> return;
> - /* Notify other cpus that system-wide "drain" is running */
> + /*
> + * Notify other cpus that system-wide "drain" is running
> + * We do not care about races with the cpu hotplug because cpu down
> + * as well as workers from this path always operate on the local
> + * per-cpu data. CPU up doesn't touch memcg_stock at all.
> + */
> curcpu = get_cpu();
> for_each_online_cpu(cpu) {
> struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
>
> --
> Michal Hocko
> SUSE Labs
>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Michal Hocko <mhocko@kernel.org> - 2017-08-30 16:20 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Michal Hocko <mhocko@kernel.org> - 2017-08-30 17:50 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Artem Savkov <asavkov@redhat.com> - 2017-08-31 13:20 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Michal Hocko <mhocko@kernel.org> - 2017-08-31 14:20 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Artem Savkov <asavkov@redhat.com> - 2017-08-31 14:20 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Michal Hocko <mhocko@kernel.org> - 2017-09-04 16:10 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Thomas Gleixner <tglx@linutronix.de> - 2017-09-05 10:20 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Michal Hocko <mhocko@kernel.org> - 2017-09-05 12:30 +0200
Re: possible circular locking dependency mmap_sem/cpu_hotplug_lock.rw_sem Thomas Gleixner <tglx@linutronix.de> - 2017-09-05 13:10 +0200
csiph-web