linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Cc: tj@kernel.org, alan@lxorguk.ukuu.org.uk, jeff@garzik.org,
	dhowells@redhat.com
Subject: Re: [PATCH 2/3] slow-work: add support for cancellation of slow work
Date: Thu, 27 Aug 2009 11:14:10 +0200	[thread overview]
Message-ID: <20090827091409.GF12579@kernel.dk> (raw)
In-Reply-To: <1251364122-9592-3-git-send-email-jens.axboe@oracle.com>

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

  parent reply	other threads:[~2009-08-27  9:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-27  9:08 [PATCH 0/3] Convert libata pio task to slow-work Jens Axboe
2009-08-27  9:08 ` [PATCH 1/3] slow-work: add delayed_slow_work support Jens Axboe
2009-08-27  9:08   ` [PATCH 2/3] slow-work: add support for cancellation of slow work Jens Axboe
2009-08-27  9:08     ` [PATCH 3/3] libata: switch pio task from workqueue to slow-work Jens Axboe
2009-08-27  9:14     ` Jens Axboe [this message]
2009-08-27  9:18       ` [PATCH 2/3] slow-work: add support for cancellation of slow work (updated) Jens Axboe
2009-08-27 12:36 ` [PATCH 0/3] Convert libata pio task to slow-work Tejun Heo
2009-08-27 12:49   ` Jens Axboe
2009-08-27 12:58     ` Tejun Heo
2009-08-27 18:49       ` Jens Axboe
2009-08-28  7:02         ` Tejun Heo
2009-08-28  7:06           ` Jens Axboe
2009-08-31  3:24             ` [very-early-draft-unsplit PATCH] workqueue: implement global cpu workqueue Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090827091409.GF12579@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dhowells@redhat.com \
    --cc=jeff@garzik.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).