Re: [PATCH v5 08/20] kthread: Allow to cancel kthread work

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

 



On Wed, Feb 24, 2016 at 05:18:05PM +0100, Petr Mladek wrote:
> @@ -770,7 +782,22 @@ void delayed_kthread_work_timer_fn(unsigned long __data)
>  	if (WARN_ON_ONCE(!worker))
>  		return;
>  
> -	spin_lock(&worker->lock);
> +	/*
> +	 * We might be unable to take the lock if someone is trying to
> +	 * cancel this work and calls del_timer_sync() when this callback
> +	 * has already been removed from the timer list.
> +	 */
> +	while (!spin_trylock(&worker->lock)) {
> +		/*
> +		 * Busy wait with spin_is_locked() to avoid cache bouncing.
> +		 * Break when canceling is set to avoid a deadlock.
> +		 */
> +		do {
> +			if (work->canceling)
> +				return;
> +			cpu_relax();
> +		} while (spin_is_locked(&worker->lock));
> +	}
>  	/* Work must not be used with more workers, see queue_kthread_work(). */
>  	WARN_ON_ONCE(work->worker != worker);
>  

This is pretty vile; why can't you drop the lock over del_timer_sync() ?
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux