Messages in this thread Patch in this message | | | From | "Luis R. Rodriguez" <> | Subject | [RFC v1 2/3] async: move synchronous caller into a helper | Date | Sun, 31 Aug 2014 02:03:19 -0700 |
| |
From: "Luis R. Rodriguez" <mcgrof@suse.com>
This will be reused later.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Tejun Heo <tj@kernel.org> Cc: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> --- 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
| |