Skip to contentSkip to conversation

async: simple cleanups

PATCH In review Lai Jiangshan 2 participants 6 messages Mar 11, 2013 – Mar 12, 2013 SuperH

lore
Share & tools
lore
#0 lore raw

cover async: simple cleanups

I found somethings need to be cleanup when I watch what has been changed to async.c.

Lai Jiangshan (3):
async: simplify lowest_in_progress()
async: remove unused @node from struct async_domain
async: rename and redefine async_func_ptr

Cc Tejun Heo <[email protected]>
Cc Arjan van de Ven <[email protected]>
---
 arch/sh/drivers/pci/pcie-sh7786.c |    2 +-
 include/linux/async.h             |   19 ++++++-----------
 kernel/async.c                    |   40 ++++++++++++++++--------------------
 3 files changed, 26 insertions(+), 35 deletions(-)
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/3 async: remove unused @node from struct async_domain

The @node in struct async_domain is unused after we introduce async_global_pending, remove it.

Cc Tejun Heo <[email protected]>
Cc Arjan van de Ven <[email protected]>
---
 include/linux/async.h |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
include/linux/async.h +4 -9
index a2e3f18..8e53494 100644
@@ -18,7 +18,6 @@
 typedef u64 async_cookie_t;
 typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
 struct async_domain {
-	struct list_head node;
 	struct list_head pending;
 	unsigned registered:1;
 };
@@ -26,19 +25,15 @@ struct async_domain {
 /*
  * domain participates in global async_synchronize_full
  */
-#define ASYNC_DOMAIN(_name) \
-	struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
-				      .pending = LIST_HEAD_INIT(_name.pending), \
-				      .registered = 1 }
+#define ASYNC_DOMAIN(_name) struct async_domain _name =			\
+	{ .pending = LIST_HEAD_INIT(_name.pending), .registered = 1 }
 
 /*
  * domain is free to go out of scope as soon as all pending work is
  * complete, this domain does not participate in async_synchronize_full
  */
-#define ASYNC_DOMAIN_EXCLUSIVE(_name) \
-	struct async_domain _name = { .node = LIST_HEAD_INIT(_name.node), \
-				      .pending = LIST_HEAD_INIT(_name.pending), \
-				      .registered = 0 }
+#define ASYNC_DOMAIN_EXCLUSIVE(_name) struct async_domain _name =	\
+	{ .pending = LIST_HEAD_INIT(_name.pending), .registered = 0 }
 
 extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
 extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 1/3 async: simplify lowest_in_progress()

In reply to Lai Jiangshan

The code in lowest_in_progress() are duplicated in two branches, simplify them.

Cc Tejun Heo <[email protected]>
Cc Arjan van de Ven <[email protected]>
---
 kernel/async.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)
kernel/async.c +8 -12
index 8ddee2c..ef66b2f 100644
@@ -84,24 +84,20 @@ static atomic_t entry_count;
 
 static async_cookie_t lowest_in_progress(struct async_domain *domain)
 {
-	struct async_entry *first = NULL;
+	struct list_head *pending;
 	async_cookie_t ret = ASYNC_COOKIE_MAX;
 	unsigned long flags;
 
 	spin_lock_irqsave(&async_lock, flags);
 
-	if (domain) {
-		if (!list_empty(&domain->pending))
-			first = list_first_entry(&domain->pending,
-					struct async_entry, domain_list);
-	} else {
-		if (!list_empty(&async_global_pending))
-			first = list_first_entry(&async_global_pending,
-					struct async_entry, global_list);
-	}
+	if (domain)
+		pending = &domain->pending;
+	else
+		pending = &async_global_pending;
 
-	if (first)
-		ret = first->cookie;
+	if (!list_empty(pending))
+		ret = list_first_entry(pending, struct async_entry,
+				domain_list)->cookie;
 
 	spin_unlock_irqrestore(&async_lock, flags);
 	return ret;
Signature · 1 line
1.7.4.4
#3 lore raw

PATCH 3/3 async: rename and redefine async_func_ptr

In reply to Lai Jiangshan

A function type is typically defined as
typedef ret_type (*func)(args..)

but async_func_ptr is not. Redefine it.

Also rename async_func_ptr to async_func_t for _func_t suffix is more generic.

Cc Tejun Heo <[email protected]>
Cc Arjan van de Ven <[email protected]>
---
 arch/sh/drivers/pci/pcie-sh7786.c |    2 +-
 include/linux/async.h             |    6 +++---
 kernel/async.c                    |   20 ++++++++++----------
 3 files changed, 14 insertions(+), 14 deletions(-)
arch/sh/drivers/pci/pcie-sh7786.c +1 -1
index c2c85f6..a162a7f 100644
@@ -35,7 +35,7 @@ static unsigned int nr_ports;
 
 static struct sh7786_pcie_hwops {
 	int (*core_init)(void);
-	async_func_ptr *port_init_hw;
+	async_func_t port_init_hw;
 } *sh7786_pcie_hwops;
 
 static struct resource sh7786_pci0_resources[] = {
include/linux/async.h +3 -3
index 8e53494..0f1226d 100644
@@ -16,7 +16,7 @@
 #include <linux/list.h>
 
 typedef u64 async_cookie_t;
-typedef void (async_func_ptr) (void *data, async_cookie_t cookie);
+typedef void (*async_func_t) (void *data, async_cookie_t cookie);
 struct async_domain {
 	struct list_head pending;
 	unsigned registered:1;
@@ -35,8 +35,8 @@ struct async_domain {
 #define ASYNC_DOMAIN_EXCLUSIVE(_name) struct async_domain _name =	\
 	{ .pending = LIST_HEAD_INIT(_name.pending), .registered = 0 }
 
-extern async_cookie_t async_schedule(async_func_ptr *ptr, void *data);
-extern async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
+extern async_cookie_t async_schedule(async_func_t func, void *data);
+extern async_cookie_t async_schedule_domain(async_func_t func, void *data,
 					    struct async_domain *domain);
 void async_unregister_domain(struct async_domain *domain);
 extern void async_synchronize_full(void);
kernel/async.c +10 -10
index ef66b2f..61873c3 100644
@@ -73,7 +73,7 @@ struct async_entry {
 	struct list_head	global_list;
 	struct work_struct	work;
 	async_cookie_t		cookie;
-	async_func_ptr		*func;
+	async_func_t		func;
 	void			*data;
 	struct async_domain	*domain;
 };
@@ -145,7 +145,7 @@ static void async_run_entry_fn(struct work_struct *work)
 	wake_up(&async_done);
 }
 
-static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct async_domain *domain)
+static async_cookie_t __async_schedule(async_func_t func, void *data, struct async_domain *domain)
 {
 	struct async_entry *entry;
 	unsigned long flags;
@@ -165,13 +165,13 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct a
 		spin_unlock_irqrestore(&async_lock, flags);
 
 		/* low on memory.. run synchronously */
-		ptr(data, newcookie);
+		func(data, newcookie);
 		return newcookie;
 	}
 	INIT_LIST_HEAD(&entry->domain_list);
 	INIT_LIST_HEAD(&entry->global_list);
 	INIT_WORK(&entry->work, async_run_entry_fn);
-	entry->func = ptr;
+	entry->func = func;
 	entry->data = data;
 	entry->domain = domain;
 
@@ -198,21 +198,21 @@ static async_cookie_t __async_schedule(async_func_ptr *ptr, void *data, struct a
 
 /**
  * async_schedule - schedule a function for asynchronous execution
- * @ptr: function to execute asynchronously
+ * @func: function to execute asynchronously
  * @data: data pointer to pass to the function
  *
  * Returns an async_cookie_t that may be used for checkpointing later.
  * Note: This function may be called from atomic or non-atomic contexts.
  */
-async_cookie_t async_schedule(async_func_ptr *ptr, void *data)
+async_cookie_t async_schedule(async_func_t func, void *data)
 {
-	return __async_schedule(ptr, data, &async_dfl_domain);
+	return __async_schedule(func, data, &async_dfl_domain);
 }
 EXPORT_SYMBOL_GPL(async_schedule);
 
 /**
  * async_schedule_domain - schedule a function for asynchronous execution within a certain domain
- * @ptr: function to execute asynchronously
+ * @func: function to execute asynchronously
  * @data: data pointer to pass to the function
  * @domain: the domain
  *
@@ -222,10 +222,10 @@ EXPORT_SYMBOL_GPL(async_schedule);
  * synchronization domain is specified via @domain.  Note: This function
  * may be called from atomic or non-atomic contexts.
  */
-async_cookie_t async_schedule_domain(async_func_ptr *ptr, void *data,
+async_cookie_t async_schedule_domain(async_func_t func, void *data,
 				     struct async_domain *domain)
 {
-	return __async_schedule(ptr, data, domain);
+	return __async_schedule(func, data, domain);
 }
 EXPORT_SYMBOL_GPL(async_schedule_domain);
 
Signature · 1 line
1.7.4.4
#4 lore raw
In reply to Lai Jiangshan
Quoted 7 lines · Lai Jiangshan

I found somethings need to be cleanup when I watch what has been changed to async.c.

Lai Jiangshan (3):
async: simplify lowest_in_progress()
async: remove unused @node from struct async_domain
async: rename and redefine async_func_ptr

Applied with cosmetic whitespace adjustments (why change the formatting in the second patch? For the 80 col limit?)

Thanks.

Signature · 1 line
tejun
#5 lore raw
Quoted 11 lines · Tejun Heo
Quoted 7 lines · Lai Jiangshan

I found somethings need to be cleanup when I watch what has been changed to async.c.

Lai Jiangshan (3):
async: simplify lowest_in_progress()
async: remove unused @node from struct async_domain
async: rename and redefine async_func_ptr

Applied with cosmetic whitespace adjustments (why change the formatting in the second patch? For the 80 col limit?)

Oops, the branch is wq/for-3.10-async.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git for-3.10-async

Thanks.

Signature · 1 line
tejun