From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: Wang Sheng-Hui <shhuiw@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@suse.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Question about __zone_watermark_ok: why there is a "+ 1" in computing free_pages?
Date: Thu, 08 Dec 2011 11:24:25 -0500 [thread overview]
Message-ID: <4EE0E4B9.4050903@gmail.com> (raw)
In-Reply-To: <20111205161443.GA20663@tiehlicka.suse.cz>
(12/5/11 11:14 AM), Michal Hocko wrote:
> On Fri 25-11-11 09:21:35, Wang Sheng-Hui wrote:
>> In line 1459, we have "free_pages -= (1<< order) + 1;".
>> Suppose allocating one 0-order page, here we'll get
>> free_pages -= 1 + 1
>> I wonder why there is a "+ 1"?
>
> Good spot. Check the patch bellow.
> ---
> From 38a1cf351b111e8791d2db538c8b0b912f5df8b8 Mon Sep 17 00:00:00 2001
> From: Michal Hocko<mhocko@suse.cz>
> Date: Mon, 5 Dec 2011 17:04:23 +0100
> Subject: [PATCH] mm: fix off-by-two in __zone_watermark_ok
>
> 88f5acf8 [mm: page allocator: adjust the per-cpu counter threshold when
> memory is low] changed the form how free_pages is calculated but it
> forgot that we used to do free_pages - ((1<< order) - 1) so we ended up
> with off-by-two when calculating free_pages.
>
> Spotted-by: Wang Sheng-Hui<shhuiw@gmail.com>
> Signed-off-by: Michal Hocko<mhocko@suse.cz>
> ---
> mm/page_alloc.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 9dd443d..8a2f1b6 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1457,7 +1457,7 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
> long min = mark;
> int o;
>
> - free_pages -= (1<< order) + 1;
> + free_pages -= (1<< order) - 1;
> if (alloc_flags& ALLOC_HIGH)
> min -= min / 2;
> if (alloc_flags& ALLOC_HARDER)
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: Michal Hocko <mhocko@suse.cz>
Cc: Wang Sheng-Hui <shhuiw@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Mel Gorman <mgorman@suse.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Question about __zone_watermark_ok: why there is a "+ 1" in computing free_pages?
Date: Thu, 08 Dec 2011 11:24:25 -0500 [thread overview]
Message-ID: <4EE0E4B9.4050903@gmail.com> (raw)
In-Reply-To: <20111205161443.GA20663@tiehlicka.suse.cz>
(12/5/11 11:14 AM), Michal Hocko wrote:
> On Fri 25-11-11 09:21:35, Wang Sheng-Hui wrote:
>> In line 1459, we have "free_pages -= (1<< order) + 1;".
>> Suppose allocating one 0-order page, here we'll get
>> free_pages -= 1 + 1
>> I wonder why there is a "+ 1"?
>
> Good spot. Check the patch bellow.
> ---
> From 38a1cf351b111e8791d2db538c8b0b912f5df8b8 Mon Sep 17 00:00:00 2001
> From: Michal Hocko<mhocko@suse.cz>
> Date: Mon, 5 Dec 2011 17:04:23 +0100
> Subject: [PATCH] mm: fix off-by-two in __zone_watermark_ok
>
> 88f5acf8 [mm: page allocator: adjust the per-cpu counter threshold when
> memory is low] changed the form how free_pages is calculated but it
> forgot that we used to do free_pages - ((1<< order) - 1) so we ended up
> with off-by-two when calculating free_pages.
>
> Spotted-by: Wang Sheng-Hui<shhuiw@gmail.com>
> Signed-off-by: Michal Hocko<mhocko@suse.cz>
> ---
> mm/page_alloc.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 9dd443d..8a2f1b6 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1457,7 +1457,7 @@ static bool __zone_watermark_ok(struct zone *z, int order, unsigned long mark,
> long min = mark;
> int o;
>
> - free_pages -= (1<< order) + 1;
> + free_pages -= (1<< order) - 1;
> if (alloc_flags& ALLOC_HIGH)
> min -= min / 2;
> if (alloc_flags& ALLOC_HARDER)
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
next prev parent reply other threads:[~2011-12-08 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 1:21 Question about __zone_watermark_ok: why there is a "+ 1" in computing free_pages? Wang Sheng-Hui
2011-12-05 16:14 ` Michal Hocko
2011-12-05 16:14 ` Michal Hocko
2011-12-05 17:06 ` Mel Gorman
2011-12-05 17:06 ` Mel Gorman
2011-12-08 2:38 ` Wang Sheng-Hui
2011-12-08 8:05 ` Michal Hocko
2011-12-08 16:24 ` KOSAKI Motohiro [this message]
2011-12-08 16:24 ` KOSAKI Motohiro
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=4EE0E4B9.4050903@gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=shhuiw@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.