Lines Matching +full:hardware +full:- +full:protected
17 (prefix "*"), field selection ("->"), assignment ("="), address-of
27 - You must use one of the rcu_dereference() family of primitives
28 to load an RCU-protected pointer, otherwise CONFIG_PROVE_RCU
29 will complain. Worse yet, your code can see random memory-corruption
45 - In the special case where data is added but is never removed
51 - You are only permitted to use rcu_dereference() on pointer values.
57 - Set bits and clear bits down in the must-be-zero low-order
62 - XOR bits to translate pointers, as is done in some
63 classic buddy-allocator algorithms.
68 - Avoid cancellation when using the "+" and "-" infix arithmetic
70 "(x-(uintptr_t)x)" for char* pointers. The compiler is within its
77 "p+a-b" is safe because its value still necessarily depends on
80 - If you are using RCU to protect JITed functions, so that the
81 "()" function-invocation operator is applied to a value obtained
83 interact directly with the hardware to flush instruction caches.
87 - Do not use the results from relational operators ("==", "!=",
103 weak-memory machines such as ARM or PowerPC do order stores
107 - Be very careful about comparing pointers obtained from
108 rcu_dereference() against non-NULL values. As Linus Torvalds
115 do_default(p->a);
125 On ARM and Power hardware, the load from "default_struct.a"
131 - The comparison was against the NULL pointer. If the
134 non-equal, the compiler is none the wiser. Therefore,
138 - The pointer is never dereferenced after being compared.
141 to reorder the non-existent subsequent dereferences.
143 RCU-protected circular linked lists.
146 of an RCU read-side critical section, and the pointer
153 Within an RCU read-side critical section, there is little
156 - The comparison is against a pointer that references memory
163 - Compile time.
165 - Boot time.
167 - Module-init time for module code.
169 - Prior to kthread creation for kthread code.
171 - During some prior acquisition of the lock that
174 - Before mod_timer() time for a timer handler.
180 - The pointer being compared against also came from
189 "EXAMPLE OF AMPLIFIED RCU-USAGE BUG".
191 - All of the accesses following the comparison are stores,
195 Documentation/memory-barriers.txt for more details.
197 - The pointers are not equal *and* the compiler does
203 pointer takes on only one of two values, a not-equal
207 - Disable any value-speculation optimizations that your compiler
208 might provide, especially if you are making use of feedback-based
210 value-speculation optimizations reorder operations by design.
212 There is one exception to this rule: Value-speculation
213 optimizations that leverage the branch-prediction hardware are
216 command-line options wisely!
219 EXAMPLE OF AMPLIFIED RCU-USAGE BUG
220 ----------------------------------
242 p->a = 42; /* Each field in its own cache line. */
243 p->b = 43;
244 p->c = 44;
246 p->b = 143;
247 p->c = 144;
261 r1 = p->b; /* Guaranteed to get 143. */
262 q = rcu_dereference(gp1); /* Guaranteed non-NULL. */
264 /* The compiler decides that q->c is same as p->c. */
265 r2 = p->c; /* Could get 44 on weakly order system. */
267 r2 = p->c - r1; /* Unconditional access to p->c. */
299 spin_lock(&p->lock);
300 p->a = 42; /* Each field in its own cache line. */
301 p->b = 43;
302 p->c = 44;
303 spin_unlock(&p->lock);
305 spin_lock(&p->lock);
306 p->b = 143;
307 p->c = 144;
308 spin_unlock(&p->lock);
322 spin_lock(&p->lock);
323 r1 = p->b; /* Guaranteed to get 143. */
324 q = rcu_dereference(gp1); /* Guaranteed non-NULL. */
326 /* The compiler decides that q->c is same as p->c. */
327 r2 = p->c; /* Locking guarantees r2 == 144. */
329 spin_lock(&q->lock);
330 r2 = q->c - r1;
331 spin_unlock(&q->lock);
334 spin_unlock(&p->lock);
342 -----------------------------------------
344 If a pointer obtained from rcu_dereference() compares not-equal to some
379 return p->a; /* Must be variable1.a. */
381 return p->b; /* Must be variable2.b. */
387 the exact value of "p" even in the not-equals case. This allows the
390 return values. This can result in "p->b" returning pre-initialization
398 ------------------------------------------------------------
406 1. If the access needs to be within an RCU read-side critical
408 RCU flavors, an RCU read-side critical section is entered
412 are also implied RCU read-side critical sections, even when
416 2. If the access might be within an RCU read-side critical section
417 on the one hand, or protected by (say) my_lock on the other,
420 p1 = rcu_dereference_check(p->rcu_protected_pointer,
424 3. If the access might be within an RCU read-side critical section
425 on the one hand, or protected by either my_lock or your_lock on
428 p1 = rcu_dereference_check(p->rcu_protected_pointer,
432 4. If the access is on the update side, so that it is always protected
435 p1 = rcu_dereference_protected(p->rcu_protected_pointer,
447 there are data-locking cases where any one of a very large number
457 SPARSE CHECKING OF RCU-PROTECTED POINTERS
458 -----------------------------------------
460 The sparse static-analysis tool checks for non-RCU access to RCU-protected
465 p = q->rcu_protected_pointer;
466 do_something_with(p->a);
467 do_something_else_with(p->b);
472 do_something_with(q->rcu_protected_pointer->a);
473 do_something_else_with(q->rcu_protected_pointer->b);
475 This could fatally disappoint your code if q->rcu_protected_pointer
478 colleagues) a three-day weekend back in the early 1990s.
486 p = rcu_dereference(q->rcu_protected_pointer);
487 do_something_with(p->a);
488 do_something_else_with(p->b);
496 and friends. For example, ->rcu_protected_pointer might be declared as
501 Use of "__rcu" is opt-in. If you choose not to use it, then you should