From: Luis Chamberlain <mcgrof@kernel.org>
To: Ruiwu Chen <rwchen404@gmail.com>
Cc: corbet@lwn.net, joel.granados@kernel.org, keescook@chromium.org,
linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk,
zachwade.k@gmail.com
Subject: Re: [PATCH v2] drop_caches: re-enable message after disabling
Date: Mon, 10 Mar 2025 20:53:00 -0700 [thread overview]
Message-ID: <Z8-znMyjTx0kw4-l@bombadil.infradead.org> (raw)
In-Reply-To: <20250308080549.14464-1-rwchen404@gmail.com>
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@gmail.com>
> >
> > 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.
The way these flags are designed are bits in a flag. If you want to
disable the flag, it'll be disabled. If you want it added it must be
added as a flag. So what I did was just remove the or logic as that
just keeps it on forever. With XOR you end up where if you had it
enabled and then want to enable it again, you disable it.
1 xor 1 = 0
The simple variable setting just always sets it and puts the burden on
the operators to read the existing setting if they don't want to disable
prior settings.
Luis
next prev parent reply other threads:[~2025-03-11 3:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 10:05 [PATCH] drop_caches: re-enable message after disabling Ruiwu Chen
2025-02-21 8:50 ` Joel Granados
2025-02-22 8:45 ` [PATCH v2] " Ruiwu Chen
2025-02-23 17:22 ` Luis Chamberlain
2025-03-08 8:05 ` Ruiwu Chen
2025-03-10 13:51 ` Joel Granados
2025-03-12 22:55 ` Luis Chamberlain
2025-03-13 15:19 ` Joel Granados
2025-03-13 15:52 ` Joel Granados
2025-03-14 12:28 ` Ruiwu Chen
2025-03-17 19:28 ` Joel Granados
2025-03-11 3:53 ` Luis Chamberlain [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-02-16 10:17 [PATCH] " Ruiwu Chen
2025-02-20 13:18 ` [PATCH v2] " Ruiwu Chen
2025-02-17 17:33 Ruiwu Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8-znMyjTx0kw4-l@bombadil.infradead.org \
--to=mcgrof@kernel.org \
--cc=corbet@lwn.net \
--cc=joel.granados@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rwchen404@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zachwade.k@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).