[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090827091409.GF12579@kernel.dk>
Date: Thu, 27 Aug 2009 11:14:10 +0200
From: Jens Axboe <jens.axboe@...cle.com>
To: linux-kernel@...r.kernel.org, linux-ide@...r.kernel.org
Cc: tj@...nel.org, alan@...rguk.ukuu.org.uk, jeff@...zik.org,
dhowells@...hat.com
Subject: Re: [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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists