2 * RCU segmented callback lists
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.
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.
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.
18 * Copyright IBM Corporation, 2017
20 * Authors: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
23 #ifndef __INCLUDE_LINUX_RCU_SEGCBLIST_H
24 #define __INCLUDE_LINUX_RCU_SEGCBLIST_H
26 /* Simple unsegmented callback lists. */
28 struct rcu_head *head;
29 struct rcu_head **tail;
34 #define RCU_CBLIST_INITIALIZER(n) { .head = NULL, .tail = &n.head }
36 /* Complicated segmented callback lists. ;-) */
39 * Index values for segments in rcu_segcblist structure.
41 * The segments are as follows:
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.
57 * Note that RCU_WAIT_TAIL cannot be empty unless RCU_NEXT_READY_TAIL is also
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).
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
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];
81 #define RCU_SEGCBLIST_INITIALIZER(n) \
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, \
90 #endif /* __INCLUDE_LINUX_RCU_SEGCBLIST_H */