All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t
@ 2015-07-29  5:29 Boqun Feng
  2015-07-29  5:29 ` [PATCH 1/2] rcu: Use rcu_callback_t in call_rcu*() and friends Boqun Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Boqun Feng @ 2015-07-29  5:29 UTC (permalink / raw)
  To: Josh Triplett, Paul E. McKenney
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, linux-kernel,
	Boqun Feng

Commit ("rcu: Create a synchronize_rcu_mult()") in linux-rcu.git#rcu/next
branch has introduced rcu_callback_t as the type for rcu callback
functions and call_rcu_func_t has been introduced for a while. This patch
series uses the rcu_callback_t and call_rcu_func_t to save a few lines of
code.

This patchset is based on rcu/next branch of Paul's linux-rcu tree, and
consists of two patches:

1.	Use rcu_callback_t as the type of callbacks in call_rcu*() and
	friends

2.	Use call_rcu_func_t to replace the equivalent but complicated
	function pointer type.

Besides cleaning up the code, this patchset can also help code tag program,
such as cscope to generate a better database.

This patchset has been already tested by 0day.

Regards,
Boqun

-------------------------------------------------------------------------
 include/linux/rcupdate.h | 10 +++++-----
 include/linux/rcutiny.h  |  2 +-
 include/linux/rcutree.h  |  2 +-
 kernel/rcu/rcutorture.c  |  6 +++---
 kernel/rcu/srcu.c        |  2 +-
 kernel/rcu/tiny.c        |  8 ++++----
 kernel/rcu/tree.c        |  8 ++++----
 kernel/rcu/tree.h        |  5 ++---
 kernel/rcu/tree_plugin.h |  2 +-
 kernel/rcu/update.c      |  2 +-
 10 files changed, 23 insertions(+), 24 deletions(-)

-- 
2.4.6


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] rcu: Use rcu_callback_t in call_rcu*() and friends
  2015-07-29  5:29 [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Boqun Feng
@ 2015-07-29  5:29 ` Boqun Feng
  2015-07-29  5:29 ` [PATCH 2/2] rcu: Use call_rcu_func_to to replace explicit type equivalents Boqun Feng
  2015-07-29 14:55 ` [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Boqun Feng @ 2015-07-29  5:29 UTC (permalink / raw)
  To: Josh Triplett, Paul E. McKenney
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, linux-kernel,
	Boqun Feng

As we now have rcu_callback_t typedefs as the type of rcu callbacks, we
should use it in call_rcu*() and friends as the type of parameters. This
could save us a few lines of code and make it clear which function
requires an rcu callbacks rather than other callbacks as its argument.

Besides, this can also help cscope to generate a better database for
code reading.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
 include/linux/rcupdate.h | 10 +++++-----
 include/linux/rcutiny.h  |  2 +-
 include/linux/rcutree.h  |  2 +-
 kernel/rcu/rcutorture.c  |  4 ++--
 kernel/rcu/srcu.c        |  2 +-
 kernel/rcu/tiny.c        |  8 ++++----
 kernel/rcu/tree.c        |  8 ++++----
 kernel/rcu/tree.h        |  2 +-
 kernel/rcu/tree_plugin.h |  2 +-
 kernel/rcu/update.c      |  2 +-
 10 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index ff47651..78af46c 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -160,7 +160,7 @@ void do_trace_rcu_torture_read(const char *rcutorturename,
  * more than one CPU).
  */
 void call_rcu(struct rcu_head *head,
-	      void (*func)(struct rcu_head *head));
+	      rcu_callback_t func);
 
 #else /* #ifdef CONFIG_PREEMPT_RCU */
 
@@ -191,7 +191,7 @@ void call_rcu(struct rcu_head *head,
  * memory ordering guarantees.
  */
 void call_rcu_bh(struct rcu_head *head,
-		 void (*func)(struct rcu_head *head));
+		 rcu_callback_t func);
 
 /**
  * call_rcu_sched() - Queue an RCU for invocation after sched grace period.
@@ -213,7 +213,7 @@ void call_rcu_bh(struct rcu_head *head,
  * memory ordering guarantees.
  */
 void call_rcu_sched(struct rcu_head *head,
-		    void (*func)(struct rcu_head *rcu));
+		    rcu_callback_t func);
 
 void synchronize_sched(void);
 
@@ -275,7 +275,7 @@ do { \
  * See the description of call_rcu() for more detailed information on
  * memory ordering guarantees.
  */
-void call_rcu_tasks(struct rcu_head *head, void (*func)(struct rcu_head *head));
+void call_rcu_tasks(struct rcu_head *head, rcu_callback_t func);
 void synchronize_rcu_tasks(void);
 void rcu_barrier_tasks(void);
 
@@ -1066,7 +1066,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)
 #define __kfree_rcu(head, offset) \
 	do { \
 		BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
-		kfree_call_rcu(head, (void (*)(struct rcu_head *))(unsigned long)(offset)); \
+		kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
 	} while (0)
 
 /**
diff --git a/include/linux/rcutiny.h b/include/linux/rcutiny.h
index ff968b7..c8a0722 100644
--- a/include/linux/rcutiny.h
+++ b/include/linux/rcutiny.h
@@ -83,7 +83,7 @@ static inline void synchronize_sched_expedited(void)
 }
 
 static inline void kfree_call_rcu(struct rcu_head *head,
-				  void (*func)(struct rcu_head *rcu))
+				  rcu_callback_t func)
 {
 	call_rcu(head, func);
 }
diff --git a/include/linux/rcutree.h b/include/linux/rcutree.h
index 5abec82..60d15a0 100644
--- a/include/linux/rcutree.h
+++ b/include/linux/rcutree.h
@@ -48,7 +48,7 @@ void synchronize_rcu_bh(void);
 void synchronize_sched_expedited(void);
 void synchronize_rcu_expedited(void);
 
-void kfree_call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
+void kfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
 
 /**
  * synchronize_rcu_bh_expedited - Brute-force RCU-bh grace period
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 7719295..51c8e7f 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -448,7 +448,7 @@ static void synchronize_rcu_busted(void)
 }
 
 static void
-call_rcu_busted(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+call_rcu_busted(struct rcu_head *head, rcu_callback_t func)
 {
 	/* This is a deliberate bug for testing purposes only! */
 	func(head);
@@ -523,7 +523,7 @@ static void srcu_torture_synchronize(void)
 }
 
 static void srcu_torture_call(struct rcu_head *head,
-			      void (*func)(struct rcu_head *head))
+			      rcu_callback_t func)
 {
 	call_srcu(srcu_ctlp, head, func);
 }
diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c
index d3fcb2e..9e61225 100644
--- a/kernel/rcu/srcu.c
+++ b/kernel/rcu/srcu.c
@@ -387,7 +387,7 @@ static void srcu_flip(struct srcu_struct *sp)
  * srcu_struct structure.
  */
 void call_srcu(struct srcu_struct *sp, struct rcu_head *head,
-		void (*func)(struct rcu_head *head))
+	       rcu_callback_t func)
 {
 	unsigned long flags;
 
diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index d047105..944b1b4 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -44,7 +44,7 @@ struct rcu_ctrlblk;
 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
 static void rcu_process_callbacks(struct softirq_action *unused);
 static void __call_rcu(struct rcu_head *head,
-		       void (*func)(struct rcu_head *rcu),
+		       rcu_callback_t func,
 		       struct rcu_ctrlblk *rcp);
 
 #include "tiny_plugin.h"
@@ -203,7 +203,7 @@ EXPORT_SYMBOL_GPL(synchronize_sched);
  * Helper function for call_rcu() and call_rcu_bh().
  */
 static void __call_rcu(struct rcu_head *head,
-		       void (*func)(struct rcu_head *rcu),
+		       rcu_callback_t func,
 		       struct rcu_ctrlblk *rcp)
 {
 	unsigned long flags;
@@ -229,7 +229,7 @@ static void __call_rcu(struct rcu_head *head,
  * period.  But since we have but one CPU, that would be after any
  * quiescent state.
  */
-void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+void call_rcu_sched(struct rcu_head *head, rcu_callback_t func)
 {
 	__call_rcu(head, func, &rcu_sched_ctrlblk);
 }
@@ -239,7 +239,7 @@ EXPORT_SYMBOL_GPL(call_rcu_sched);
  * Post an RCU bottom-half callback to be invoked after any subsequent
  * quiescent state.
  */
-void call_rcu_bh(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+void call_rcu_bh(struct rcu_head *head, rcu_callback_t func)
 {
 	__call_rcu(head, func, &rcu_bh_ctrlblk);
 }
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 9f75f25..34a4308 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3017,7 +3017,7 @@ static void rcu_leak_callback(struct rcu_head *rhp)
  * is expected to specify a CPU.
  */
 static void
-__call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
+__call_rcu(struct rcu_head *head, rcu_callback_t func,
 	   struct rcu_state *rsp, int cpu, bool lazy)
 {
 	unsigned long flags;
@@ -3088,7 +3088,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
 /*
  * Queue an RCU-sched callback for invocation after a grace period.
  */
-void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+void call_rcu_sched(struct rcu_head *head, rcu_callback_t func)
 {
 	__call_rcu(head, func, &rcu_sched_state, -1, 0);
 }
@@ -3097,7 +3097,7 @@ EXPORT_SYMBOL_GPL(call_rcu_sched);
 /*
  * Queue an RCU callback for invocation after a quicker grace period.
  */
-void call_rcu_bh(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+void call_rcu_bh(struct rcu_head *head, rcu_callback_t func)
 {
 	__call_rcu(head, func, &rcu_bh_state, -1, 0);
 }
@@ -3111,7 +3111,7 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
  * function may only be called from __kfree_rcu().
  */
 void kfree_call_rcu(struct rcu_head *head,
-		    void (*func)(struct rcu_head *rcu))
+		    rcu_callback_t func)
 {
 	__call_rcu(head, func, rcu_state_p, -1, 1);
 }
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index 2e991f8..ad11529 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -584,7 +584,7 @@ static void rcu_print_detail_task_stall(struct rcu_state *rsp);
 static int rcu_print_task_stall(struct rcu_node *rnp);
 static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
 static void rcu_preempt_check_callbacks(void);
-void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
+void call_rcu(struct rcu_head *head, rcu_callback_t func);
 static void __init __rcu_init_preempt(void);
 static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
 static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index b2bf396..06116ae 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -500,7 +500,7 @@ static void rcu_preempt_do_callbacks(void)
 /*
  * Queue a preemptible-RCU callback for invocation after a grace period.
  */
-void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
+void call_rcu(struct rcu_head *head, rcu_callback_t func)
 {
 	__call_rcu(head, func, rcu_state_p, -1, 0);
 }
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index 7a0b3bc..5f748c5 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -534,7 +534,7 @@ static void rcu_spawn_tasks_kthread(void);
  * Post an RCU-tasks callback.  First call must be from process context
  * after the scheduler if fully operational.
  */
-void call_rcu_tasks(struct rcu_head *rhp, void (*func)(struct rcu_head *rhp))
+void call_rcu_tasks(struct rcu_head *rhp, rcu_callback_t func)
 {
 	unsigned long flags;
 	bool needwake;
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rcu: Use call_rcu_func_to to replace explicit type equivalents
  2015-07-29  5:29 [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Boqun Feng
  2015-07-29  5:29 ` [PATCH 1/2] rcu: Use rcu_callback_t in call_rcu*() and friends Boqun Feng
@ 2015-07-29  5:29 ` Boqun Feng
  2015-07-29 14:55 ` [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Boqun Feng @ 2015-07-29  5:29 UTC (permalink / raw)
  To: Josh Triplett, Paul E. McKenney
  Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, linux-kernel,
	Boqun Feng

We have call_rcu_func_t for a quite while, but we still use explicit
function pointer type equivalents in some places, this patch replace
these equivalent types with call_rcu_func_t to gain better readability.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
 kernel/rcu/rcutorture.c | 2 +-
 kernel/rcu/tree.h       | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index 51c8e7f..f9ec6cb 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -252,7 +252,7 @@ struct rcu_torture_ops {
 	void (*exp_sync)(void);
 	unsigned long (*get_state)(void);
 	void (*cond_sync)(unsigned long oldstate);
-	void (*call)(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
+	call_rcu_func_t call;
 	void (*cb_barrier)(void);
 	void (*fqs)(void);
 	void (*stats)(void);
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index ad11529..0c33c82 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -464,8 +464,7 @@ struct rcu_state {
 						/*  shut bogus gcc warning) */
 	u8 flavor_mask;				/* bit in flavor mask. */
 	struct rcu_data __percpu *rda;		/* pointer of percu rcu_data. */
-	void (*call)(struct rcu_head *head,	/* call_rcu() flavor. */
-		     void (*func)(struct rcu_head *head));
+	call_rcu_func_t call;			/* call_rcu() flavor. */
 
 	/* The following fields are guarded by the root rcu_node's lock. */
 
-- 
2.4.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t
  2015-07-29  5:29 [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Boqun Feng
  2015-07-29  5:29 ` [PATCH 1/2] rcu: Use rcu_callback_t in call_rcu*() and friends Boqun Feng
  2015-07-29  5:29 ` [PATCH 2/2] rcu: Use call_rcu_func_to to replace explicit type equivalents Boqun Feng
@ 2015-07-29 14:55 ` Paul E. McKenney
  2 siblings, 0 replies; 4+ messages in thread
From: Paul E. McKenney @ 2015-07-29 14:55 UTC (permalink / raw)
  To: Boqun Feng
  Cc: Josh Triplett, Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan,
	linux-kernel

On Wed, Jul 29, 2015 at 01:29:37PM +0800, Boqun Feng wrote:
> Commit ("rcu: Create a synchronize_rcu_mult()") in linux-rcu.git#rcu/next
> branch has introduced rcu_callback_t as the type for rcu callback
> functions and call_rcu_func_t has been introduced for a while. This patch
> series uses the rcu_callback_t and call_rcu_func_t to save a few lines of
> code.
> 
> This patchset is based on rcu/next branch of Paul's linux-rcu tree, and
> consists of two patches:
> 
> 1.	Use rcu_callback_t as the type of callbacks in call_rcu*() and
> 	friends
> 
> 2.	Use call_rcu_func_t to replace the equivalent but complicated
> 	function pointer type.
> 
> Besides cleaning up the code, this patchset can also help code tag program,
> such as cscope to generate a better database.
> 
> This patchset has been already tested by 0day.

Hello, Boqun,

I have queued these for local testing.

							Thanx, Paul

> Regards,
> Boqun
> 
> -------------------------------------------------------------------------
>  include/linux/rcupdate.h | 10 +++++-----
>  include/linux/rcutiny.h  |  2 +-
>  include/linux/rcutree.h  |  2 +-
>  kernel/rcu/rcutorture.c  |  6 +++---
>  kernel/rcu/srcu.c        |  2 +-
>  kernel/rcu/tiny.c        |  8 ++++----
>  kernel/rcu/tree.c        |  8 ++++----
>  kernel/rcu/tree.h        |  5 ++---
>  kernel/rcu/tree_plugin.h |  2 +-
>  kernel/rcu/update.c      |  2 +-
>  10 files changed, 23 insertions(+), 24 deletions(-)
> 
> -- 
> 2.4.6
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-29 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-29  5:29 [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Boqun Feng
2015-07-29  5:29 ` [PATCH 1/2] rcu: Use rcu_callback_t in call_rcu*() and friends Boqun Feng
2015-07-29  5:29 ` [PATCH 2/2] rcu: Use call_rcu_func_to to replace explicit type equivalents Boqun Feng
2015-07-29 14:55 ` [PATCH 0/2] Replace explicit function pointer types with rcu_callback_t and call_rcu_func_t Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.