Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1197971 > unrolled thread

Re: [PATCH v2 6/6] stop_machine: kill stop_cpus_lock and lg_double_lock/unlock()

Started byOleg Nesterov <oleg@redhat.com>
First post2015-08-01 13:00 +0200
Last post2015-08-02 00:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2 6/6] stop_machine: kill stop_cpus_lock and  lg_double_lock/unlock() Oleg Nesterov <oleg@redhat.com> - 2015-08-01 13:00 +0200
    Re: [PATCH v2 6/6] stop_machine: kill stop_cpus_lock and  lg_double_lock/unlock() Peter Zijlstra <peterz@infradead.org> - 2015-08-02 00:40 +0200

#1197971 — Re: [PATCH v2 6/6] stop_machine: kill stop_cpus_lock and lg_double_lock/unlock()

FromOleg Nesterov <oleg@redhat.com>
Date2015-08-01 13:00 +0200
SubjectRe: [PATCH v2 6/6] stop_machine: kill stop_cpus_lock and lg_double_lock/unlock()
Message-ID<pSCGe-2sX-11@gated-at.bofh.it>
Hi Peter,

Thanks for looking. I'll try to reply on Monday, just one note...

On 07/30, Peter Zijlstra wrote:
>
> On Tue, Jul 21, 2015 at 09:22:47PM +0200, Oleg Nesterov wrote:
>
> > +static int cpu_stop_queue_two_works(int cpu1, struct cpu_stop_work *work1,
> > +				    int cpu2, struct cpu_stop_work *work2)
> > +{
> > +	struct cpu_stopper *stopper1 = per_cpu_ptr(&cpu_stopper, cpu1);
> > +	struct cpu_stopper *stopper2 = per_cpu_ptr(&cpu_stopper, cpu2);
> > +	int err;
> > +retry:
> > +	spin_lock_irq(&stopper1->lock);
> > +	spin_lock_nested(&stopper2->lock, SINGLE_DEPTH_NESTING);
> > +	/*
> > +	 * If we observe both CPUs active we know _cpu_down() cannot yet have
> > +	 * queued its stop_machine works and therefore ours will get executed
> > +	 * first. Or its not either one of our CPUs that's getting unplugged,
> > +	 * in which case we don't care.
> > +	 */
> > +	err = -ENOENT;
> > +	if (!cpu_active(cpu1) || !cpu_active(cpu2))
> > +		goto unlock;
> > +
> > +	WARN_ON(!stopper1->enabled || !stopper2->enabled);
> > +	/*
> > +	 * Ensure that if we race with stop_cpus() the stoppers won't
> > +	 * get queued up in reverse order, leading to system deadlock.
> > +	 */
> > +	err = -EDEADLK;
> > +	if (stop_work_pending(stopper1) != stop_work_pending(stopper2))
> > +		goto unlock;
>
> You could DoS/false positive this by running stop_one_cpu() in a loop,
> and thereby 'always' having work pending on one but not the other.

IIRC no. I am pretty sure stop_one_cpu() doesn't use stopper->stop_work,
only stop_machine() does.

Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1198357

FromPeter Zijlstra <peterz@infradead.org>
Date2015-08-02 00:40 +0200
Message-ID<pSNBD-1yt-1@gated-at.bofh.it>
In reply to#1197971
On Sat, Aug 01, 2015 at 12:57:18PM +0200, Oleg Nesterov wrote:

> > > +	if (stop_work_pending(stopper1) != stop_work_pending(stopper2))
> > > +		goto unlock;
> >
> > You could DoS/false positive this by running stop_one_cpu() in a loop,
> > and thereby 'always' having work pending on one but not the other.
> 
> IIRC no. I am pretty sure stop_one_cpu() doesn't use stopper->stop_work,
> only stop_machine() does.

Urgh, I missed you were testing the cpu_stopper::stop_work not the
cpu_stopper::works list.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web