aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2017-03-14 17:29:53 -0400
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2017-04-18 14:38:20 -0400
commit2b34c43cc1671c59bad6dd1682ae3ee4f0919eb7 (patch)
tree43741e096b4627598e7deb28a333596cd3f5fdb5
parentf2425b4efb0c69e77c0b9666b605ae4a1ecaae47 (diff)
srcu: Move rcu_init_levelspread() to rcu_tree_node.h
This commit moves the rcu_init_levelspread() function from kernel/rcu/tree.c to kernel/rcu/rcu.h so that SRCU can access it. This is another step towards enabling SRCU to create its own combining tree. This commit is code-movement only, give or take knock-on adjustments. Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
-rw-r--r--include/linux/rcu_node_tree.h3
-rw-r--r--kernel/rcu/rcu.h36
-rw-r--r--kernel/rcu/srcu.c1
-rw-r--r--kernel/rcu/tree.c25
-rw-r--r--kernel/rcu/tree_trace.c1
5 files changed, 38 insertions, 28 deletions
diff --git a/include/linux/rcu_node_tree.h b/include/linux/rcu_node_tree.h
index b7eb97096b1c..4b766b61e1a0 100644
--- a/include/linux/rcu_node_tree.h
+++ b/include/linux/rcu_node_tree.h
@@ -96,7 +96,4 @@
96# error "CONFIG_RCU_FANOUT insufficient for NR_CPUS" 96# error "CONFIG_RCU_FANOUT insufficient for NR_CPUS"
97#endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */ 97#endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */
98 98
99extern int rcu_num_lvls;
100extern int rcu_num_nodes;
101
102#endif /* __LINUX_RCU_NODE_TREE_H */ 99#endif /* __LINUX_RCU_NODE_TREE_H */
diff --git a/kernel/rcu/rcu.h b/kernel/rcu/rcu.h
index a943b42a9cf7..87326479b39a 100644
--- a/kernel/rcu/rcu.h
+++ b/kernel/rcu/rcu.h
@@ -190,4 +190,40 @@ void rcu_test_sync_prims(void);
190 */ 190 */
191extern void resched_cpu(int cpu); 191extern void resched_cpu(int cpu);
192 192
193#if defined(SRCU) || !defined(TINY_RCU)
194
195#include <linux/rcu_node_tree.h>
196
197extern int rcu_num_lvls;
198extern int rcu_num_nodes;
199static bool rcu_fanout_exact;
200static int rcu_fanout_leaf;
201
202/*
203 * Compute the per-level fanout, either using the exact fanout specified
204 * or balancing the tree, depending on the rcu_fanout_exact boot parameter.
205 */
206static inline void rcu_init_levelspread(int *levelspread, const int *levelcnt)
207{
208 int i;
209
210 if (rcu_fanout_exact) {
211 levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
212 for (i = rcu_num_lvls - 2; i >= 0; i--)
213 levelspread[i] = RCU_FANOUT;
214 } else {
215 int ccur;
216 int cprv;
217
218 cprv = nr_cpu_ids;
219 for (i = rcu_num_lvls - 1; i >= 0; i--) {
220 ccur = levelcnt[i];
221 levelspread[i] = (cprv + ccur - 1) / ccur;
222 cprv = ccur;
223 }
224 }
225}
226
227#endif /* #if defined(SRCU) || !defined(TINY_RCU) */
228
193#endif /* __LINUX_RCU_H */ 229#endif /* __LINUX_RCU_H */
diff --git a/kernel/rcu/srcu.c b/kernel/rcu/srcu.c
index 56fd30862122..0b511de7ca4d 100644
--- a/kernel/rcu/srcu.c
+++ b/kernel/rcu/srcu.c
@@ -36,6 +36,7 @@
36#include <linux/delay.h> 36#include <linux/delay.h>
37#include <linux/srcu.h> 37#include <linux/srcu.h>
38 38
39#include <linux/rcu_node_tree.h>
39#include "rcu.h" 40#include "rcu.h"
40 41
41static int init_srcu_struct_fields(struct srcu_struct *sp) 42static int init_srcu_struct_fields(struct srcu_struct *sp)
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 844a030c1960..df3527744af8 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3952,31 +3952,6 @@ void rcu_scheduler_starting(void)
3952} 3952}
3953 3953
3954/* 3954/*
3955 * Compute the per-level fanout, either using the exact fanout specified
3956 * or balancing the tree, depending on the rcu_fanout_exact boot parameter.
3957 */
3958static void __init rcu_init_levelspread(int *levelspread, const int *levelcnt)
3959{
3960 int i;
3961
3962 if (rcu_fanout_exact) {
3963 levelspread[rcu_num_lvls - 1] = rcu_fanout_leaf;
3964 for (i = rcu_num_lvls - 2; i >= 0; i--)
3965 levelspread[i] = RCU_FANOUT;
3966 } else {
3967 int ccur;
3968 int cprv;
3969
3970 cprv = nr_cpu_ids;
3971 for (i = rcu_num_lvls - 1; i >= 0; i--) {
3972 ccur = levelcnt[i];
3973 levelspread[i] = (cprv + ccur - 1) / ccur;
3974 cprv = ccur;
3975 }
3976 }
3977}
3978
3979/*
3980 * Helper function for rcu_init() that initializes one rcu_state structure. 3955 * Helper function for rcu_init() that initializes one rcu_state structure.
3981 */ 3956 */
3982static void __init rcu_init_one(struct rcu_state *rsp) 3957static void __init rcu_init_one(struct rcu_state *rsp)
diff --git a/kernel/rcu/tree_trace.c b/kernel/rcu/tree_trace.c
index 066c64071a7b..30c5bf89ee58 100644
--- a/kernel/rcu/tree_trace.c
+++ b/kernel/rcu/tree_trace.c
@@ -45,6 +45,7 @@
45 45
46#define RCU_TREE_NONCORE 46#define RCU_TREE_NONCORE
47#include "tree.h" 47#include "tree.h"
48#include "rcu.h"
48 49
49static int r_open(struct inode *inode, struct file *file, 50static int r_open(struct inode *inode, struct file *file,
50 const struct seq_operations *op) 51 const struct seq_operations *op)