* [Question] mm/vmpressure.c: ilog2 calculation in constant
@ 2021-05-28 12:08 torvic9
2021-05-28 13:08 ` David Hildenbrand
0 siblings, 1 reply; 2+ messages in thread
From: torvic9 @ 2021-05-28 12:08 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: linux-mm
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'?
Then, I guess, we could also get rid of the log2.h include.
Note that this is just a question, not a request, as I'm sure there is a reason for this.
(given the help text in the comment just above)
Greetings,
Tor Vic
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Question] mm/vmpressure.c: ilog2 calculation in constant
2021-05-28 12:08 [Question] mm/vmpressure.c: ilog2 calculation in constant torvic9
@ 2021-05-28 13:08 ` David Hildenbrand
0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2021-05-28 13:08 UTC (permalink / raw)
To: torvic9, linux-kernel, akpm; +Cc: linux-mm
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-28 13:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 12:08 [Question] mm/vmpressure.c: ilog2 calculation in constant torvic9
2021-05-28 13:08 ` David Hildenbrand
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.