Re: [net] Question about ipvs->sysctl_sync_threshold and READ_ONCE

Jason Xing <[email protected]>
Newsgroups org.kernel.vger.lvs-devel,org.kernel.vger.netdev
Message-ID <CAL+tcoDA2Mf9oxAFsmbfM3JcdSb=Er09R1+=j7CLSpLVcxN38w@mail.gmail.com>
On Wed, Mar 20, 2024 at 6:49 AM Zijie Zhao <[email protected]> wrote:
>
> Dear IPVS maintainers,
>
> We encountered an unusual usage of sysctl parameter while analyzing
> kernel source code.
>
>
> In include/net/ip_vs.h, line 1062 - 1070:
>
> ```
> static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
> {
>         return ipvs->sysctl_sync_threshold[0];
> }
>
> static inline int sysctl_sync_period(struct netns_ipvs *ipvs)
> {
>         return READ_ONCE(ipvs->sysctl_sync_threshold[1]);
> }
> ```
>
> Here, sysctl_sync_threshold[1] is accessed behind `READ_ONCE`, but
> sysctl_sync_threshold[0] is not. Should sysctl_sync_threshold[0] also be
> guarded by `READ_ONCE`?

I'm not so sure and clear about the detailed history.

AFAIK, readers accessing this sysctl knob (sysctl_sync_threshold)
should be protected by READ_ONCE() because it can be changed
concurrently. Probably the commit 749c42b620a95 missed this point many
years ago and then commit 6aa7de059173a followed that.

Thanks,
Jason

>
> Please kindly let us know if we missed any key information and this is
> actually intended. We appreciate your information and time! Thanks!
>
>
> Links to the code:
> https://elixir.bootlin.com/linux/v6.8.1/source/include/net/ip_vs.h#L1064
> https://elixir.bootlin.com/linux/v6.8.1/source/include/net/ip_vs.h#L1069
>
> Best,
> Zijie
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.