From: "zbestahu" <zbestahu@aliyun.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: akpm <akpm@linux-foundation.org>, minchan <minchan@kernel.org>,
linux-mm <linux-mm@kvack.org>, Yue Hu <huyue2@coolpad.com>,
Anton Vorontsov <anton.vorontsov@linaro.org>
Subject: Re: Re:[PATCH] mm: vmpressure: simplify pressure ratio calculation
Date: Tue, 04 Jul 2017 20:59:25 +0800 [thread overview]
Message-ID: <a68ebcb3-d087-49fe-9717-490ccfa1ff6a.zbestahu@aliyun.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 1728 bytes --]
The patch does not change the function, the existing percent
calculation using scale should be about rounding to integer, it
seems to be redundant, we can calculate it directly just like
"pressure = not_relaimed * 100 / scanned", no rounding issue.
It's also better because of saving several arithmetic operations.
Signed-off-by: Yue Hu <huyue2@coolpad.com>
---
mm/vmpressure.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 6063581..aad1fb2 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -111,7 +111,6 @@ static enum vmpressure_levels vmpressure_level(unsigned long pressure)
static enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
unsigned long reclaimed)
{
- unsigned long scale = scanned + reclaimed;
unsigned long pressure = 0;
/*
@@ -123,13 +122,12 @@ static enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
goto out;
/*
* We calculate the ratio (in percents) of how many pages were
- * scanned vs. reclaimed in a given time frame (window). Note that
- * time is in VM reclaimer's "ticks", i.e. number of pages
+ * unsuccessful reclaimed to scanned in a given time frame (window).
+ * Note that time is in VM reclaimer's "ticks", i.e. number of pages
* scanned. This makes it possible to set desired reaction time
* and serves as a ratelimit.
*/
- pressure = scale - (reclaimed * scale / scanned);
- pressure = pressure * 100 / scale;
+ pressure = (scanned - reclaimed) * 100 / scanned;
out:
pr_debug("%s: %3lu (s: %lu r: %lu)\n", __func__, pressure,
--
1.9.1N§²æìr¸zǧu©²Æ {\béì¹»\x1c®&Þ)îÆi¢Ø^nr¶Ý¢j$½§$¢¸\x05¢¹¨è§~'.)îÄÃ,yèm¶ÿÃ\f%{±j+ðèצj)Z·
next reply other threads:[~2017-07-04 12:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 12:59 zbestahu [this message]
2017-07-04 13:43 zbestahu
2017-07-04 13:54 ` Michal Hocko
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=a68ebcb3-d087-49fe-9717-490ccfa1ff6a.zbestahu@aliyun.com \
--to=zbestahu@aliyun.com \
--cc=akpm@linux-foundation.org \
--cc=anton.vorontsov@linaro.org \
--cc=huyue2@coolpad.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=minchan@kernel.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