From: Rafael Aquini <aquini@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Joel Savitz <jsavitz@redhat.com>,
linux-kernel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>,
John Hubbard <jhubbard@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org
Subject: Re: [PATCH] mm/page_alloc: fix documentation error and remove magic numbers
Date: Wed, 24 Jun 2020 10:26:26 -0400 [thread overview]
Message-ID: <20200624142626.GB1987277@optiplex-lnx> (raw)
In-Reply-To: <20200624140958.GN21350@casper.infradead.org>
On Wed, Jun 24, 2020 at 03:09:58PM +0100, Matthew Wilcox wrote:
> On Wed, Jun 24, 2020 at 10:07:27AM -0400, Rafael Aquini wrote:
> > On Wed, Jun 24, 2020 at 12:12:55PM +0100, Matthew Wilcox wrote:
> > > On Tue, Jun 23, 2020 at 11:27:12PM -0400, Joel Savitz wrote:
> > > > In addition, this patch replaces the magic number bounds with symbolic
> > > > constants to clarify the logic.
> > >
> > > Why do people think this kind of thing makes the code easier to read?
> > > It actually makes it harder. Unless the constants are used in more
> > > than one place, just leave the numbers where they are.
> > >
> > > > @@ -7852,6 +7852,9 @@ void setup_per_zone_wmarks(void)
> > > > * 8192MB: 11584k
> > > > * 16384MB: 16384k
> > > > */
> > > > +static const int MIN_FREE_KBYTES_LOWER_BOUND = 1 << 7;
> > > > +static const int MIN_FREE_KBYTES_UPPER_BOUND = 1 << 18;
> > > > +
> >
> > I think these constants would look better if declared as an enum.
>
> Why does having to look in two different places make the code clearer?
>
It might not make it clearer in this particular case, because it was
easy to take the meaning from the code, but it also doesn't make it
harder to read, so I don't have any strong opinion on this case.
Joel's approach, however, makes sense if you consider it's generally a
good practice to get rid of the unnamed magic numbers anti-pattern.
Cheers,
-- Rafael
next prev parent reply other threads:[~2020-06-24 14:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 3:27 Joel Savitz
2020-06-24 11:12 ` Matthew Wilcox
2020-06-24 14:07 ` Rafael Aquini
2020-06-24 14:09 ` Matthew Wilcox
2020-06-24 14:26 ` Rafael Aquini [this message]
2020-06-24 14:27 ` Matthew Wilcox
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=20200624142626.GB1987277@optiplex-lnx \
--to=aquini@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=jhubbard@nvidia.com \
--cc=jsavitz@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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