From: Eric Dumazet <redacted>
Date: Wed, 6 Jul 2022 09:00:11 +0200
On Wed, Jul 6, 2022 at 7:22 AM Kuniyuki Iwashima [off-list ref] wrote:
quoted
A sysctl variable is accessed concurrently, and there is always a chance of
data-race. So, all readers and writers need some basic protection to avoid
load/store-tearing.
This patch changes proc_dointvec() to use READ_ONCE()/WRITE_ONCE()
internally to fix a data-race on the sysctl side. For now, proc_dointvec()
itself is tolerant to a data-race, but we still need to add annotations on
the other subsystem's side.
In case we miss such fixes, this patch converts proc_dointvec() to a
wrapper of proc_dointvec_lockless(). When we fix a data-race in the other
subsystem, we can explicitly set it as a handler.
Also, this patch removes proc_dointvec()'s document and adds
proc_dointvec_lockless()'s one so that no one will use proc_dointvec()
anymore.
While we are on it, we remove some trailing spaces.
I do not see why you add more functions.
It was not to miss where we still need fixes and to be taken care of
by newly added sysctl knob.
Really all sysctls can change locklessly by nature, as I pointed out.
So I would simply add WRITE_ONCE() whenever they are written, and
READ_ONCE() when they are read.
If stable teams care enough, they will have to backport these changes,
so I would rather not have to change
proc_dointvec() to proc_dointvec_lockless() in many files, with many
conflicts, that ultimately will either
add bugs, or ask extra work for maintainers.
Indeed, I will drop such changes and just add annotations in *_conv().
Thank you!