linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: ? ?? <weilongpingshu@hotmail.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: ? ?? <weilongpingshu@hotmail.com>
Subject: [PATCH] bug:roundup_pow_of_two(size) will return 0     when size > 2^63 because of overflow problem. fix:when size > max, return max. (when newsize > max will return max originally)
Date: Fri, 27 Oct 2017 13:32:45 +0000	[thread overview]
Message-ID: <SG2PR01MB13282FE183A0EA24DE95EB84C05A0@SG2PR01MB1328.apcprd01.prod.exchangelabs.com> (raw)

Signed-off-by: LongPing.WEI <weilongpingshu@hotmail.com>
---
 mm/readahead.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index c4ca702..4941f04 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -248,7 +248,12 @@ int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
  */
 static unsigned long get_init_ra_size(unsigned long size, unsigned long max)
 {
-	unsigned long newsize = roundup_pow_of_two(size);
+	unsigned long newsize;
+
+	if (size > max)
+		return max;
+
+	newsize = roundup_pow_of_two(size);
 
 	if (newsize <= max / 32)
 		newsize = newsize * 4;
-- 
2.7.4

--
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-10-27 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27 13:32 ? ?? [this message]
2017-10-27 19:34 ` Matthew Wilcox

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=SG2PR01MB13282FE183A0EA24DE95EB84C05A0@SG2PR01MB1328.apcprd01.prod.exchangelabs.com \
    --to=weilongpingshu@hotmail.com \
    --cc=linux-mm@kvack.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