Re: [PATCH] mmc_test: Add performance tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 23 Jul 2010 12:25:47 +0300
Adrian Hunter <adrian.hunter@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux