From: Wang Sheng-Hui <shhuiw@gmail.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Question about __zone_watermark_ok: why there is a "+ 1" in computing free_pages?
Date: Fri, 25 Nov 2011 09:21:35 +0800 [thread overview]
Message-ID: <CAKXJSOHu+sQ1NeMsRvFyp2GYoB6g+50boUu=-QvbxxjcqgOAVA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
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"?
1448/*
1449 * Return true if free pages are above 'mark'. This takes into account
the order
1450 * of the allocation.
1451 */
1452static bool __zone_watermark_ok(struct zone *z, int order, unsigned
long mark,
1453 int classzone_idx, int alloc_flags, long
free_pages)
1454{
1455 /* free_pages my go negative - that's OK */
1456 long min = mark;
1457 int o;
1458
1459 free_pages -= (1 << order) + 1;
1460 if (alloc_flags & ALLOC_HIGH)
1461 min -= min / 2;
1462 if (alloc_flags & ALLOC_HARDER)
1463 min -= min / 4;
1464
1465 if (free_pages <= min + z->lowmem_reserve[classzone_idx])
1466 return false;
1467 for (o = 0; o < order; o++) {
1468 /* At the next order, this order's pages become
unavailable */
1469 free_pages -= z->free_area[o].nr_free << o;
1470
1471 /* Require fewer higher order pages to be free */
1472 min >>= 1;
1473
1474 if (free_pages <= min)
1475 return false;
1476 }
1477 return true;
1478}
[-- Attachment #2: Type: text/html, Size: 1525 bytes --]
next reply other threads:[~2011-11-25 1:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 1:21 Wang Sheng-Hui [this message]
2011-12-05 16:14 ` Michal Hocko
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
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='CAKXJSOHu+sQ1NeMsRvFyp2GYoB6g+50boUu=-QvbxxjcqgOAVA@mail.gmail.com' \
--to=shhuiw@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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