xref: /linux/kernel/rcu/tree.h (revision cdacbe1f91264687af956e810278030f2ab5a3d0)
14102adabSPaul E. McKenney /*
24102adabSPaul E. McKenney  * Read-Copy Update mechanism for mutual exclusion (tree-based version)
34102adabSPaul E. McKenney  * Internal non-public definitions.
44102adabSPaul E. McKenney  *
54102adabSPaul E. McKenney  * This program is free software; you can redistribute it and/or modify
64102adabSPaul E. McKenney  * it under the terms of the GNU General Public License as published by
74102adabSPaul E. McKenney  * the Free Software Foundation; either version 2 of the License, or
84102adabSPaul E. McKenney  * (at your option) any later version.
94102adabSPaul E. McKenney  *
104102adabSPaul E. McKenney  * This program is distributed in the hope that it will be useful,
114102adabSPaul E. McKenney  * but WITHOUT ANY WARRANTY; without even the implied warranty of
124102adabSPaul E. McKenney  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
134102adabSPaul E. McKenney  * GNU General Public License for more details.
144102adabSPaul E. McKenney  *
154102adabSPaul E. McKenney  * You should have received a copy of the GNU General Public License
1687de1cfdSPaul E. McKenney  * along with this program; if not, you can access it online at
1787de1cfdSPaul E. McKenney  * http://www.gnu.org/licenses/gpl-2.0.html.
184102adabSPaul E. McKenney  *
194102adabSPaul E. McKenney  * Copyright IBM Corporation, 2008
204102adabSPaul E. McKenney  *
214102adabSPaul E. McKenney  * Author: Ingo Molnar <mingo@elte.hu>
224102adabSPaul E. McKenney  *	   Paul E. McKenney <paulmck@linux.vnet.ibm.com>
234102adabSPaul E. McKenney  */
244102adabSPaul E. McKenney 
254102adabSPaul E. McKenney #include <linux/cache.h>
264102adabSPaul E. McKenney #include <linux/spinlock.h>
274102adabSPaul E. McKenney #include <linux/threads.h>
284102adabSPaul E. McKenney #include <linux/cpumask.h>
294102adabSPaul E. McKenney #include <linux/seqlock.h>
303a6d7c64SPeter Zijlstra #include <linux/stop_machine.h>
314102adabSPaul E. McKenney 
324102adabSPaul E. McKenney /*
334102adabSPaul E. McKenney  * Define shape of hierarchy based on NR_CPUS, CONFIG_RCU_FANOUT, and
344102adabSPaul E. McKenney  * CONFIG_RCU_FANOUT_LEAF.
354102adabSPaul E. McKenney  * In theory, it should be possible to add more levels straightforwardly.
364102adabSPaul E. McKenney  * In practice, this did work well going from three levels to four.
374102adabSPaul E. McKenney  * Of course, your mileage may vary.
384102adabSPaul E. McKenney  */
3905c5df31SPaul E. McKenney 
4005c5df31SPaul E. McKenney #ifdef CONFIG_RCU_FANOUT
4105c5df31SPaul E. McKenney #define RCU_FANOUT CONFIG_RCU_FANOUT
4205c5df31SPaul E. McKenney #else /* #ifdef CONFIG_RCU_FANOUT */
4305c5df31SPaul E. McKenney # ifdef CONFIG_64BIT
4405c5df31SPaul E. McKenney # define RCU_FANOUT 64
4505c5df31SPaul E. McKenney # else
4605c5df31SPaul E. McKenney # define RCU_FANOUT 32
4705c5df31SPaul E. McKenney # endif
4805c5df31SPaul E. McKenney #endif /* #else #ifdef CONFIG_RCU_FANOUT */
4905c5df31SPaul E. McKenney 
5047d631afSPaul E. McKenney #ifdef CONFIG_RCU_FANOUT_LEAF
5147d631afSPaul E. McKenney #define RCU_FANOUT_LEAF CONFIG_RCU_FANOUT_LEAF
5247d631afSPaul E. McKenney #else /* #ifdef CONFIG_RCU_FANOUT_LEAF */
5347d631afSPaul E. McKenney # ifdef CONFIG_64BIT
5447d631afSPaul E. McKenney # define RCU_FANOUT_LEAF 64
5547d631afSPaul E. McKenney # else
5647d631afSPaul E. McKenney # define RCU_FANOUT_LEAF 32
5747d631afSPaul E. McKenney # endif
5847d631afSPaul E. McKenney #endif /* #else #ifdef CONFIG_RCU_FANOUT_LEAF */
5947d631afSPaul E. McKenney 
6047d631afSPaul E. McKenney #define RCU_FANOUT_1	      (RCU_FANOUT_LEAF)
6105c5df31SPaul E. McKenney #define RCU_FANOUT_2	      (RCU_FANOUT_1 * RCU_FANOUT)
6205c5df31SPaul E. McKenney #define RCU_FANOUT_3	      (RCU_FANOUT_2 * RCU_FANOUT)
6305c5df31SPaul E. McKenney #define RCU_FANOUT_4	      (RCU_FANOUT_3 * RCU_FANOUT)
644102adabSPaul E. McKenney 
654102adabSPaul E. McKenney #if NR_CPUS <= RCU_FANOUT_1
664102adabSPaul E. McKenney #  define RCU_NUM_LVLS	      1
674102adabSPaul E. McKenney #  define NUM_RCU_LVL_0	      1
6842621697SAlexander Gordeev #  define NUM_RCU_NODES	      NUM_RCU_LVL_0
69cb007102SAlexander Gordeev #  define NUM_RCU_LVL_INIT    { NUM_RCU_LVL_0 }
70cb007102SAlexander Gordeev #  define RCU_NODE_NAME_INIT  { "rcu_node_0" }
71cb007102SAlexander Gordeev #  define RCU_FQS_NAME_INIT   { "rcu_node_fqs_0" }
72385b73c0SPaul E. McKenney #  define RCU_EXP_NAME_INIT   { "rcu_node_exp_0" }
734102adabSPaul E. McKenney #elif NR_CPUS <= RCU_FANOUT_2
744102adabSPaul E. McKenney #  define RCU_NUM_LVLS	      2
754102adabSPaul E. McKenney #  define NUM_RCU_LVL_0	      1
764102adabSPaul E. McKenney #  define NUM_RCU_LVL_1	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1)
7742621697SAlexander Gordeev #  define NUM_RCU_NODES	      (NUM_RCU_LVL_0 + NUM_RCU_LVL_1)
78cb007102SAlexander Gordeev #  define NUM_RCU_LVL_INIT    { NUM_RCU_LVL_0, NUM_RCU_LVL_1 }
79cb007102SAlexander Gordeev #  define RCU_NODE_NAME_INIT  { "rcu_node_0", "rcu_node_1" }
80cb007102SAlexander Gordeev #  define RCU_FQS_NAME_INIT   { "rcu_node_fqs_0", "rcu_node_fqs_1" }
81385b73c0SPaul E. McKenney #  define RCU_EXP_NAME_INIT   { "rcu_node_exp_0", "rcu_node_exp_1" }
824102adabSPaul E. McKenney #elif NR_CPUS <= RCU_FANOUT_3
834102adabSPaul E. McKenney #  define RCU_NUM_LVLS	      3
844102adabSPaul E. McKenney #  define NUM_RCU_LVL_0	      1
854102adabSPaul E. McKenney #  define NUM_RCU_LVL_1	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2)
864102adabSPaul E. McKenney #  define NUM_RCU_LVL_2	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1)
8742621697SAlexander Gordeev #  define NUM_RCU_NODES	      (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2)
88cb007102SAlexander Gordeev #  define NUM_RCU_LVL_INIT    { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2 }
89cb007102SAlexander Gordeev #  define RCU_NODE_NAME_INIT  { "rcu_node_0", "rcu_node_1", "rcu_node_2" }
90cb007102SAlexander Gordeev #  define RCU_FQS_NAME_INIT   { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2" }
91385b73c0SPaul E. McKenney #  define RCU_EXP_NAME_INIT   { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2" }
924102adabSPaul E. McKenney #elif NR_CPUS <= RCU_FANOUT_4
934102adabSPaul E. McKenney #  define RCU_NUM_LVLS	      4
944102adabSPaul E. McKenney #  define NUM_RCU_LVL_0	      1
954102adabSPaul E. McKenney #  define NUM_RCU_LVL_1	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_3)
964102adabSPaul E. McKenney #  define NUM_RCU_LVL_2	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_2)
974102adabSPaul E. McKenney #  define NUM_RCU_LVL_3	      DIV_ROUND_UP(NR_CPUS, RCU_FANOUT_1)
9842621697SAlexander Gordeev #  define NUM_RCU_NODES	      (NUM_RCU_LVL_0 + NUM_RCU_LVL_1 + NUM_RCU_LVL_2 + NUM_RCU_LVL_3)
99cb007102SAlexander Gordeev #  define NUM_RCU_LVL_INIT    { NUM_RCU_LVL_0, NUM_RCU_LVL_1, NUM_RCU_LVL_2, NUM_RCU_LVL_3 }
100cb007102SAlexander Gordeev #  define RCU_NODE_NAME_INIT  { "rcu_node_0", "rcu_node_1", "rcu_node_2", "rcu_node_3" }
101cb007102SAlexander Gordeev #  define RCU_FQS_NAME_INIT   { "rcu_node_fqs_0", "rcu_node_fqs_1", "rcu_node_fqs_2", "rcu_node_fqs_3" }
102385b73c0SPaul E. McKenney #  define RCU_EXP_NAME_INIT   { "rcu_node_exp_0", "rcu_node_exp_1", "rcu_node_exp_2", "rcu_node_exp_3" }
1034102adabSPaul E. McKenney #else
1044102adabSPaul E. McKenney # error "CONFIG_RCU_FANOUT insufficient for NR_CPUS"
1054102adabSPaul E. McKenney #endif /* #if (NR_CPUS) <= RCU_FANOUT_1 */
1064102adabSPaul E. McKenney 
1074102adabSPaul E. McKenney extern int rcu_num_lvls;
1084102adabSPaul E. McKenney extern int rcu_num_nodes;
1094102adabSPaul E. McKenney 
1104102adabSPaul E. McKenney /*
1114102adabSPaul E. McKenney  * Dynticks per-CPU state.
1124102adabSPaul E. McKenney  */
1134102adabSPaul E. McKenney struct rcu_dynticks {
1144102adabSPaul E. McKenney 	long long dynticks_nesting; /* Track irq/process nesting level. */
1154102adabSPaul E. McKenney 				    /* Process level is worth LLONG_MAX/2. */
1164102adabSPaul E. McKenney 	int dynticks_nmi_nesting;   /* Track NMI nesting level. */
1174102adabSPaul E. McKenney 	atomic_t dynticks;	    /* Even value for idle, else odd. */
1184102adabSPaul E. McKenney #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
1194102adabSPaul E. McKenney 	long long dynticks_idle_nesting;
1204102adabSPaul E. McKenney 				    /* irq/process nesting level from idle. */
1214102adabSPaul E. McKenney 	atomic_t dynticks_idle;	    /* Even value for idle, else odd. */
1224102adabSPaul E. McKenney 				    /*  "Idle" excludes userspace execution. */
1234102adabSPaul E. McKenney 	unsigned long dynticks_idle_jiffies;
1244102adabSPaul E. McKenney 				    /* End of last non-NMI non-idle period. */
1254102adabSPaul E. McKenney #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */
1264102adabSPaul E. McKenney #ifdef CONFIG_RCU_FAST_NO_HZ
1274102adabSPaul E. McKenney 	bool all_lazy;		    /* Are all CPU's CBs lazy? */
1284102adabSPaul E. McKenney 	unsigned long nonlazy_posted;
1294102adabSPaul E. McKenney 				    /* # times non-lazy CBs posted to CPU. */
1304102adabSPaul E. McKenney 	unsigned long nonlazy_posted_snap;
1314102adabSPaul E. McKenney 				    /* idle-period nonlazy_posted snapshot. */
1324102adabSPaul E. McKenney 	unsigned long last_accelerate;
1334102adabSPaul E. McKenney 				    /* Last jiffy CBs were accelerated. */
1344102adabSPaul E. McKenney 	unsigned long last_advance_all;
1354102adabSPaul E. McKenney 				    /* Last jiffy CBs were all advanced. */
1364102adabSPaul E. McKenney 	int tick_nohz_enabled_snap; /* Previously seen value from sysfs. */
1374102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */
1384102adabSPaul E. McKenney };
1394102adabSPaul E. McKenney 
1404102adabSPaul E. McKenney /* RCU's kthread states for tracing. */
1414102adabSPaul E. McKenney #define RCU_KTHREAD_STOPPED  0
1424102adabSPaul E. McKenney #define RCU_KTHREAD_RUNNING  1
1434102adabSPaul E. McKenney #define RCU_KTHREAD_WAITING  2
1444102adabSPaul E. McKenney #define RCU_KTHREAD_OFFCPU   3
1454102adabSPaul E. McKenney #define RCU_KTHREAD_YIELDING 4
1464102adabSPaul E. McKenney #define RCU_KTHREAD_MAX      4
1474102adabSPaul E. McKenney 
1484102adabSPaul E. McKenney /*
1494102adabSPaul E. McKenney  * Definition for node within the RCU grace-period-detection hierarchy.
1504102adabSPaul E. McKenney  */
1514102adabSPaul E. McKenney struct rcu_node {
1524102adabSPaul E. McKenney 	raw_spinlock_t lock;	/* Root rcu_node's lock protects some */
1534102adabSPaul E. McKenney 				/*  rcu_state fields as well as following. */
1544102adabSPaul E. McKenney 	unsigned long gpnum;	/* Current grace period for this node. */
1554102adabSPaul E. McKenney 				/*  This will either be equal to or one */
1564102adabSPaul E. McKenney 				/*  behind the root rcu_node's gpnum. */
1574102adabSPaul E. McKenney 	unsigned long completed; /* Last GP completed for this node. */
1584102adabSPaul E. McKenney 				/*  This will either be equal to or one */
1594102adabSPaul E. McKenney 				/*  behind the root rcu_node's gpnum. */
1604102adabSPaul E. McKenney 	unsigned long qsmask;	/* CPUs or groups that need to switch in */
1614102adabSPaul E. McKenney 				/*  order for current grace period to proceed.*/
1624102adabSPaul E. McKenney 				/*  In leaf rcu_node, each bit corresponds to */
1634102adabSPaul E. McKenney 				/*  an rcu_data structure, otherwise, each */
1644102adabSPaul E. McKenney 				/*  bit corresponds to a child rcu_node */
1654102adabSPaul E. McKenney 				/*  structure. */
1664102adabSPaul E. McKenney 	unsigned long expmask;	/* Groups that have ->blkd_tasks */
1674102adabSPaul E. McKenney 				/*  elements that need to drain to allow the */
1684102adabSPaul E. McKenney 				/*  current expedited grace period to */
16928f6569aSPranith Kumar 				/*  complete (only for PREEMPT_RCU). */
1704102adabSPaul E. McKenney 	unsigned long qsmaskinit;
1714102adabSPaul E. McKenney 				/* Per-GP initial value for qsmask & expmask. */
1720aa04b05SPaul E. McKenney 				/*  Initialized from ->qsmaskinitnext at the */
1730aa04b05SPaul E. McKenney 				/*  beginning of each grace period. */
1740aa04b05SPaul E. McKenney 	unsigned long qsmaskinitnext;
1750aa04b05SPaul E. McKenney 				/* Online CPUs for next grace period. */
1764102adabSPaul E. McKenney 	unsigned long grpmask;	/* Mask to apply to parent qsmask. */
1774102adabSPaul E. McKenney 				/*  Only one bit will be set in this mask. */
1784102adabSPaul E. McKenney 	int	grplo;		/* lowest-numbered CPU or group here. */
1794102adabSPaul E. McKenney 	int	grphi;		/* highest-numbered CPU or group here. */
1804102adabSPaul E. McKenney 	u8	grpnum;		/* CPU/group number for next level up. */
1814102adabSPaul E. McKenney 	u8	level;		/* root is at level 0. */
1820aa04b05SPaul E. McKenney 	bool	wait_blkd_tasks;/* Necessary to wait for blocked tasks to */
1830aa04b05SPaul E. McKenney 				/*  exit RCU read-side critical sections */
1840aa04b05SPaul E. McKenney 				/*  before propagating offline up the */
1850aa04b05SPaul E. McKenney 				/*  rcu_node tree? */
1864102adabSPaul E. McKenney 	struct rcu_node *parent;
1874102adabSPaul E. McKenney 	struct list_head blkd_tasks;
1884102adabSPaul E. McKenney 				/* Tasks blocked in RCU read-side critical */
1894102adabSPaul E. McKenney 				/*  section.  Tasks are placed at the head */
1904102adabSPaul E. McKenney 				/*  of this list and age towards the tail. */
1914102adabSPaul E. McKenney 	struct list_head *gp_tasks;
1924102adabSPaul E. McKenney 				/* Pointer to the first task blocking the */
1934102adabSPaul E. McKenney 				/*  current grace period, or NULL if there */
1944102adabSPaul E. McKenney 				/*  is no such task. */
1954102adabSPaul E. McKenney 	struct list_head *exp_tasks;
1964102adabSPaul E. McKenney 				/* Pointer to the first task blocking the */
1974102adabSPaul E. McKenney 				/*  current expedited grace period, or NULL */
1984102adabSPaul E. McKenney 				/*  if there is no such task.  If there */
1994102adabSPaul E. McKenney 				/*  is no current expedited grace period, */
2004102adabSPaul E. McKenney 				/*  then there can cannot be any such task. */
2014102adabSPaul E. McKenney 	struct list_head *boost_tasks;
2024102adabSPaul E. McKenney 				/* Pointer to first task that needs to be */
2034102adabSPaul E. McKenney 				/*  priority boosted, or NULL if no priority */
2044102adabSPaul E. McKenney 				/*  boosting is needed for this rcu_node */
2054102adabSPaul E. McKenney 				/*  structure.  If there are no tasks */
2064102adabSPaul E. McKenney 				/*  queued on this rcu_node structure that */
2074102adabSPaul E. McKenney 				/*  are blocking the current grace period, */
2084102adabSPaul E. McKenney 				/*  there can be no such task. */
209abaa93d9SPaul E. McKenney 	struct rt_mutex boost_mtx;
210abaa93d9SPaul E. McKenney 				/* Used only for the priority-boosting */
211abaa93d9SPaul E. McKenney 				/*  side effect, not as a lock. */
2124102adabSPaul E. McKenney 	unsigned long boost_time;
2134102adabSPaul E. McKenney 				/* When to start boosting (jiffies). */
2144102adabSPaul E. McKenney 	struct task_struct *boost_kthread_task;
2154102adabSPaul E. McKenney 				/* kthread that takes care of priority */
2164102adabSPaul E. McKenney 				/*  boosting for this rcu_node structure. */
2174102adabSPaul E. McKenney 	unsigned int boost_kthread_status;
2184102adabSPaul E. McKenney 				/* State of boost_kthread_task for tracing. */
2194102adabSPaul E. McKenney 	unsigned long n_tasks_boosted;
2204102adabSPaul E. McKenney 				/* Total number of tasks boosted. */
2214102adabSPaul E. McKenney 	unsigned long n_exp_boosts;
2224102adabSPaul E. McKenney 				/* Number of tasks boosted for expedited GP. */
2234102adabSPaul E. McKenney 	unsigned long n_normal_boosts;
2244102adabSPaul E. McKenney 				/* Number of tasks boosted for normal GP. */
2254102adabSPaul E. McKenney 	unsigned long n_balk_blkd_tasks;
2264102adabSPaul E. McKenney 				/* Refused to boost: no blocked tasks. */
2274102adabSPaul E. McKenney 	unsigned long n_balk_exp_gp_tasks;
2284102adabSPaul E. McKenney 				/* Refused to boost: nothing blocking GP. */
2294102adabSPaul E. McKenney 	unsigned long n_balk_boost_tasks;
2304102adabSPaul E. McKenney 				/* Refused to boost: already boosting. */
2314102adabSPaul E. McKenney 	unsigned long n_balk_notblocked;
2324102adabSPaul E. McKenney 				/* Refused to boost: RCU RS CS still running. */
2334102adabSPaul E. McKenney 	unsigned long n_balk_notyet;
2344102adabSPaul E. McKenney 				/* Refused to boost: not yet time. */
2354102adabSPaul E. McKenney 	unsigned long n_balk_nos;
2364102adabSPaul E. McKenney 				/* Refused to boost: not sure why, though. */
2374102adabSPaul E. McKenney 				/*  This can happen due to race conditions. */
2384102adabSPaul E. McKenney #ifdef CONFIG_RCU_NOCB_CPU
2394102adabSPaul E. McKenney 	wait_queue_head_t nocb_gp_wq[2];
2404102adabSPaul E. McKenney 				/* Place for rcu_nocb_kthread() to wait GP. */
2414102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
2424102adabSPaul E. McKenney 	int need_future_gp[2];
2434102adabSPaul E. McKenney 				/* Counts of upcoming no-CB GP requests. */
2444102adabSPaul E. McKenney 	raw_spinlock_t fqslock ____cacheline_internodealigned_in_smp;
245385b73c0SPaul E. McKenney 
246385b73c0SPaul E. McKenney 	struct mutex exp_funnel_mutex ____cacheline_internodealigned_in_smp;
2474102adabSPaul E. McKenney } ____cacheline_internodealigned_in_smp;
2484102adabSPaul E. McKenney 
2494102adabSPaul E. McKenney /*
2504102adabSPaul E. McKenney  * Do a full breadth-first scan of the rcu_node structures for the
2514102adabSPaul E. McKenney  * specified rcu_state structure.
2524102adabSPaul E. McKenney  */
2534102adabSPaul E. McKenney #define rcu_for_each_node_breadth_first(rsp, rnp) \
2544102adabSPaul E. McKenney 	for ((rnp) = &(rsp)->node[0]; \
2554102adabSPaul E. McKenney 	     (rnp) < &(rsp)->node[rcu_num_nodes]; (rnp)++)
2564102adabSPaul E. McKenney 
2574102adabSPaul E. McKenney /*
2584102adabSPaul E. McKenney  * Do a breadth-first scan of the non-leaf rcu_node structures for the
2594102adabSPaul E. McKenney  * specified rcu_state structure.  Note that if there is a singleton
2604102adabSPaul E. McKenney  * rcu_node tree with but one rcu_node structure, this loop is a no-op.
2614102adabSPaul E. McKenney  */
2624102adabSPaul E. McKenney #define rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) \
2634102adabSPaul E. McKenney 	for ((rnp) = &(rsp)->node[0]; \
2644102adabSPaul E. McKenney 	     (rnp) < (rsp)->level[rcu_num_lvls - 1]; (rnp)++)
2654102adabSPaul E. McKenney 
2664102adabSPaul E. McKenney /*
2674102adabSPaul E. McKenney  * Scan the leaves of the rcu_node hierarchy for the specified rcu_state
2684102adabSPaul E. McKenney  * structure.  Note that if there is a singleton rcu_node tree with but
2694102adabSPaul E. McKenney  * one rcu_node structure, this loop -will- visit the rcu_node structure.
2704102adabSPaul E. McKenney  * It is still a leaf node, even if it is also the root node.
2714102adabSPaul E. McKenney  */
2724102adabSPaul E. McKenney #define rcu_for_each_leaf_node(rsp, rnp) \
2734102adabSPaul E. McKenney 	for ((rnp) = (rsp)->level[rcu_num_lvls - 1]; \
2744102adabSPaul E. McKenney 	     (rnp) < &(rsp)->node[rcu_num_nodes]; (rnp)++)
2754102adabSPaul E. McKenney 
2764102adabSPaul E. McKenney /* Index values for nxttail array in struct rcu_data. */
2774102adabSPaul E. McKenney #define RCU_DONE_TAIL		0	/* Also RCU_WAIT head. */
2784102adabSPaul E. McKenney #define RCU_WAIT_TAIL		1	/* Also RCU_NEXT_READY head. */
2794102adabSPaul E. McKenney #define RCU_NEXT_READY_TAIL	2	/* Also RCU_NEXT head. */
2804102adabSPaul E. McKenney #define RCU_NEXT_TAIL		3
2814102adabSPaul E. McKenney #define RCU_NEXT_SIZE		4
2824102adabSPaul E. McKenney 
2834102adabSPaul E. McKenney /* Per-CPU data for read-copy update. */
2844102adabSPaul E. McKenney struct rcu_data {
2854102adabSPaul E. McKenney 	/* 1) quiescent-state and grace-period handling : */
2864102adabSPaul E. McKenney 	unsigned long	completed;	/* Track rsp->completed gp number */
2874102adabSPaul E. McKenney 					/*  in order to detect GP end. */
2884102adabSPaul E. McKenney 	unsigned long	gpnum;		/* Highest gp number that this CPU */
2894102adabSPaul E. McKenney 					/*  is aware of having started. */
2905cd37193SPaul E. McKenney 	unsigned long	rcu_qs_ctr_snap;/* Snapshot of rcu_qs_ctr to check */
2915cd37193SPaul E. McKenney 					/*  for rcu_all_qs() invocations. */
2924102adabSPaul E. McKenney 	bool		passed_quiesce;	/* User-mode/idle loop etc. */
2934102adabSPaul E. McKenney 	bool		qs_pending;	/* Core waits for quiesc state. */
2944102adabSPaul E. McKenney 	bool		beenonline;	/* CPU online at least once. */
295e3663b10SPaul E. McKenney 	bool		gpwrap;		/* Possible gpnum/completed wrap. */
2964102adabSPaul E. McKenney 	struct rcu_node *mynode;	/* This CPU's leaf of hierarchy */
2974102adabSPaul E. McKenney 	unsigned long grpmask;		/* Mask to apply to leaf qsmask. */
2984102adabSPaul E. McKenney 	unsigned long	ticks_this_gp;	/* The number of scheduling-clock */
2994102adabSPaul E. McKenney 					/*  ticks this CPU has handled */
3004102adabSPaul E. McKenney 					/*  during and after the last grace */
3014102adabSPaul E. McKenney 					/* period it is aware of. */
3023a6d7c64SPeter Zijlstra 	struct cpu_stop_work exp_stop_work;
3033a6d7c64SPeter Zijlstra 					/* Expedited grace-period control */
3043a6d7c64SPeter Zijlstra 					/*  for CPU stopping. */
3054102adabSPaul E. McKenney 
3064102adabSPaul E. McKenney 	/* 2) batch handling */
3074102adabSPaul E. McKenney 	/*
3084102adabSPaul E. McKenney 	 * If nxtlist is not NULL, it is partitioned as follows.
3094102adabSPaul E. McKenney 	 * Any of the partitions might be empty, in which case the
3104102adabSPaul E. McKenney 	 * pointer to that partition will be equal to the pointer for
3114102adabSPaul E. McKenney 	 * the following partition.  When the list is empty, all of
3124102adabSPaul E. McKenney 	 * the nxttail elements point to the ->nxtlist pointer itself,
3134102adabSPaul E. McKenney 	 * which in that case is NULL.
3144102adabSPaul E. McKenney 	 *
3154102adabSPaul E. McKenney 	 * [nxtlist, *nxttail[RCU_DONE_TAIL]):
3164102adabSPaul E. McKenney 	 *	Entries that batch # <= ->completed
3174102adabSPaul E. McKenney 	 *	The grace period for these entries has completed, and
3184102adabSPaul E. McKenney 	 *	the other grace-period-completed entries may be moved
3194102adabSPaul E. McKenney 	 *	here temporarily in rcu_process_callbacks().
3204102adabSPaul E. McKenney 	 * [*nxttail[RCU_DONE_TAIL], *nxttail[RCU_WAIT_TAIL]):
3214102adabSPaul E. McKenney 	 *	Entries that batch # <= ->completed - 1: waiting for current GP
3224102adabSPaul E. McKenney 	 * [*nxttail[RCU_WAIT_TAIL], *nxttail[RCU_NEXT_READY_TAIL]):
3234102adabSPaul E. McKenney 	 *	Entries known to have arrived before current GP ended
3244102adabSPaul E. McKenney 	 * [*nxttail[RCU_NEXT_READY_TAIL], *nxttail[RCU_NEXT_TAIL]):
3254102adabSPaul E. McKenney 	 *	Entries that might have arrived after current GP ended
3264102adabSPaul E. McKenney 	 *	Note that the value of *nxttail[RCU_NEXT_TAIL] will
3274102adabSPaul E. McKenney 	 *	always be NULL, as this is the end of the list.
3284102adabSPaul E. McKenney 	 */
3294102adabSPaul E. McKenney 	struct rcu_head *nxtlist;
3304102adabSPaul E. McKenney 	struct rcu_head **nxttail[RCU_NEXT_SIZE];
3314102adabSPaul E. McKenney 	unsigned long	nxtcompleted[RCU_NEXT_SIZE];
3324102adabSPaul E. McKenney 					/* grace periods for sublists. */
3334102adabSPaul E. McKenney 	long		qlen_lazy;	/* # of lazy queued callbacks */
3344102adabSPaul E. McKenney 	long		qlen;		/* # of queued callbacks, incl lazy */
3354102adabSPaul E. McKenney 	long		qlen_last_fqs_check;
3364102adabSPaul E. McKenney 					/* qlen at last check for QS forcing */
3374102adabSPaul E. McKenney 	unsigned long	n_cbs_invoked;	/* count of RCU cbs invoked. */
3384102adabSPaul E. McKenney 	unsigned long	n_nocbs_invoked; /* count of no-CBs RCU cbs invoked. */
3394102adabSPaul E. McKenney 	unsigned long   n_cbs_orphaned; /* RCU cbs orphaned by dying CPU */
3404102adabSPaul E. McKenney 	unsigned long   n_cbs_adopted;  /* RCU cbs adopted from dying CPU */
3414102adabSPaul E. McKenney 	unsigned long	n_force_qs_snap;
3424102adabSPaul E. McKenney 					/* did other CPU force QS recently? */
3434102adabSPaul E. McKenney 	long		blimit;		/* Upper limit on a processed batch */
3444102adabSPaul E. McKenney 
3454102adabSPaul E. McKenney 	/* 3) dynticks interface. */
3464102adabSPaul E. McKenney 	struct rcu_dynticks *dynticks;	/* Shared per-CPU dynticks state. */
3474102adabSPaul E. McKenney 	int dynticks_snap;		/* Per-GP tracking for dynticks. */
3484102adabSPaul E. McKenney 
3494102adabSPaul E. McKenney 	/* 4) reasons this CPU needed to be kicked by force_quiescent_state */
3504102adabSPaul E. McKenney 	unsigned long dynticks_fqs;	/* Kicked due to dynticks idle. */
3514102adabSPaul E. McKenney 	unsigned long offline_fqs;	/* Kicked due to being offline. */
3524a81e832SPaul E. McKenney 	unsigned long cond_resched_completed;
3534a81e832SPaul E. McKenney 					/* Grace period that needs help */
3544a81e832SPaul E. McKenney 					/*  from cond_resched(). */
3554102adabSPaul E. McKenney 
3564102adabSPaul E. McKenney 	/* 5) __rcu_pending() statistics. */
3574102adabSPaul E. McKenney 	unsigned long n_rcu_pending;	/* rcu_pending() calls since boot. */
3584102adabSPaul E. McKenney 	unsigned long n_rp_qs_pending;
3594102adabSPaul E. McKenney 	unsigned long n_rp_report_qs;
3604102adabSPaul E. McKenney 	unsigned long n_rp_cb_ready;
3614102adabSPaul E. McKenney 	unsigned long n_rp_cpu_needs_gp;
3624102adabSPaul E. McKenney 	unsigned long n_rp_gp_completed;
3634102adabSPaul E. McKenney 	unsigned long n_rp_gp_started;
36496d3fd0dSPaul E. McKenney 	unsigned long n_rp_nocb_defer_wakeup;
3654102adabSPaul E. McKenney 	unsigned long n_rp_need_nothing;
3664102adabSPaul E. McKenney 
3672cd6ffafSPaul E. McKenney 	/* 6) _rcu_barrier(), OOM callbacks, and expediting. */
3684102adabSPaul E. McKenney 	struct rcu_head barrier_head;
3694102adabSPaul E. McKenney #ifdef CONFIG_RCU_FAST_NO_HZ
3704102adabSPaul E. McKenney 	struct rcu_head oom_head;
3714102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_FAST_NO_HZ */
3722cd6ffafSPaul E. McKenney 	struct mutex exp_funnel_mutex;
373cf3620a6SPaul E. McKenney 	bool exp_done;			/* Expedited QS for this CPU? */
3744102adabSPaul E. McKenney 
3754102adabSPaul E. McKenney 	/* 7) Callback offloading. */
3764102adabSPaul E. McKenney #ifdef CONFIG_RCU_NOCB_CPU
3774102adabSPaul E. McKenney 	struct rcu_head *nocb_head;	/* CBs waiting for kthread. */
3784102adabSPaul E. McKenney 	struct rcu_head **nocb_tail;
37941050a00SPaul E. McKenney 	atomic_long_t nocb_q_count;	/* # CBs waiting for nocb */
38041050a00SPaul E. McKenney 	atomic_long_t nocb_q_count_lazy; /*  invocation (all stages). */
381fbce7497SPaul E. McKenney 	struct rcu_head *nocb_follower_head; /* CBs ready to invoke. */
382fbce7497SPaul E. McKenney 	struct rcu_head **nocb_follower_tail;
3834102adabSPaul E. McKenney 	wait_queue_head_t nocb_wq;	/* For nocb kthreads to sleep on. */
3844102adabSPaul E. McKenney 	struct task_struct *nocb_kthread;
3859fdd3bc9SPaul E. McKenney 	int nocb_defer_wakeup;		/* Defer wakeup of nocb_kthread. */
386fbce7497SPaul E. McKenney 
387fbce7497SPaul E. McKenney 	/* The following fields are used by the leader, hence own cacheline. */
388fbce7497SPaul E. McKenney 	struct rcu_head *nocb_gp_head ____cacheline_internodealigned_in_smp;
389fbce7497SPaul E. McKenney 					/* CBs waiting for GP. */
390fbce7497SPaul E. McKenney 	struct rcu_head **nocb_gp_tail;
39111ed7f93SPranith Kumar 	bool nocb_leader_sleep;		/* Is the nocb leader thread asleep? */
392fbce7497SPaul E. McKenney 	struct rcu_data *nocb_next_follower;
393fbce7497SPaul E. McKenney 					/* Next follower in wakeup chain. */
394fbce7497SPaul E. McKenney 
395fbce7497SPaul E. McKenney 	/* The following fields are used by the follower, hence new cachline. */
396fbce7497SPaul E. McKenney 	struct rcu_data *nocb_leader ____cacheline_internodealigned_in_smp;
397fbce7497SPaul E. McKenney 					/* Leader CPU takes GP-end wakeups. */
3984102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
3994102adabSPaul E. McKenney 
4004102adabSPaul E. McKenney 	/* 8) RCU CPU stall data. */
4014102adabSPaul E. McKenney 	unsigned int softirq_snap;	/* Snapshot of softirq activity. */
4024102adabSPaul E. McKenney 
4034102adabSPaul E. McKenney 	int cpu;
4044102adabSPaul E. McKenney 	struct rcu_state *rsp;
4054102adabSPaul E. McKenney };
4064102adabSPaul E. McKenney 
4074102adabSPaul E. McKenney /* Values for fqs_state field in struct rcu_state. */
4084102adabSPaul E. McKenney #define RCU_GP_IDLE		0	/* No grace period in progress. */
4094102adabSPaul E. McKenney #define RCU_GP_INIT		1	/* Grace period being initialized. */
4104102adabSPaul E. McKenney #define RCU_SAVE_DYNTICK	2	/* Need to scan dyntick state. */
4114102adabSPaul E. McKenney #define RCU_FORCE_QS		3	/* Need to force quiescent state. */
4124102adabSPaul E. McKenney #define RCU_SIGNAL_INIT		RCU_SAVE_DYNTICK
4134102adabSPaul E. McKenney 
4149fdd3bc9SPaul E. McKenney /* Values for nocb_defer_wakeup field in struct rcu_data. */
4159fdd3bc9SPaul E. McKenney #define RCU_NOGP_WAKE_NOT	0
4169fdd3bc9SPaul E. McKenney #define RCU_NOGP_WAKE		1
4179fdd3bc9SPaul E. McKenney #define RCU_NOGP_WAKE_FORCE	2
4189fdd3bc9SPaul E. McKenney 
4194102adabSPaul E. McKenney #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500))
4204102adabSPaul E. McKenney 					/* For jiffies_till_first_fqs and */
4214102adabSPaul E. McKenney 					/*  and jiffies_till_next_fqs. */
4224102adabSPaul E. McKenney 
4234102adabSPaul E. McKenney #define RCU_JIFFIES_FQS_DIV	256	/* Very large systems need more */
4244102adabSPaul E. McKenney 					/*  delay between bouts of */
4254102adabSPaul E. McKenney 					/*  quiescent-state forcing. */
4264102adabSPaul E. McKenney 
4274102adabSPaul E. McKenney #define RCU_STALL_RAT_DELAY	2	/* Allow other CPUs time to take */
4284102adabSPaul E. McKenney 					/*  at least one scheduling clock */
4294102adabSPaul E. McKenney 					/*  irq before ratting on them. */
4304102adabSPaul E. McKenney 
4314102adabSPaul E. McKenney #define rcu_wait(cond)							\
4324102adabSPaul E. McKenney do {									\
4334102adabSPaul E. McKenney 	for (;;) {							\
4344102adabSPaul E. McKenney 		set_current_state(TASK_INTERRUPTIBLE);			\
4354102adabSPaul E. McKenney 		if (cond)						\
4364102adabSPaul E. McKenney 			break;						\
4374102adabSPaul E. McKenney 		schedule();						\
4384102adabSPaul E. McKenney 	}								\
4394102adabSPaul E. McKenney 	__set_current_state(TASK_RUNNING);				\
4404102adabSPaul E. McKenney } while (0)
4414102adabSPaul E. McKenney 
4424102adabSPaul E. McKenney /*
4434102adabSPaul E. McKenney  * RCU global state, including node hierarchy.  This hierarchy is
4444102adabSPaul E. McKenney  * represented in "heap" form in a dense array.  The root (first level)
4454102adabSPaul E. McKenney  * of the hierarchy is in ->node[0] (referenced by ->level[0]), the second
4464102adabSPaul E. McKenney  * level in ->node[1] through ->node[m] (->node[1] referenced by ->level[1]),
4474102adabSPaul E. McKenney  * and the third level in ->node[m+1] and following (->node[m+1] referenced
4484102adabSPaul E. McKenney  * by ->level[2]).  The number of levels is determined by the number of
4494102adabSPaul E. McKenney  * CPUs and by CONFIG_RCU_FANOUT.  Small systems will have a "hierarchy"
4504102adabSPaul E. McKenney  * consisting of a single rcu_node.
4514102adabSPaul E. McKenney  */
4524102adabSPaul E. McKenney struct rcu_state {
4534102adabSPaul E. McKenney 	struct rcu_node node[NUM_RCU_NODES];	/* Hierarchy. */
454032dfc87SAlexander Gordeev 	struct rcu_node *level[RCU_NUM_LVLS + 1];
455032dfc87SAlexander Gordeev 						/* Hierarchy levels (+1 to */
456032dfc87SAlexander Gordeev 						/*  shut bogus gcc warning) */
4574a81e832SPaul E. McKenney 	u8 flavor_mask;				/* bit in flavor mask. */
4584102adabSPaul E. McKenney 	struct rcu_data __percpu *rda;		/* pointer of percu rcu_data. */
4594102adabSPaul E. McKenney 	void (*call)(struct rcu_head *head,	/* call_rcu() flavor. */
4604102adabSPaul E. McKenney 		     void (*func)(struct rcu_head *head));
4614102adabSPaul E. McKenney 
4624102adabSPaul E. McKenney 	/* The following fields are guarded by the root rcu_node's lock. */
4634102adabSPaul E. McKenney 
4644102adabSPaul E. McKenney 	u8	fqs_state ____cacheline_internodealigned_in_smp;
4654102adabSPaul E. McKenney 						/* Force QS state. */
4664102adabSPaul E. McKenney 	u8	boost;				/* Subject to priority boost. */
4674102adabSPaul E. McKenney 	unsigned long gpnum;			/* Current gp number. */
4684102adabSPaul E. McKenney 	unsigned long completed;		/* # of last completed gp. */
4694102adabSPaul E. McKenney 	struct task_struct *gp_kthread;		/* Task for grace periods. */
4704102adabSPaul E. McKenney 	wait_queue_head_t gp_wq;		/* Where GP task waits. */
471afea227fSPaul E. McKenney 	short gp_flags;				/* Commands for GP task. */
472afea227fSPaul E. McKenney 	short gp_state;				/* GP kthread sleep state. */
4734102adabSPaul E. McKenney 
4744102adabSPaul E. McKenney 	/* End of fields guarded by root rcu_node's lock. */
4754102adabSPaul E. McKenney 
4764102adabSPaul E. McKenney 	raw_spinlock_t orphan_lock ____cacheline_internodealigned_in_smp;
4774102adabSPaul E. McKenney 						/* Protect following fields. */
4784102adabSPaul E. McKenney 	struct rcu_head *orphan_nxtlist;	/* Orphaned callbacks that */
4794102adabSPaul E. McKenney 						/*  need a grace period. */
4804102adabSPaul E. McKenney 	struct rcu_head **orphan_nxttail;	/* Tail of above. */
4814102adabSPaul E. McKenney 	struct rcu_head *orphan_donelist;	/* Orphaned callbacks that */
4824102adabSPaul E. McKenney 						/*  are ready to invoke. */
4834102adabSPaul E. McKenney 	struct rcu_head **orphan_donetail;	/* Tail of above. */
4844102adabSPaul E. McKenney 	long qlen_lazy;				/* Number of lazy callbacks. */
4854102adabSPaul E. McKenney 	long qlen;				/* Total number of callbacks. */
4864102adabSPaul E. McKenney 	/* End of fields guarded by orphan_lock. */
4874102adabSPaul E. McKenney 
4884102adabSPaul E. McKenney 	struct mutex barrier_mutex;		/* Guards barrier fields. */
4894102adabSPaul E. McKenney 	atomic_t barrier_cpu_count;		/* # CPUs waiting on. */
4904102adabSPaul E. McKenney 	struct completion barrier_completion;	/* Wake at barrier end. */
4914f525a52SPaul E. McKenney 	unsigned long barrier_sequence;		/* ++ at start and end of */
4924102adabSPaul E. McKenney 						/*  _rcu_barrier(). */
4934102adabSPaul E. McKenney 	/* End of fields guarded by barrier_mutex. */
4944102adabSPaul E. McKenney 
495d6ada2cfSPaul E. McKenney 	unsigned long expedited_sequence;	/* Take a ticket. */
496*cdacbe1fSPaul E. McKenney 	atomic_long_t expedited_workdone0;	/* # done by others #0. */
4974102adabSPaul E. McKenney 	atomic_long_t expedited_workdone1;	/* # done by others #1. */
4984102adabSPaul E. McKenney 	atomic_long_t expedited_workdone2;	/* # done by others #2. */
4992cd6ffafSPaul E. McKenney 	atomic_long_t expedited_workdone3;	/* # done by others #3. */
5004102adabSPaul E. McKenney 	atomic_long_t expedited_normal;		/* # fallbacks to normal. */
5013a6d7c64SPeter Zijlstra 	atomic_t expedited_need_qs;		/* # CPUs left to check in. */
5023a6d7c64SPeter Zijlstra 	wait_queue_head_t expedited_wq;		/* Wait for check-ins. */
5034102adabSPaul E. McKenney 
5044102adabSPaul E. McKenney 	unsigned long jiffies_force_qs;		/* Time at which to invoke */
5054102adabSPaul E. McKenney 						/*  force_quiescent_state(). */
5064102adabSPaul E. McKenney 	unsigned long n_force_qs;		/* Number of calls to */
5074102adabSPaul E. McKenney 						/*  force_quiescent_state(). */
5084102adabSPaul E. McKenney 	unsigned long n_force_qs_lh;		/* ~Number of calls leaving */
5094102adabSPaul E. McKenney 						/*  due to lock unavailable. */
5104102adabSPaul E. McKenney 	unsigned long n_force_qs_ngp;		/* Number of calls leaving */
5114102adabSPaul E. McKenney 						/*  due to no GP active. */
5124102adabSPaul E. McKenney 	unsigned long gp_start;			/* Time at which GP started, */
5134102adabSPaul E. McKenney 						/*  but in jiffies. */
5146ccd2ecdSPaul E. McKenney 	unsigned long gp_activity;		/* Time of last GP kthread */
5156ccd2ecdSPaul E. McKenney 						/*  activity in jiffies. */
5164102adabSPaul E. McKenney 	unsigned long jiffies_stall;		/* Time at which to check */
5174102adabSPaul E. McKenney 						/*  for CPU stalls. */
5186193c76aSPaul E. McKenney 	unsigned long jiffies_resched;		/* Time at which to resched */
5196193c76aSPaul E. McKenney 						/*  a reluctant CPU. */
520fc908ed3SPaul E. McKenney 	unsigned long n_force_qs_gpstart;	/* Snapshot of n_force_qs at */
521fc908ed3SPaul E. McKenney 						/*  GP start. */
5224102adabSPaul E. McKenney 	unsigned long gp_max;			/* Maximum GP duration in */
5234102adabSPaul E. McKenney 						/*  jiffies. */
5244102adabSPaul E. McKenney 	const char *name;			/* Name of structure. */
5254102adabSPaul E. McKenney 	char abbr;				/* Abbreviated name. */
5264102adabSPaul E. McKenney 	struct list_head flavors;		/* List of RCU flavors. */
5274102adabSPaul E. McKenney };
5284102adabSPaul E. McKenney 
5294102adabSPaul E. McKenney /* Values for rcu_state structure's gp_flags field. */
5304102adabSPaul E. McKenney #define RCU_GP_FLAG_INIT 0x1	/* Need grace-period initialization. */
5314102adabSPaul E. McKenney #define RCU_GP_FLAG_FQS  0x2	/* Need grace-period quiescent-state forcing. */
5324102adabSPaul E. McKenney 
533afea227fSPaul E. McKenney /* Values for rcu_state structure's gp_flags field. */
534afea227fSPaul E. McKenney #define RCU_GP_WAIT_INIT 0	/* Initial state. */
535afea227fSPaul E. McKenney #define RCU_GP_WAIT_GPS  1	/* Wait for grace-period start. */
536319362c9SPaul E. McKenney #define RCU_GP_DONE_GPS  2	/* Wait done for grace-period start. */
537319362c9SPaul E. McKenney #define RCU_GP_WAIT_FQS  3	/* Wait for force-quiescent-state time. */
53832bb1c79SPaul E. McKenney #define RCU_GP_DOING_FQS 4	/* Wait done for force-quiescent-state time. */
539319362c9SPaul E. McKenney #define RCU_GP_CLEANUP   5	/* Grace-period cleanup started. */
540319362c9SPaul E. McKenney #define RCU_GP_CLEANED   6	/* Grace-period cleanup complete. */
541afea227fSPaul E. McKenney 
5424102adabSPaul E. McKenney extern struct list_head rcu_struct_flavors;
5434102adabSPaul E. McKenney 
5444102adabSPaul E. McKenney /* Sequence through rcu_state structures for each RCU flavor. */
5454102adabSPaul E. McKenney #define for_each_rcu_flavor(rsp) \
5464102adabSPaul E. McKenney 	list_for_each_entry((rsp), &rcu_struct_flavors, flavors)
5474102adabSPaul E. McKenney 
5484102adabSPaul E. McKenney /*
5494102adabSPaul E. McKenney  * RCU implementation internal declarations:
5504102adabSPaul E. McKenney  */
5514102adabSPaul E. McKenney extern struct rcu_state rcu_sched_state;
5524102adabSPaul E. McKenney 
5534102adabSPaul E. McKenney extern struct rcu_state rcu_bh_state;
5544102adabSPaul E. McKenney 
55528f6569aSPranith Kumar #ifdef CONFIG_PREEMPT_RCU
5564102adabSPaul E. McKenney extern struct rcu_state rcu_preempt_state;
55728f6569aSPranith Kumar #endif /* #ifdef CONFIG_PREEMPT_RCU */
5584102adabSPaul E. McKenney 
5594102adabSPaul E. McKenney #ifdef CONFIG_RCU_BOOST
5604102adabSPaul E. McKenney DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_status);
5614102adabSPaul E. McKenney DECLARE_PER_CPU(int, rcu_cpu_kthread_cpu);
5624102adabSPaul E. McKenney DECLARE_PER_CPU(unsigned int, rcu_cpu_kthread_loops);
5634102adabSPaul E. McKenney DECLARE_PER_CPU(char, rcu_cpu_has_work);
5644102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_BOOST */
5654102adabSPaul E. McKenney 
5664102adabSPaul E. McKenney #ifndef RCU_TREE_NONCORE
5674102adabSPaul E. McKenney 
5684102adabSPaul E. McKenney /* Forward declarations for rcutree_plugin.h */
5694102adabSPaul E. McKenney static void rcu_bootup_announce(void);
57038200cf2SPaul E. McKenney static void rcu_preempt_note_context_switch(void);
5714102adabSPaul E. McKenney static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp);
5724102adabSPaul E. McKenney #ifdef CONFIG_HOTPLUG_CPU
5738af3a5e7SPaul E. McKenney static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
5744102adabSPaul E. McKenney #endif /* #ifdef CONFIG_HOTPLUG_CPU */
5754102adabSPaul E. McKenney static void rcu_print_detail_task_stall(struct rcu_state *rsp);
5764102adabSPaul E. McKenney static int rcu_print_task_stall(struct rcu_node *rnp);
5774102adabSPaul E. McKenney static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp);
57886aea0e6SPaul E. McKenney static void rcu_preempt_check_callbacks(void);
5794102adabSPaul E. McKenney void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu));
5804102adabSPaul E. McKenney static void __init __rcu_init_preempt(void);
5814102adabSPaul E. McKenney static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
5824102adabSPaul E. McKenney static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
5834102adabSPaul E. McKenney static void invoke_rcu_callbacks_kthread(void);
5844102adabSPaul E. McKenney static bool rcu_is_callbacks_kthread(void);
5854102adabSPaul E. McKenney #ifdef CONFIG_RCU_BOOST
5864102adabSPaul E. McKenney static void rcu_preempt_do_callbacks(void);
5874102adabSPaul E. McKenney static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
5884102adabSPaul E. McKenney 						 struct rcu_node *rnp);
5894102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_BOOST */
5909386c0b7SPaul E. McKenney static void __init rcu_spawn_boost_kthreads(void);
5914102adabSPaul E. McKenney static void rcu_prepare_kthreads(int cpu);
5928fa7845dSPaul E. McKenney static void rcu_cleanup_after_idle(void);
593198bbf81SPaul E. McKenney static void rcu_prepare_for_idle(void);
5944102adabSPaul E. McKenney static void rcu_idle_count_callbacks_posted(void);
5950aa04b05SPaul E. McKenney static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
5964102adabSPaul E. McKenney static void print_cpu_stall_info_begin(void);
5974102adabSPaul E. McKenney static void print_cpu_stall_info(struct rcu_state *rsp, int cpu);
5984102adabSPaul E. McKenney static void print_cpu_stall_info_end(void);
5994102adabSPaul E. McKenney static void zero_cpu_stall_ticks(struct rcu_data *rdp);
6004102adabSPaul E. McKenney static void increment_cpu_stall_ticks(void);
601d7e29933SPaul E. McKenney static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu);
6024102adabSPaul E. McKenney static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq);
6034102adabSPaul E. McKenney static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp);
6044102adabSPaul E. McKenney static void rcu_init_one_nocb(struct rcu_node *rnp);
6054102adabSPaul E. McKenney static bool __call_rcu_nocb(struct rcu_data *rdp, struct rcu_head *rhp,
60696d3fd0dSPaul E. McKenney 			    bool lazy, unsigned long flags);
6074102adabSPaul E. McKenney static bool rcu_nocb_adopt_orphan_cbs(struct rcu_state *rsp,
60896d3fd0dSPaul E. McKenney 				      struct rcu_data *rdp,
60996d3fd0dSPaul E. McKenney 				      unsigned long flags);
6109fdd3bc9SPaul E. McKenney static int rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp);
61196d3fd0dSPaul E. McKenney static void do_nocb_deferred_wakeup(struct rcu_data *rdp);
6124102adabSPaul E. McKenney static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp);
61335ce7f29SPaul E. McKenney static void rcu_spawn_all_nocb_kthreads(int cpu);
61435ce7f29SPaul E. McKenney static void __init rcu_spawn_nocb_kthreads(void);
61535ce7f29SPaul E. McKenney #ifdef CONFIG_RCU_NOCB_CPU
61635ce7f29SPaul E. McKenney static void __init rcu_organize_nocb_kthreads(struct rcu_state *rsp);
61735ce7f29SPaul E. McKenney #endif /* #ifdef CONFIG_RCU_NOCB_CPU */
6184a81e832SPaul E. McKenney static void __maybe_unused rcu_kick_nohz_cpu(int cpu);
6194102adabSPaul E. McKenney static bool init_nocb_callback_list(struct rcu_data *rdp);
62028ced795SChristoph Lameter static void rcu_sysidle_enter(int irq);
62128ced795SChristoph Lameter static void rcu_sysidle_exit(int irq);
6224102adabSPaul E. McKenney static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
6234102adabSPaul E. McKenney 				  unsigned long *maxj);
6244102adabSPaul E. McKenney static bool is_sysidle_rcu_state(struct rcu_state *rsp);
6254102adabSPaul E. McKenney static void rcu_sysidle_report_gp(struct rcu_state *rsp, int isidle,
6264102adabSPaul E. McKenney 				  unsigned long maxj);
6274102adabSPaul E. McKenney static void rcu_bind_gp_kthread(void);
6284102adabSPaul E. McKenney static void rcu_sysidle_init_percpu_data(struct rcu_dynticks *rdtp);
629a096932fSPaul E. McKenney static bool rcu_nohz_full_cpu(struct rcu_state *rsp);
630176f8f7aSPaul E. McKenney static void rcu_dynticks_task_enter(void);
631176f8f7aSPaul E. McKenney static void rcu_dynticks_task_exit(void);
6324102adabSPaul E. McKenney 
6334102adabSPaul E. McKenney #endif /* #ifndef RCU_TREE_NONCORE */
6344102adabSPaul E. McKenney 
6354102adabSPaul E. McKenney #ifdef CONFIG_RCU_TRACE
63641050a00SPaul E. McKenney /* Read out queue lengths for tracing. */
63741050a00SPaul E. McKenney static inline void rcu_nocb_q_lengths(struct rcu_data *rdp, long *ql, long *qll)
63841050a00SPaul E. McKenney {
6394102adabSPaul E. McKenney #ifdef CONFIG_RCU_NOCB_CPU
64041050a00SPaul E. McKenney 	*ql = atomic_long_read(&rdp->nocb_q_count);
64141050a00SPaul E. McKenney 	*qll = atomic_long_read(&rdp->nocb_q_count_lazy);
6424102adabSPaul E. McKenney #else /* #ifdef CONFIG_RCU_NOCB_CPU */
6434102adabSPaul E. McKenney 	*ql = 0;
6444102adabSPaul E. McKenney 	*qll = 0;
6454102adabSPaul E. McKenney #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */
64641050a00SPaul E. McKenney }
6474102adabSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TRACE */
648