mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: mroos@linux.ee
Cc: Len Brown <len.brown@intel.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	James Bottomley <JBottomley@parallels.com>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH 2/4] async: make async_synchronize_full() flush all work regardless of domain
Date: Fri, 25 May 2012 00:50:32 -0700	[thread overview]
Message-ID: <20120525075032.21933.17544.stgit@dwillia2-linux.jf.intel.com> (raw)
In-Reply-To: <20120525074813.21933.91876.stgit@dwillia2-linux.jf.intel.com>

In response to an async related regression James noted:

  "My theory is that this is an init problem: The assumption in a lot of
   our code is that async_synchronize_full() waits for everything ... even
   the domain specific async schedules, which isn't true."

...so make this assumption true.

Each domain, including the default one, registers itself on a global domain
list when work is scheduled.  Once all entries complete it exits that
list.  Waiting for the list to be empty syncs all in-flight work across
all domains.

Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: James Bottomley <JBottomley@parallels.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 kernel/async.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/async.c b/kernel/async.c
index aa23eec..f7d70b1 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -63,6 +63,7 @@ static async_cookie_t next_cookie = 1;
 
 static LIST_HEAD(async_pending);
 static ASYNC_DOMAIN(async_running);
+static LIST_HEAD(async_domains);
 static DEFINE_SPINLOCK(async_lock);
 
 struct async_entry {
@@ -145,6 +146,8 @@ static void async_run_entry_fn(struct work_struct *work)
 	/* 3) remove self from the running queue */
 	spin_lock_irqsave(&async_lock, flags);
 	list_del(&entry->list);
+	if (--running->count == 0)
+		list_del_init(&running->node);
 
 	/* 4) free the entry */
 	kfree(entry);
@@ -187,6 +190,8 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct a
 	spin_lock_irqsave(&async_lock, flags);
 	newcookie = entry->cookie = next_cookie++;
 	list_add_tail(&entry->list, &async_pending);
+	if (running->count++ == 0)
+		list_add_tail(&running->node, &async_domains);
 	atomic_inc(&entry_count);
 	spin_unlock_irqrestore(&async_lock, flags);
 
@@ -238,7 +243,7 @@ void async_synchronize_full(void)
 {
 	do {
 		async_synchronize_cookie(next_cookie);
-	} while (!list_empty(&async_running.domain) || !list_empty(&async_pending));
+	} while (!list_empty(&async_domains));
 }
 EXPORT_SYMBOL_GPL(async_synchronize_full);
 


  parent reply	other threads:[~2012-05-25  7:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25  7:50 [RFT PATCH 0/4] fix / cleanup async scsi scanning Dan Williams
2012-05-25  7:50 ` [PATCH 1/4] async: introduce 'async_domain' type Dan Williams
2012-05-25  7:51   ` James Bottomley
2012-05-25  8:18     ` Dan Williams
2012-05-25  8:48       ` James Bottomley
2012-05-25 19:23         ` Rafael J. Wysocki
2012-05-25 13:31     ` Arjan van de Ven
2012-05-25 13:40     ` mroos
2012-05-25 15:05       ` Dan Williams
2012-05-27 22:34   ` Mark Brown
2012-05-25  7:50 ` Dan Williams [this message]
2012-05-25  7:50 ` [PATCH 3/4] scsi: queue async scan work to an async_schedule domain Dan Williams
2012-05-25  7:50 ` [PATCH 4/4] scsi: cleanup usages of scsi_complete_async_scans Dan Williams

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=20120525075032.21933.17544.stgit@dwillia2-linux.jf.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=JBottomley@parallels.com \
    --cc=arjan@linux.intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mroos@linux.ee \
    --cc=rjw@sisk.pl \
    /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

all inboxes | Powered by JetHome®