]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/linux/rcu_segcblist.h
Merge branches 'pm-cpufreq', 'pm-cpuidle' and 'pm-devfreq'
[karo-tx-linux.git] / include / linux / rcu_segcblist.h
1 /*
2  * RCU segmented callback lists
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, you can access it online at
16  * http://www.gnu.org/licenses/gpl-2.0.html.
17  *
18  * Copyright IBM Corporation, 2017
19  *
20  * Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
21  */
22
23 #ifndef __INCLUDE_LINUX_RCU_SEGCBLIST_H
24 #define __INCLUDE_LINUX_RCU_SEGCBLIST_H
25
26 /* Simple unsegmented callback lists. */
27 struct rcu_cblist {
28         struct rcu_head *head;
29         struct rcu_head **tail;
30         long len;
31         long len_lazy;
32 };
33
34 #define RCU_CBLIST_INITIALIZER(n) { .head = NULL, .tail = &n.head }
35
36 /* Complicated segmented callback lists.  ;-) */
37
38 /*
39  * Index values for segments in rcu_segcblist structure.
40  *
41  * The segments are as follows:
42  *
43  * [head, *tails[RCU_DONE_TAIL]):
44  *      Callbacks whose grace period has elapsed, and thus can be invoked.
45  * [*tails[RCU_DONE_TAIL], *tails[RCU_WAIT_TAIL]):
46  *      Callbacks waiting for the current GP from the current CPU's viewpoint.
47  * [*tails[RCU_WAIT_TAIL], *tails[RCU_NEXT_READY_TAIL]):
48  *      Callbacks that arrived before the next GP started, again from
49  *      the current CPU's viewpoint.  These can be handled by the next GP.
50  * [*tails[RCU_NEXT_READY_TAIL], *tails[RCU_NEXT_TAIL]):
51  *      Callbacks that might have arrived after the next GP started.
52  *      There is some uncertainty as to when a given GP starts and
53  *      ends, but a CPU knows the exact times if it is the one starting
54  *      or ending the GP.  Other CPUs know that the previous GP ends
55  *      before the next one starts.
56  *
57  * Note that RCU_WAIT_TAIL cannot be empty unless RCU_NEXT_READY_TAIL is also
58  * empty.
59  *
60  * The ->gp_seq[] array contains the grace-period number at which the
61  * corresponding segment of callbacks will be ready to invoke.  A given
62  * element of this array is meaningful only when the corresponding segment
63  * is non-empty, and it is never valid for RCU_DONE_TAIL (whose callbacks
64  * are already ready to invoke) or for RCU_NEXT_TAIL (whose callbacks have
65  * not yet been assigned a grace-period number).
66  */
67 #define RCU_DONE_TAIL           0       /* Also RCU_WAIT head. */
68 #define RCU_WAIT_TAIL           1       /* Also RCU_NEXT_READY head. */
69 #define RCU_NEXT_READY_TAIL     2       /* Also RCU_NEXT head. */
70 #define RCU_NEXT_TAIL           3
71 #define RCU_CBLIST_NSEGS        4
72
73 struct rcu_segcblist {
74         struct rcu_head *head;
75         struct rcu_head **tails[RCU_CBLIST_NSEGS];
76         unsigned long gp_seq[RCU_CBLIST_NSEGS];
77         long len;
78         long len_lazy;
79 };
80
81 #define RCU_SEGCBLIST_INITIALIZER(n) \
82 { \
83         .head = NULL, \
84         .tails[RCU_DONE_TAIL] = &n.head, \
85         .tails[RCU_WAIT_TAIL] = &n.head, \
86         .tails[RCU_NEXT_READY_TAIL] = &n.head, \
87         .tails[RCU_NEXT_TAIL] = &n.head, \
88 }
89
90 #endif /* __INCLUDE_LINUX_RCU_SEGCBLIST_H */