linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Joel Granados <joel.granados@kernel.org>
Cc: Ruiwu Chen <rwchen404@gmail.com>,
	corbet@lwn.net, 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: Wed, 12 Mar 2025 15:55:22 -0700	[thread overview]
Message-ID: <Z9IQ2jam9hkXnPhg@bombadil.infradead.org> (raw)
In-Reply-To: <zaiqpjvkekhgipcs7smqhbb7hqt5dcneyoyndycofjepitxznf@q22hsykugpme>

On Mon, Mar 10, 2025 at 02:51:11PM +0100, Joel Granados wrote:
> 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.
> 
> So can you use ^= or not?

No,  ^= does not work, see a boolean truth table.

> And what does operate it twice mean?

I think the reporter meant an "sysadmin", say two folks admining a system.
Since we this as a flag to enable disabling it easily we can just
always check for the flag as I suggested:

stfu = sysctl_drop_caches & 4

  Luis

  reply	other threads:[~2025-03-12 22:55 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 [this message]
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
  -- 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=Z9IQ2jam9hkXnPhg@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).