Re: [PATCH v2] drop_caches: re-enable message after disabling

From: Joel Granados
Date: Wed Mar 12 2025 - 17:25:31 EST


On Sat, Mar 08, 2025 at 04:05:49PM +0800, Ruiwu Chen wrote:
> >> When 'echo 4 > /proc/sys/vm/drop_caches' the message is disabled,
> >> but there is no interface to enable the message, only by restarting
> >> the way, so add the 'echo 0 > /proc/sys/vm/drop_caches' way to
> >> enabled the message again.
> >>
> >> Signed-off-by: Ruiwu Chen <rwchen404@xxxxxxxxx>
> >
> > You are overcomplicating things, if you just want to re-enable messages
> > you can just use:
> >
> > - stfu |= sysctl_drop_caches & 4;
> > + stfu = sysctl_drop_caches & 4;
> >
> > The bool is there as 4 is intended as a bit flag, you can can figure
> > out what values you want and just append 4 to it to get the expected
> > result.
> >
> > Luis
>
> Is that what you mean ?
>
> - stfu |= sysctl_drop_caches & 4;
> + stfu ^= sysctl_drop_caches & 4;
>
> 'echo 4 > /sys/kernel/vm/drop_caches' can disable or open messages,
> This is what I originally thought, but there is uncertainty that when different operators execute the command,
> It is not possible to determine whether this time is enabled or turned on unless you operate it twice.

So can you use ^= or not? And what does operate it twice mean?

Best
>
> Ruiwu
>
> >
> >> ---
> >> v2: - updated Documentation/ to note this new API.
> >> - renamed the variable.
...
> >> @@ -85,7 +88,7 @@ static const struct ctl_table drop_caches_table[] = {
> >> .maxlen = sizeof(int),
> >> .mode = 0200,
> >> .proc_handler = drop_caches_sysctl_handler,
> >> - .extra1 = SYSCTL_ONE,
> >> + .extra1 = SYSCTL_ZERO,
> >> .extra2 = SYSCTL_FOUR,
> >> },
> >> };
> >> --
> >> 2.27.0
> >>

--

Joel Granados