From: David Hildenbrand <david@redhat.com>
To: torvic9@mailbox.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [Question] mm/vmpressure.c: ilog2 calculation in constant
Date: Fri, 28 May 2021 15:08:59 +0200 [thread overview]
Message-ID: <7a34c010-9f2a-431b-3c49-8f0d387f1cba@redhat.com> (raw)
In-Reply-To: <1825464932.40588.1622203733380@office.mailbox.org>
On 28.05.21 14:08, torvic9@mailbox.org wrote:
> Hello,
>
> in mm/vmpressure.c, we have defined this constant:
>
> static const unsigned int vmpressure_level_critical_prio = ilog2(100 / 10);
>
> My question is: Why do we calculate ilog2 instead of simply setting the constant to '3'?
My best guess is that it's in place to a) increase readability b) make
it easier to adjust. The compiler will optimize it out either way, so we
don't really care.
Having that said: it doesn't increase readability on my end. But I only
took a quick glimpse. Maybe the "100 / 10 == 10" here is the magic bit
also mentioned in the comment "when scanning depth is ~10%". So it can
be adjusted "more easily" eventually ... at least not by me.
--
Thanks,
David / dhildenb
prev parent reply other threads:[~2021-05-28 13:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 12:08 [Question] mm/vmpressure.c: ilog2 calculation in constant torvic9
2021-05-28 13:08 ` David Hildenbrand [this message]
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=7a34c010-9f2a-431b-3c49-8f0d387f1cba@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvic9@mailbox.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;
as well as URLs for NNTP newsgroup(s).