From: "Juan M. de la Torre" <jmtorre@gmx.net>
To: linux-kernel@vger.kernel.org
Subject: Possible bug in __alloc_pages() ?
Date: Tue, 17 Sep 2002 23:48:04 +0200 [thread overview]
Message-ID: <20020917214804.GA891@apocalipsis> (raw)
Hi, this code appears at the beggining of __page_alloc() (kernel 2.4.19):
min = 1UL << order;
for (;;) {
zone_t *z = *(zone++);
if (!z)
break;
min += z->pages_low;
if (z->free_pages > min) {
page = rmqueue(z, order);
if (page)
return page;
}
}
AFAIK, what this code does is to try to alloc the requested pages from
the first zone in a zone_list (passed as argument) which have enought free
pages.
A zone is considered to have enought free pages if z->free_pages is greater
than (number_of_requested_pages + z->pages_low).
In the loop shown, the first iteration is OK, but in the second iteration
(which only occurs if the first zone in the zone_list hasn't enought free
pages) the zone will only be considered to have enought free pages if
z->free_pages is greater that (number_of_requested_pages + z->pages_low
+ PREV_ZONE->pages_low).
I think this is a bug, but i'm not sure (i'm not a VM hacker).
If it is a bug, there are other two loops in the same function which
are buggy.
Possible patch:
--- linux/mm/page_alloc.c.orig Tue Sep 17 23:45:02 2002
+++ linux/mm/page_alloc.c Tue Sep 17 23:46:45 2002
@@ -330,8 +330,7 @@
if (!z)
break;
- min += z->pages_low;
- if (z->free_pages > min) {
+ if (z->free_pages > min + z->pages_low) {
page = rmqueue(z, order);
if (page)
return page;
@@ -354,8 +353,8 @@
local_min = z->pages_min;
if (!(gfp_mask & __GFP_WAIT))
local_min >>= 2;
- min += local_min;
- if (z->free_pages > min) {
+
+ if (z->free_pages > min + local_min) {
page = rmqueue(z, order);
if (page)
return page;
@@ -394,8 +393,7 @@
if (!z)
break;
- min += z->pages_min;
- if (z->free_pages > min) {
+ if (z->free_pages > min + z->pages_min) {
page = rmqueue(z, order);
if (page)
return page;
Regards,
Juanma
--
/jm
next reply other threads:[~2002-09-17 21:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-17 21:48 Juan M. de la Torre [this message]
2002-09-17 22:02 ` Possible bug in __alloc_pages() ? Martin J. Bligh
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=20020917214804.GA891@apocalipsis \
--to=jmtorre@gmx.net \
--cc=linux-kernel@vger.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 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.