lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20121114145848.8224e8b0.akpm@linux-foundation.org>
Date:	Wed, 14 Nov 2012 14:58:48 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Marek Szyprowski <m.szyprowski@...sung.com>
Cc:	linux-mm@...ck.org, linaro-mm-sig@...ts.linaro.org,
	linux-kernel@...r.kernel.org,
	Kyungmin Park <kyungmin.park@...sung.com>,
	Mel Gorman <mel@....ul.ie>,
	Michal Nazarewicz <mina86@...a86.com>,
	Minchan Kim <minchan@...nel.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Subject: Re: [PATCH] mm: cma: allocate pages from CMA if NR_FREE_PAGES
 approaches low water mark

On Mon, 12 Nov 2012 09:59:42 +0100
Marek Szyprowski <m.szyprowski@...sung.com> wrote:

> It has been observed that system tends to keep a lot of CMA free pages
> even in very high memory pressure use cases. The CMA fallback for movable
> pages is used very rarely, only when system is completely pruned from
> MOVABLE pages, what usually means that the out-of-memory even will be
> triggered very soon. To avoid such situation and make better use of CMA
> pages, a heuristics is introduced which turns on CMA fallback for movable
> pages when the real number of free pages (excluding CMA free pages)
> approaches low water mark.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@...sung.com>
> Reviewed-by: Kyungmin Park <kyungmin.park@...sung.com>
> CC: Michal Nazarewicz <mina86@...a86.com>
> ---
>  mm/page_alloc.c |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index fcb9719..90b51f3 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1076,6 +1076,15 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order,
>  {
>  	struct page *page;
>  
> +#ifdef CONFIG_CMA
> +	unsigned long nr_free = zone_page_state(zone, NR_FREE_PAGES);
> +	unsigned long nr_cma_free = zone_page_state(zone, NR_FREE_CMA_PAGES);
> +
> +	if (migratetype == MIGRATE_MOVABLE && nr_cma_free &&
> +	    nr_free - nr_cma_free < 2 * low_wmark_pages(zone))
> +		migratetype = MIGRATE_CMA;
> +#endif /* CONFIG_CMA */
> +
>  retry_reserve:
>  	page = __rmqueue_smallest(zone, order, migratetype);

erk, this is right on the page allocator hotpath.  Bad.

At the very least, we could code it so it is not quite so dreadfully
inefficient:

	if (migratetype == MIGRATE_MOVABLE) {
		unsigned long nr_cma_free;

		nr_cma_free = zone_page_state(zone, NR_FREE_CMA_PAGES);
		if (nr_cma_free) {
			unsigned long nr_free;

			nr_free = zone_page_state(zone, NR_FREE_PAGES);

			if (nr_free - nr_cma_free < 2 * low_wmark_pages(zone))
				migratetype = MIGRATE_CMA;
		}
	}

but it still looks pretty bad.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ