lkml.org 
[lkml]   [2009]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] slow-work: add support for cancellation of slow work
On Thu, Aug 27 2009, Jens Axboe wrote:
> @@ -194,12 +194,21 @@ static bool slow_work_execute(void)
> if (!test_and_clear_bit(SLOW_WORK_PENDING, &work->flags))
> BUG();
>
> - work->ops->execute(work);
> + /*
> + * Don't execute if the work was cancelled after being added
> + */
> + if (!test_bit(SLOW_WORK_CANCEL, &work->flags))
> + work->ops->execute(work);
>
> if (very_slow)
> atomic_dec(&vslow_work_executing_count);
> clear_bit_unlock(SLOW_WORK_EXECUTING, &work->flags);
>
> + /*
> + * Wake anyone waiting for this work to be done
> + */
> + wake_up_bit(&work->flags, SLOW_WORK_EXECUTING);
> +
> /* if someone tried to enqueue the item whilst we were executing it,
> * then it'll be left unenqueued to avoid multiple threads trying to
> * execute it simultaneously

> +void cancel_slow_work(struct slow_work *work)
> +{
> + set_bit(SLOW_WORK_CANCEL, &work->flags);
> + wait_on_bit(&work->flags, SLOW_WORK_EXECUTING, slow_work_wait,
> + TASK_UNINTERRUPTIBLE);
> + clear_bit(SLOW_WORK_CANCEL, &work->flags);
> +}
> +EXPORT_SYMBOL(cancel_slow_work);

We want to use SLOW_WORK_PENDING for this logic, not SLOW_WORK_EXECUTING.
I'll update it.

--
Jens Axboe



\
 
 \ /
  Last update: 2009-08-27 11:17    [from the cache]
©2003-2011 Jasper Spaans