From: Andrew Morton <akpm@linux-foundation.org>
To: Adrian Hunter <adrian.hunter@nokia.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH] mmc_test: Add performance tests
Date: Mon, 26 Jul 2010 15:52:34 -0700 [thread overview]
Message-ID: <20100726155234.3aca5a83.akpm@linux-foundation.org> (raw)
In-Reply-To: <4C49601B.5070900@nokia.com>
On Fri, 23 Jul 2010 12:25:47 +0300
Adrian Hunter <adrian.hunter@nokia.com> wrote:
> +/*
> + * Allocate a lot of memory, preferrably max_sz but at least min_sz. In case
> + * there isn't much memory do not exceed 1/16th total RAM.
> + */
> +static struct mmc_test_mem *mmc_test_alloc_mem(unsigned int min_sz,
> + unsigned int max_sz)
> +{
> + unsigned int max_page_cnt = DIV_ROUND_UP(max_sz, PAGE_SIZE);
> + unsigned int min_page_cnt = DIV_ROUND_UP(min_sz, PAGE_SIZE);
> + unsigned int page_cnt = 0;
> + struct mmc_test_mem *mem;
> + struct sysinfo si;
> +
> + si_meminfo(&si);
> + if (max_page_cnt > si.totalram >> 4)
> + max_page_cnt = si.totalram >> 4;
> + if (max_page_cnt < min_page_cnt)
> + max_page_cnt = min_page_cnt;
> +
> + mem = kzalloc(sizeof(struct mmc_test_mem), GFP_KERNEL);
>
> ...
>
> + gfp_t flags = GFP_KERNEL | GFP_DMA | __GFP_NOWARN |
> + __GFP_NORETRY;
> +
> + order = get_order(page_cnt << PAGE_SHIFT);
> + while (1) {
> + page = alloc_pages(flags, order);
>
> ...
>
struct sysinfo.totalram returns the total number of pages including
highmem. But a GFP_KERNEL allocation can only return lowmem pages.
The difference between the two can be 20x (on a 16G i386 box).
nr_free_buffer_pages() would be a more accurate thing to use.
Also, I worry about overflows here. For example, `page_cnt <<
PAGE_SHIFT' could overflow the unsigned int? Please check all of that.
next prev parent reply other threads:[~2010-07-26 22:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-23 9:25 [PATCH] mmc_test: Add performance tests Adrian Hunter
2010-07-26 22:52 ` Andrew Morton [this message]
2010-08-02 8:17 ` [PATCH] mmc_test: Fix large memory allocation Adrian Hunter
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=20100726155234.3aca5a83.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adrian.hunter@nokia.com \
--cc=linux-mmc@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 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).