linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
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: 回复:[PATCH] mm: vmpressure: simplify pressure ratio calculation
Date: Mon, 03 Jul 2017 22:19:02 +0800	[thread overview]
Message-ID: <00146e00-d941-4311-8494-3e4220b04103.zbestahu@aliyun.com> (raw)
In-Reply-To: 20170703102354.GG3217@dhcp22.suse.cz

[-- Attachment #1: Type: text/plain, Size: 4269 bytes --]

Yes, the original code using scale should be about rounding to integer. I am trying to improve the calculation because i think the rounding seems to be useless, we can calculate pressure directly just like original code of "pressure = pressure * 100 / scale", no floating number issue.From the view of disassembly, the patch is also better than original.
If original code using scale is more powerful than the patch, please ignore the submit.
Thanks.------------------------------------------------------------------发件人:Michal Hocko <mhocko@kernel.org>发送时间:2017年7月3日(星期一) 18:24收件人:zbestahu@aliyun.com <zbestahu@aliyun.com>抄 送: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>主 题:Re: [PATCH] mm: vmpressure: simplify pressure ratio calculation
On Mon 03-07-17 17:45:25, zbestahu@aliyun.com wrote:
> Hi Michal
> 
> We can think the some of scanned pages is reclaimed as reclaimed pages
> and the rest of pages is just unsuccessful reclaimed pages. vmpressure
> is tend to unsuccessful reclaimed pages, so obviously the pressure
> percent is the ratio of unsuccessful reclaimed pages to scanned pages.

Yes this is correct and this is what the current code does as well.
The difference is in the rounding when the integer arithmetic is used.

Btw. are you trying to fix any existing problem or you merely checked
the code and considered this part too hard to understand and so you sent
a patch to make it simpler? Have you considered the original intention
of the code? Note that I am not saying your patch is incorrect I would
just like to uderstand your motivation and the original intention in the
code.

> -------- 原始邮件 --------
> 发件人:Michal Hocko <mhocko@kernel.org>
> 时间:周一 7月3日 15:44
> 收件人:zbestahu <zbestahu@aliyun.com>
> 抄送: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>
> 主题:Re: [PATCH] mm: vmpressure: simplify pressure ratio calculation
> 
> >[CC Anton]
> >
> >On Sat 01-07-17 14:27:39, zbestahu@aliyun.com wrote:
> >> From: Yue Hu <huyue2@coolpad.com>
> >> 
> >> The patch removes the needless scale in existing caluation, it
> >> makes the calculation more simple and more effective.
> >
> >I suspect the construct is deliberate and done this way because of the
> >rounding. Your code will behave slightly differently. If that is
> >intentional then it should be described in the changedlog.
> >
> >> Signed-off-by: Yue Hu <huyue2@coolpad.com>
> >> ---
> >>  mm/vmpressure.c | 4 +---
> >>  1 file changed, 1 insertion(+), 3 deletions(-)
> >> 
> >> diff --git a/mm/vmpressure.c b/mm/vmpressure.c
> >> index 6063581..174b2f0 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;
> >>  
> >>   /*
> >> @@ -128,8 +127,7 @@ static enum vmpressure_levels vmpressure_calc_level(unsigned long scanned,
> >>    * 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.1
> >> 
> >
> >-- 
> >Michal Hocko
> >SUSE Labs

-- 
Michal Hocko
SUSE Labs

[-- Attachment #2: Type: text/html, Size: 8617 bytes --]

  parent reply	other threads:[~2017-07-03 14:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03  9:45 [PATCH] " zbestahu
2017-07-03 10:23 ` Michal Hocko
2017-07-03 14:19 ` zbestahu [this message]
2017-07-03 15:37   ` 回复:[PATCH] " Michal Hocko
2017-07-04 13:08   ` zbestahu
2017-07-04 13:13     ` 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=00146e00-d941-4311-8494-3e4220b04103.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