u64_stats: Document writer non-preemptibility requirement
authorAhmed S. Darwish <a.darwish@linutronix.de>
Wed, 3 Jun 2020 14:49:46 +0000 (16:49 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jun 2020 22:50:42 +0000 (15:50 -0700)
commit6501bf87602f799b7e502014f8bc0aa58b868277
treef1c76d72ff0a12292f736f7259d8cf18a6d54851
parent79cbb6bc3332da7162c2581e151659ab8ebaa528
u64_stats: Document writer non-preemptibility requirement

The u64_stats mechanism uses sequence counters to protect against 64-bit
values tearing on 32-bit architectures. Updating such statistics is a
sequence counter write side critical section.

Preemption must be disabled before entering this seqcount write critical
section.  Failing to do so, the seqcount read side can preempt the write
side section and spin for the entire scheduler tick.  If that reader
belongs to a real-time scheduling class, it can spin forever and the
kernel will livelock.

Document this statistics update side non-preemptibility requirement.

Reword the introductory paragraph to highlight u64_stats raison d'ĂȘtre:
64-bit values tearing protection on 32-bit architectures. Divide
documentation on a basis of internal design vs. usage constraints.

Reword the u64_stats header file top comment to always mention "Reader"
or "Writer" at the start of each bullet point, making it easier to
follow which side each point is actually for.

Clarify the statement "whole thing is a NOOP on 64bit arches or UP
kernels".  For 32-bit UP kernels, preemption is always disabled for the
statistics read side section.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/u64_stats_sync.h