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:07:27 -0400 [thread overview]
Message-ID: <20200624140727.GA1987277@optiplex-lnx> (raw)
In-Reply-To: <20200624111255.GL21350@casper.infradead.org>
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.
> > int __meminit init_per_zone_wmark_min(void)
> > {
> > unsigned long lowmem_kbytes;
> > @@ -7862,10 +7865,10 @@ int __meminit init_per_zone_wmark_min(void)
> >
> > if (new_min_free_kbytes > user_min_free_kbytes) {
> > min_free_kbytes = new_min_free_kbytes;
> > - if (min_free_kbytes < 128)
> > - min_free_kbytes = 128;
> > - if (min_free_kbytes > 262144)
> > - min_free_kbytes = 262144;
> > + if (min_free_kbytes < MIN_FREE_KBYTES_LOWER_BOUND)
> > + min_free_kbytes = MIN_FREE_KBYTES_LOWER_BOUND;
> > + if (min_free_kbytes > MIN_FREE_KBYTES_UPPER_BOUND)
> > + min_free_kbytes = MIN_FREE_KBYTES_UPPER_BOUND;
>
> The only thing I'd consider changing there is replacing 262144 with 256
> * 1024. 1 << 18 is not clearer!
>
next prev parent reply other threads:[~2020-06-24 14:08 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 [this message]
2020-06-24 14:09 ` Matthew Wilcox
2020-06-24 14:26 ` Rafael Aquini
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=20200624140727.GA1987277@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