From: Tejun Heo <tj@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Dan Williams <djbw@fb.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] async: use ULLONG_MAX for infinity cookie value
Date: Fri, 18 Jan 2013 16:40:13 -0800 [thread overview]
Message-ID: <20130119004013.GJ24579@htj.dyndns.org> (raw)
In-Reply-To: <20130119003923.GH24579@htj.dyndns.org>
>From 25ad5d23db71cda13511f3c9c07ab0c88ece394c Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Fri, 18 Jan 2013 16:34:16 -0800
Currently, next_cookie is used as the infinity value. In most cases,
this should work fine but it theoretically could bring subtle behavior
difference between async_synchronize_full() and
async_synchronize_full_domain().
async_synchronize_full() keeps waiting until there's no registered
async_entry left regardless of what next_cookie was when the function
was called. It guarantees that the queue is completely drained at
least once before returning.
However, async_synchronize_full_domain() doesn't. It synchronizes
upto next_cookie and if further async jobs are queued after the
next_cookie value to synchronize is decided, they won't be waited for.
For unrelated async jobs, the behavior difference doesn't matter;
however, if async jobs which are related (nested or otherwise) to the
executing ones are queued while sychronization is in progress, the
resulting behavior difference could be problematic.
This can be easily fixed by using ULLONG_MAX as the infinity value
instead. Define ASYNC_COOKIE_MAX as ULLONG_MAX and use it as the
infinity value for synchronization. This makes
async_synchronize_full_domain() fully drain the domain at least once
before returning, making its behavior match async_synchronize_full().
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Dan Williams <djbw@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
kernel/async.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/async.c b/kernel/async.c
index c082fed..4cb4823 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -59,7 +59,8 @@ asynchronous and synchronous parts of the kernel.
static async_cookie_t next_cookie = 1;
-#define MAX_WORK 32768
+#define MAX_WORK 32768
+#define ASYNC_COOKIE_MAX ULLONG_MAX /* infinity cookie */
static LIST_HEAD(async_pending);
static ASYNC_DOMAIN(async_dfl_domain);
@@ -86,8 +87,8 @@ static atomic_t entry_count;
*/
static async_cookie_t __lowest_in_progress(struct async_domain *domain)
{
- async_cookie_t first_running = next_cookie; /* infinity value */
- async_cookie_t first_pending = next_cookie; /* ditto */
+ async_cookie_t first_running = ASYNC_COOKIE_MAX;
+ async_cookie_t first_pending = ASYNC_COOKIE_MAX;
struct async_entry *entry;
/*
@@ -264,7 +265,7 @@ void async_synchronize_full(void)
domain = list_first_entry(&async_domains, typeof(*domain), node);
spin_unlock_irq(&async_lock);
- async_synchronize_cookie_domain(next_cookie, domain);
+ async_synchronize_cookie_domain(ASYNC_COOKIE_MAX, domain);
} while (!list_empty(&async_domains));
mutex_unlock(&async_register_mutex);
}
@@ -300,7 +301,7 @@ EXPORT_SYMBOL_GPL(async_unregister_domain);
*/
void async_synchronize_full_domain(struct async_domain *domain)
{
- async_synchronize_cookie_domain(next_cookie, domain);
+ async_synchronize_cookie_domain(ASYNC_COOKIE_MAX, domain);
}
EXPORT_SYMBOL_GPL(async_synchronize_full_domain);
--
1.8.0.2
next prev parent reply other threads:[~2013-01-19 0:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-19 0:39 [PATCHSET] async: reimplement synchronization Tejun Heo
2013-01-19 0:39 ` [PATCH 1/4] async: bring sanity to the use of words domain and running Tejun Heo
2013-01-19 0:40 ` Tejun Heo [this message]
2013-01-19 0:40 ` [PATCH 3/4] async: keep pending tasks on async_domain and remove async_pending Tejun Heo
2013-01-19 0:41 ` [PATCH 4/4] async: replace list of active domains with global list of pending items Tejun Heo
2013-01-25 0:13 ` James Hogan
2013-01-25 1:01 ` Tejun Heo
2013-01-25 10:08 ` James Hogan
2013-01-25 10:10 ` James Hogan
2013-01-25 10:13 ` [PATCH 1/1] async: initialise list heads to fix crash James Hogan
2013-01-25 17:17 ` Tejun Heo
2013-01-23 17:33 ` [PATCHSET] async: reimplement synchronization 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=20130119004013.GJ24579@htj.dyndns.org \
--to=tj@kernel.org \
--cc=arjan@linux.intel.com \
--cc=djbw@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®