rcu.h (e95d68d2127716c7d6fb144bb19ef48ce9f37393) rcu.h (031aeee000e895247eafa4233c2d193dd39d4ea2)
1/*
2 * Read-Copy Update definitions shared among RCU implementations.
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 *

--- 47 unchanged lines hidden (view full) ---

56#define DYNTICK_TASK_EXIT_IDLE (DYNTICK_TASK_NEST_VALUE + \
57 DYNTICK_TASK_FLAG)
58
59
60/*
61 * Grace-period counter management.
62 */
63
1/*
2 * Read-Copy Update definitions shared among RCU implementations.
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 *

--- 47 unchanged lines hidden (view full) ---

56#define DYNTICK_TASK_EXIT_IDLE (DYNTICK_TASK_NEST_VALUE + \
57 DYNTICK_TASK_FLAG)
58
59
60/*
61 * Grace-period counter management.
62 */
63
64#define RCU_SEQ_CTR_SHIFT 1
65#define RCU_SEQ_STATE_MASK ((1 << RCU_SEQ_CTR_SHIFT) - 1)
66
67/*
68 * Return the counter portion of a sequence number previously returned
69 * by rcu_seq_snap() or rcu_seq_current().
70 */
71static inline unsigned long rcu_seq_ctr(unsigned long s)
72{
73 return s >> RCU_SEQ_CTR_SHIFT;
74}
75
76/*
77 * Return the state portion of a sequence number previously returned
78 * by rcu_seq_snap() or rcu_seq_current().
79 */
80static inline int rcu_seq_state(unsigned long s)
81{
82 return s & RCU_SEQ_STATE_MASK;
83}
84
64/* Adjust sequence number for start of update-side operation. */
65static inline void rcu_seq_start(unsigned long *sp)
66{
67 WRITE_ONCE(*sp, *sp + 1);
68 smp_mb(); /* Ensure update-side operation after counter increment. */
85/* Adjust sequence number for start of update-side operation. */
86static inline void rcu_seq_start(unsigned long *sp)
87{
88 WRITE_ONCE(*sp, *sp + 1);
89 smp_mb(); /* Ensure update-side operation after counter increment. */
69 WARN_ON_ONCE(!(*sp & 0x1));
90 WARN_ON_ONCE(rcu_seq_state(*sp) != 1);
70}
71
72/* Adjust sequence number for end of update-side operation. */
73static inline void rcu_seq_end(unsigned long *sp)
74{
75 smp_mb(); /* Ensure update-side operation before counter increment. */
91}
92
93/* Adjust sequence number for end of update-side operation. */
94static inline void rcu_seq_end(unsigned long *sp)
95{
96 smp_mb(); /* Ensure update-side operation before counter increment. */
76 WARN_ON_ONCE(!(*sp & 0x1));
77 WRITE_ONCE(*sp, *sp + 1);
97 WARN_ON_ONCE(!rcu_seq_state(*sp));
98 WRITE_ONCE(*sp, (*sp | RCU_SEQ_STATE_MASK) + 1);
78}
79
80/* Take a snapshot of the update side's sequence number. */
81static inline unsigned long rcu_seq_snap(unsigned long *sp)
82{
83 unsigned long s;
84
99}
100
101/* Take a snapshot of the update side's sequence number. */
102static inline unsigned long rcu_seq_snap(unsigned long *sp)
103{
104 unsigned long s;
105
85 s = (READ_ONCE(*sp) + 3) & ~0x1;
106 s = (READ_ONCE(*sp) + 2 * RCU_SEQ_STATE_MASK + 1) & ~RCU_SEQ_STATE_MASK;
86 smp_mb(); /* Above access must not bleed into critical section. */
87 return s;
88}
89
90/* Return the current value the update side's sequence number, no ordering. */
91static inline unsigned long rcu_seq_current(unsigned long *sp)
92{
93 return READ_ONCE(*sp);

--- 172 unchanged lines hidden ---
107 smp_mb(); /* Above access must not bleed into critical section. */
108 return s;
109}
110
111/* Return the current value the update side's sequence number, no ordering. */
112static inline unsigned long rcu_seq_current(unsigned long *sp)
113{
114 return READ_ONCE(*sp);

--- 172 unchanged lines hidden ---