linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: zbestahu@aliyun.com
To: akpm@linux-foundation.org, minchan@kernel.org, mhocko@suse.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Yue Hu <huyue2@coolpad.com>
Subject: [PATCH] mm: vmpressure: simplify pressure ratio calculation
Date: Sat,  1 Jul 2017 14:13:39 +0800	[thread overview]
Message-ID: <1498889619-3933-1-git-send-email-zbestahu@aliyun.com> (raw)

From: Yue Hu <huyue2@coolpad.com>

The patch removes the needless scale in existing caluation, it
makes the calculation more simple and more effective.

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

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

             reply	other threads:[~2017-07-01  6:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-01  6:13 zbestahu [this message]
2017-07-05 10:00 ` [PATCH] mm: vmpressure: simplify pressure ratio calculation Anshuman Khandual
2017-07-05 12:49 ` zbestahu
2017-07-01  6:27 zbestahu
2017-07-03  7:44 ` Michal Hocko
2017-07-03  9:45 zbestahu
2017-07-03 10:23 ` 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=1498889619-3933-1-git-send-email-zbestahu@aliyun.com \
    --to=zbestahu@aliyun.com \
    --cc=akpm@linux-foundation.org \
    --cc=huyue2@coolpad.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --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;
as well as URLs for NNTP newsgroup(s).