There is a need for a polling interface for SRCU grace periods. This polling needs to distinguish between an SRCU instance being idle on the one hand or in the middle of a grace period on the other. This commit therefore converts the Tiny SRCU srcu_struct structure's srcu_idx from a defacto boolean to a free-running counter, using the bottom bit to indicate that a grace period is in progress. The second-from-bottom bit is thus used as the index returned by srcu_read_lock().
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -124,11 +124,12 @@ void srcu_drive_gp(struct work_struct *wp) · 123 unmodified lines | |||
| 124 | ssp->srcu_cb_head = NULL; | 124 | ssp->srcu_cb_head = NULL; |
| 125 | ssp->srcu_cb_tail = &ssp->srcu_cb_head; | 125 | ssp->srcu_cb_tail = &ssp->srcu_cb_head; |
| 126 | local_irq_enable(); | 126 | local_irq_enable(); |
| 127 | idx = ssp->srcu_idx; | 127 | idx = (ssp->srcu_idx & 0x2) / 2; |
| 128 | WRITE_ONCE(ssp->srcu_idx, !ssp->srcu_idx); | 128 | WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); |
| 129 | WRITE_ONCE(ssp->srcu_gp_waiting, true); /* srcu_read_unlock() wakes! */ | 129 | WRITE_ONCE(ssp->srcu_gp_waiting, true); /* srcu_read_unlock() wakes! */ |
| 130 | swait_event_exclusive(ssp->srcu_wq, !READ_ONCE(ssp->srcu_lock_nesting[idx])); | 130 | swait_event_exclusive(ssp->srcu_wq, !READ_ONCE(ssp->srcu_lock_nesting[idx])); |
| 131 | WRITE_ONCE(ssp->srcu_gp_waiting, false); /* srcu_read_unlock() cheap. */ | 131 | WRITE_ONCE(ssp->srcu_gp_waiting, false); /* srcu_read_unlock() cheap. */ |
| 132 | WRITE_ONCE(ssp->srcu_idx, ssp->srcu_idx + 1); | ||
| 132 | 133 | ||
| 133 | /* Invoke the callbacks we removed above. */ | 134 | /* Invoke the callbacks we removed above. */ |
| 134 | while (lh) { | 135 | while (lh) { |