Re: more efficient current_is_keventd macro? [was Re: [lhcs-devel]Re: Kthread_create() never returns when called from worker_thread]

From: Rusty Russell
Date: Mon Mar 08 2004 - 20:53:23 EST


On Tue, 2004-03-09 at 09:36, Andrew Morton wrote:
> Srivatsa Vaddagiri <vatsa@xxxxxxxxxx> wrote:
> > int current_is_keventd(void)
> > {
> > + int cpu = smp_processor_id();
> > + cwq = keventd_wq->cpu_wq + cpu;
> > + if (current == cwq->thread)
> > + return 1;
> > + else
> > + return 0;
> > }
>
> Is racy in the presence of preemption.

Actually, it's not, because if current *is* keventd we're nailed to the
CPU, and if it's not, we're going to return false either way.

But it *should* be fixed, simply as an example to others.

Cheers,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

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