mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ed Cashin <ecashin@coraid.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/14] aoe: kernel thread handles I/O completions for simple locking
Date: Fri, 31 Aug 2012 13:06:32 -0700	[thread overview]
Message-ID: <20120831130632.f7b12060.akpm@linux-foundation.org> (raw)
In-Reply-To: <bd1dae439834419bfa6056e75361d23e0404ac82.1346158422.git.ecashin@coraid.com>

On Sat, 25 Aug 2012 10:39:46 -0400
Ed Cashin <ecashin@coraid.com> wrote:

> +static int
> +kthread(void *vp)
> +{
> +	struct ktstate *k;
> +	DECLARE_WAITQUEUE(wait, current);
> +	int more;
> +
> +	k = vp;
> +	current->flags |= PF_NOFREEZE;
> +	set_user_nice(current, -10);
> +	complete(&k->rendez);	/* tell spawner we're running */
> +	do {
> +		spin_lock_irq(k->lock);
> +		more = k->fn();
> +		if (!more) {
> +			add_wait_queue(k->waitq, &wait);
> +			__set_current_state(TASK_INTERRUPTIBLE);
> +		}
> +		spin_unlock_irq(k->lock);
> +		if (!more) {
> +			schedule();
> +			remove_wait_queue(k->waitq, &wait);
> +		} else
> +			cond_resched();
> +	} while (!kthread_should_stop());
> +	complete(&k->rendez);	/* tell spawner we're stopping */
> +	return 0;
> +}
> +
> +static void
> +aoe_ktstop(struct ktstate *k)
> +{
> +	kthread_stop(k->task);
> +	wait_for_completion(&k->rendez);
> +}
> +
> +static int
> +aoe_ktstart(struct ktstate *k)
> +{
> +	struct task_struct *task;
> +
> +	init_completion(&k->rendez);
> +	task = kthread_run(kthread, k, k->name);
> +	if (task == NULL || IS_ERR(task))
> +		return -ENOMEM;
> +	k->task = task;
> +	wait_for_completion(&k->rendez); /* allow kthread to start */
> +	init_completion(&k->rendez);	/* for waiting for exit later */
> +	return 0;
> +}

It's a pretty unlikely thing, but I wonder if there's a way in which
aoe_ktstart() can run that second init_completion() _after_ kthread()
has run its second complete().  ie: someone runs aoe_ktstop()
super-early.  If that can happen, the later wait_for_completion() hangs
up.




  reply	other threads:[~2012-08-31 20:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-28 12:53 [PATCH 00/14] aoe driver v49 performance and usability improvements Ed Cashin
2012-08-25 14:39 ` [PATCH 01/14] aoe: for performance support larger packet payloads Ed Cashin
2012-08-25 14:39 ` [PATCH 02/14] aoe: kernel thread handles I/O completions for simple locking Ed Cashin
2012-08-31 20:06   ` Andrew Morton [this message]
2012-08-25 14:39 ` [PATCH 03/14] aoe: become I/O request queue handler for increased user control Ed Cashin
2012-08-25 14:39 ` [PATCH 04/14] aoe: use a kernel thread for transmissions Ed Cashin
2012-08-25 14:39 ` [PATCH 05/14] aoe: use packets that work with the smallest-MTU local interface Ed Cashin
2012-08-25 14:39 ` [PATCH 07/14] aoe: do revalidation steps in order Ed Cashin
2012-08-25 14:39 ` [PATCH 06/14] aoe: failover remote interface based on aoe_deadsecs parameter Ed Cashin
2012-08-25 14:39 ` [PATCH 08/14] aoe: disallow unsupported AoE minor addresses Ed Cashin
2012-08-25 14:39 ` [PATCH 09/14] aoe: associate frames with the AoE storage target Ed Cashin
2012-08-25 14:39 ` [PATCH 10/14] aoe: increase net_device reference count while using it Ed Cashin
2012-08-25 14:39 ` [PATCH 11/14] aoe: remove unused code and add cosmetic improvements Ed Cashin
2012-08-25 14:39 ` [PATCH 12/14] aoe: update internal version number to 49 Ed Cashin
2012-08-25 14:39 ` [PATCH 13/14] aoe: update copyright year in touched files Ed Cashin
2012-08-25 14:39 ` [PATCH 14/14] aoe: update documentation with new URL and VM settings reference Ed Cashin
  -- strict thread matches above, loose matches on Subject: below --
2012-08-23 17:43 [PATCH 00/14] aoe driver v49 performance and usability improvements Ed Cashin
2012-08-18  1:24 ` [PATCH 02/14] aoe: kernel thread handles I/O completions for simple locking Ed Cashin
2012-08-24 21:22   ` Andrew Morton
2012-08-25  0:35     ` Ed Cashin
2012-08-26  1:31     ` ecashin

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=20120831130632.f7b12060.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ecashin@coraid.com \
    --cc=linux-kernel@vger.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

Powered by JetHome