Re: [PATCH] mm: vmpressure: simplify pressure ratio calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 03-07-17 17:45:25, zbestahu@xxxxxxxxxx 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@xxxxxxxxxx>
> 时间:周一 7月3日 15:44
> 收件人:zbestahu <zbestahu@xxxxxxxxxx>
> 抄送:akpm <akpm@xxxxxxxxxxxxxxxxxxxx>,minchan <minchan@xxxxxxxxxx>,linux-mm <linux-mm@xxxxxxxxx>,Yue Hu <huyue2@xxxxxxxxxxx>,Anton Vorontsov <anton.vorontsov@xxxxxxxxxx>
> 主题:Re: [PATCH] mm: vmpressure: simplify pressure ratio calculation
> 
> >[CC Anton]
> >
> >On Sat 01-07-17 14:27:39, zbestahu@xxxxxxxxxx wrote:
> >> From: Yue Hu <huyue2@xxxxxxxxxxx>
> >> 
> >> 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@xxxxxxxxxxx>
> >> ---
> >>  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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux