From: "Luis R. Rodriguez" <[email protected]>

This will be reused later.

Cc: Greg Kroah-Hartman <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Arjan van de Ven <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
 kernel/async.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/kernel/async.c b/kernel/async.c
index 61f023c..362b3d6 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -145,6 +145,20 @@ static void async_run_entry_fn(struct work_struct *work)
        wake_up(&async_done);
 }
 
+/* run synchronously when low on memory or when an invalid domain was used */
+static async_cookie_t __async_schedule_sync(async_func_t func, void *data)
+{
+       unsigned long flags;
+       async_cookie_t newcookie;
+
+       spin_lock_irqsave(&async_lock, flags);
+       newcookie = next_cookie++;
+       spin_unlock_irqrestore(&async_lock, flags);
+
+       func(data, newcookie);
+       return newcookie;
+}
+
 static async_cookie_t __async_schedule(async_func_t func, void *data, struct 
async_domain *domain)
 {
        struct async_entry *entry;
@@ -160,13 +174,7 @@ static async_cookie_t __async_schedule(async_func_t func, 
void *data, struct asy
         */
        if (!entry || atomic_read(&entry_count) > MAX_WORK) {
                kfree(entry);
-               spin_lock_irqsave(&async_lock, flags);
-               newcookie = next_cookie++;
-               spin_unlock_irqrestore(&async_lock, flags);
-
-               /* low on memory.. run synchronously */
-               func(data, newcookie);
-               return newcookie;
+               return __async_schedule_sync(func, data);
        }
        INIT_LIST_HEAD(&entry->domain_list);
        INIT_LIST_HEAD(&entry->global_list);
-- 
2.0.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to