diff options
author | Paul E. McKenney <paul.mckenney@linaro.org> | 2012-10-11 12:30:37 -0700 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-11-08 11:50:12 -0800 |
commit | 1924bcb0259711eea98491a7942d1ffbf677e114 (patch) | |
tree | b5c98e8b210c60468cf1264b9839a3078869b5d1 /kernel/task_work.c | |
parent | 7b2e6011f150c42235c4a541d20cf6891afe878a (diff) | |
download | op-kernel-dev-1924bcb0259711eea98491a7942d1ffbf677e114.zip op-kernel-dev-1924bcb0259711eea98491a7942d1ffbf677e114.tar.gz |
rcu: Avoid counter wrap in synchronize_sched_expedited()
There is a counter scheme similar to ticket locking that
synchronize_sched_expedited() uses to service multiple concurrent
callers with the same expedited grace period. Upon entry, a
sync_sched_expedited_started variable is atomically incremented,
and upon completion of a expedited grace period a separate
sync_sched_expedited_done variable is atomically incremented.
However, if a synchronize_sched_expedited() is delayed while
in try_stop_cpus(), concurrent invocations will increment the
sync_sched_expedited_started counter, which will eventually overflow.
If the original synchronize_sched_expedited() resumes execution just
as the counter overflows, a concurrent invocation could incorrectly
conclude that an expedited grace period elapsed in zero time, which
would be bad. One could rely on counter size to prevent this from
happening in practice, but the goal is to formally validate this
code, so it needs to be fixed anyway.
This commit therefore checks the gap between the two counters before
incrementing sync_sched_expedited_started, and if the gap is too
large, does a normal grace period instead. Overflow is thus only
possible if there are more than about 3.5 billion threads on 32-bit
systems, which can be excluded until such time as task_struct fits
into a single byte and 4G/4G patches are accepted into mainline.
It is also easy to encode this limitation into mechanical theorem
provers.
Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/task_work.c')
0 files changed, 0 insertions, 0 deletions