hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/include/linux/srcutiny.h
....@@ -1,24 +1,11 @@
1
+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * Sleepable Read-Copy Update mechanism for mutual exclusion,
34 * tiny variant.
45 *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, you can access it online at
17
- * http://www.gnu.org/licenses/gpl-2.0.html.
18
- *
196 * Copyright (C) IBM Corporation, 2017
207 *
21
- * Author: Paul McKenney <paulmck@us.ibm.com>
8
+ * Author: Paul McKenney <paulmck@linux.ibm.com>
229 */
2310
2411 #ifndef _LINUX_SRCU_TINY_H
....@@ -28,7 +15,8 @@
2815
2916 struct srcu_struct {
3017 short srcu_lock_nesting[2]; /* srcu_read_lock() nesting depth. */
31
- short srcu_idx; /* Current reader array element. */
18
+ unsigned short srcu_idx; /* Current reader array element in bit 0x2. */
19
+ unsigned short srcu_idx_max; /* Furthest future srcu_idx request. */
3220 u8 srcu_gp_running; /* GP workqueue running? */
3321 u8 srcu_gp_waiting; /* GP waiting for readers? */
3422 struct swait_queue_head srcu_wq;
....@@ -60,7 +48,7 @@
6048 #define DEFINE_STATIC_SRCU(name) \
6149 static struct srcu_struct name = __SRCU_STRUCT_INIT(name, name)
6250
63
-void synchronize_srcu(struct srcu_struct *sp);
51
+void synchronize_srcu(struct srcu_struct *ssp);
6452
6553 /*
6654 * Counts the new reader in the appropriate per-CPU element of the
....@@ -68,36 +56,36 @@
6856 * __srcu_read_unlock() must be in the same handler instance. Returns an
6957 * index that must be passed to the matching srcu_read_unlock().
7058 */
71
-static inline int __srcu_read_lock(struct srcu_struct *sp)
59
+static inline int __srcu_read_lock(struct srcu_struct *ssp)
7260 {
7361 int idx;
7462
75
- idx = READ_ONCE(sp->srcu_idx);
76
- WRITE_ONCE(sp->srcu_lock_nesting[idx], sp->srcu_lock_nesting[idx] + 1);
63
+ idx = ((READ_ONCE(ssp->srcu_idx) + 1) & 0x2) >> 1;
64
+ WRITE_ONCE(ssp->srcu_lock_nesting[idx], ssp->srcu_lock_nesting[idx] + 1);
7765 return idx;
7866 }
7967
80
-static inline void synchronize_srcu_expedited(struct srcu_struct *sp)
68
+static inline void synchronize_srcu_expedited(struct srcu_struct *ssp)
8169 {
82
- synchronize_srcu(sp);
70
+ synchronize_srcu(ssp);
8371 }
8472
85
-static inline void srcu_barrier(struct srcu_struct *sp)
73
+static inline void srcu_barrier(struct srcu_struct *ssp)
8674 {
87
- synchronize_srcu(sp);
75
+ synchronize_srcu(ssp);
8876 }
8977
9078 /* Defined here to avoid size increase for non-torture kernels. */
91
-static inline void srcu_torture_stats_print(struct srcu_struct *sp,
79
+static inline void srcu_torture_stats_print(struct srcu_struct *ssp,
9280 char *tt, char *tf)
9381 {
9482 int idx;
9583
96
- idx = READ_ONCE(sp->srcu_idx) & 0x1;
84
+ idx = ((READ_ONCE(ssp->srcu_idx) + 1) & 0x2) >> 1;
9785 pr_alert("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd)\n",
9886 tt, tf, idx,
99
- READ_ONCE(sp->srcu_lock_nesting[!idx]),
100
- READ_ONCE(sp->srcu_lock_nesting[idx]));
87
+ READ_ONCE(ssp->srcu_lock_nesting[!idx]),
88
+ READ_ONCE(ssp->srcu_lock_nesting[idx]));
10189 }
10290
10391 #endif