* [PATCH 1/3] stop_machine: check work->done while handling enqueued works
@ 2013-02-06 12:36 Hillf Danton
2013-02-06 18:46 ` Tejun Heo
0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2013-02-06 12:36 UTC (permalink / raw)
To: Rusty Russell, Tejun Heo; +Cc: Andrew Morton, Ingo Molnar, LKML
To advoid invalid reference, updating work result is moved to
cpu_stop_signal_done().
Signed-off-by: Hillf Danton <dhillf@gmail.com>
---
--- a/kernel/stop_machine.c Wed Feb 6 19:50:56 2013
+++ b/kernel/stop_machine.c Wed Feb 6 19:54:34 2013
@@ -51,9 +51,11 @@ static void cpu_stop_init_done(struct cp
}
/* signal completion unless @done is NULL */
-static void cpu_stop_signal_done(struct cpu_stop_done *done, bool executed)
+static void cpu_stop_signal_done(struct cpu_stop_done *done, bool
executed, int ret)
{
if (done) {
+ if (ret)
+ done->ret = ret;
if (executed)
done->executed = true;
if (atomic_dec_and_test(&done->nr_todo))
@@ -73,7 +75,7 @@ static void cpu_stop_queue_work(struct c
list_add_tail(&work->list, &stopper->works);
wake_up_process(stopper->thread);
} else
- cpu_stop_signal_done(work->done, false);
+ cpu_stop_signal_done(work->done, false, 0);
spin_unlock_irqrestore(&stopper->lock, flags);
}
@@ -279,8 +281,6 @@ repeat:
preempt_disable();
ret = fn(arg);
- if (ret)
- done->ret = ret;
/* restore preemption and check it's still balanced */
preempt_enable();
@@ -289,7 +289,7 @@ repeat:
kallsyms_lookup((unsigned long)fn, NULL, NULL, NULL,
ksym_buf), arg);
- cpu_stop_signal_done(done, true);
+ cpu_stop_signal_done(done, true, ret);
} else
schedule();
@@ -343,7 +343,7 @@ static int __cpuinit cpu_stop_cpu_callba
/* drain remaining works */
spin_lock_irq(&stopper->lock);
list_for_each_entry(work, &stopper->works, list)
- cpu_stop_signal_done(work->done, false);
+ cpu_stop_signal_done(work->done, false, 0);
stopper->enabled = false;
spin_unlock_irq(&stopper->lock);
/* release the stopper */
--
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/3] stop_machine: check work->done while handling enqueued works
2013-02-06 12:36 [PATCH 1/3] stop_machine: check work->done while handling enqueued works Hillf Danton
@ 2013-02-06 18:46 ` Tejun Heo
2013-02-07 12:13 ` Hillf Danton
0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2013-02-06 18:46 UTC (permalink / raw)
To: Hillf Danton; +Cc: Rusty Russell, Andrew Morton, Ingo Molnar, LKML
On Wed, Feb 06, 2013 at 08:36:01PM +0800, Hillf Danton wrote:
> To advoid invalid reference, updating work result is moved to
> cpu_stop_signal_done().
Can you please elaborate "why" in addition to "what"? Do we actually
have a bug here, is it meant to be an independent cleanup, or is it
something which is necessary for later patches in the series? What
are we achieving here?
> /* signal completion unless @done is NULL */
> -static void cpu_stop_signal_done(struct cpu_stop_done *done, bool executed)
> +static void cpu_stop_signal_done(struct cpu_stop_done *done, bool
> executed, int ret)
Patch is corrupt.
> @@ -279,8 +281,6 @@ repeat:
> preempt_disable();
>
> ret = fn(arg);
> - if (ret)
> - done->ret = ret;
If this is meant as a pure cleanup, I'm not sure it's an improvement.
You own your cpu_stop_done until you call cpu_stop_signal_done() on
it, so I don't think there's anything wrong with the current code.
The new code is different, not necessarily better.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] stop_machine: check work->done while handling enqueued works
2013-02-06 18:46 ` Tejun Heo
@ 2013-02-07 12:13 ` Hillf Danton
2013-02-07 16:37 ` Tejun Heo
0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2013-02-07 12:13 UTC (permalink / raw)
To: Tejun Heo; +Cc: Rusty Russell, Andrew Morton, Ingo Molnar, LKML
Hello Tejun
On Thu, Feb 7, 2013 at 2:46 AM, Tejun Heo <tj@kernel.org> wrote:
>> @@ -279,8 +281,6 @@ repeat:
>> preempt_disable();
>>
>> ret = fn(arg);
>> - if (ret)
>> - done->ret = ret;
>
> If this is meant as a pure cleanup, I'm not sure it's an improvement.
> You own your cpu_stop_done until you call cpu_stop_signal_done() on
> it, so I don't think there's anything wrong with the current code.
> The new code is different, not necessarily better.
The comment just above cpu_stop_signal_done()
says it is not certain that the input done is valid, so
I did this work.
Plus works enqueued through stop_one_cpu_nowait()
do carry no done.
Hillf
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] stop_machine: check work->done while handling enqueued works
2013-02-07 12:13 ` Hillf Danton
@ 2013-02-07 16:37 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2013-02-07 16:37 UTC (permalink / raw)
To: Hillf Danton; +Cc: Rusty Russell, Andrew Morton, Ingo Molnar, LKML
Hello, Hillf.
On Thu, Feb 07, 2013 at 08:13:44PM +0800, Hillf Danton wrote:
> > If this is meant as a pure cleanup, I'm not sure it's an improvement.
> > You own your cpu_stop_done until you call cpu_stop_signal_done() on
> > it, so I don't think there's anything wrong with the current code.
> > The new code is different, not necessarily better.
>
> The comment just above cpu_stop_signal_done()
> says it is not certain that the input done is valid, so
> I did this work.
> Plus works enqueued through stop_one_cpu_nowait()
> do carry no done.
So, are you saying that we can hit NULL deref in cpu_stopper_thread()
and this is a bug fix? If so, can you please redo the description? I
really can't tell what the patch is trying to do from the original
description.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-07 16:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06 12:36 [PATCH 1/3] stop_machine: check work->done while handling enqueued works Hillf Danton
2013-02-06 18:46 ` Tejun Heo
2013-02-07 12:13 ` Hillf Danton
2013-02-07 16:37 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®