Re: [RFC PATCH 0/6] Convert all tasklets to workqueues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(the email address of Matthew Wilcox looks wrong, changed to [email protected])

On 06/29, Oleg Nesterov wrote:
>
> Steven, unless you have some objections, could you change tasklet_kill() ?
> 
> > +static inline void tasklet_kill(struct tasklet_struct *t)
> >  {
> > -       return test_bit(TASKLET_STATE_SCHED, &t->state);
> > +       flush_workqueue(ktaskletd_wq);
> >  }
> 
> Just change flush_workqueue(ktaskletd_wq) to cancel_work_sync(t-work).

Ugh, tasklet_disable() should be changed as well.

> @@ -84,35 +50,35 @@ static inline void tasklet_disable_nosyn
>  static inline void tasklet_disable(struct tasklet_struct *t)
>  {
>         tasklet_disable_nosync(t);
> -       tasklet_unlock_wait(t);
> -       smp_mb();
> -}
> -
> -static inline void tasklet_enable(struct tasklet_struct *t)
> -{
> -       smp_mb__before_atomic_dec();
> -       atomic_dec(&t->count);
> +       flush_workqueue(ktaskletd_wq);
> +       /* flush_workqueue should provide us a barrier */
>  }

Suppose we have the tasklets T1 and T2, both are scheduled on the
same CPU. T1 takes some spinlock LOCK.

Currently it is possible to do

	spin_lock(LOCK);
	disable_tasklet(T2);

With this patch, the above code hangs.


The most simple fix is to use wait_on_work(t->work) instead of
flush_workqueue(). Currently it is static, but we can export it.
This change will speedup tasklet_disable), btw.

A better fix imho is to use cancel_work_sync() again, but this
needs some complications to preserve TASKLET_STATE_PENDING.

This in turn means that cancel_work_sync() should return "int", but
not "void". This change makes sense regardless, I'll try to make a
patch on Sunday.

Oleg.

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux