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: <alpine.DEB.2.10.1503161631290.20956@chino.kir.corp.google.com>
Date:	Mon, 16 Mar 2015 16:32:52 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Tomasz Figa <tfiga@...omium.org>
cc:	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	Russell King <linux@....linux.org.uk>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Will Deacon <will.deacon@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Laura Abbott <lauraa@...eaurora.org>,
	Ritesh Harjani <ritesh.harjani@...il.com>,
	Santosh Shilimkar <santosh.shilimkar@...com>,
	Carlo Caione <carlo@...one.org>,
	Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
	Douglas Anderson <dianders@...omium.org>,
	Sonny Rao <sonnyrao@...omium.org>
Subject: Re: [PATCH] ARM: mm: Do not invoke OOM for higher order IOMMU DMA
 allocations

On Mon, 16 Mar 2015, Tomasz Figa wrote:

> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 83cd5ac..f081e9e 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1145,18 +1145,31 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
>  	}
>  
>  	/*
> -	 * IOMMU can map any pages, so himem can also be used here
> +	 * IOMMU can map any pages, so himem can also be used here.
> +	 * We do not want OOM killer to be invoked as long as we can fall back
> +	 * to single pages, so we use __GFP_NORETRY for positive orders.
>  	 */
> -	gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
> +	gfp |= __GFP_NOWARN | __GFP_HIGHMEM | __GFP_NORETRY;
>  
>  	while (count) {
> -		int j, order = __fls(count);
> +		int j, order;
>  
> -		pages[i] = alloc_pages(gfp, order);
> -		while (!pages[i] && order)
> -			pages[i] = alloc_pages(gfp, --order);
> -		if (!pages[i])
> -			goto error;
> +		for (order = __fls(count); order; --order) {
> +			/* Will not trigger OOM. */
> +			pages[i] = alloc_pages(gfp, order);
> +			if (pages[i])
> +				break;
> +		}
> +
> +		if (!pages[i]) {
> +			/*
> +			 * Fall back to single page allocation.
> +			 * Might invoke OOM killer as last resort.
> +			 */
> +			pages[i] = alloc_pages(gfp & ~__GFP_NORETRY, 0);
> +			if (!pages[i])
> +				goto error;
> +		}
>  
>  		if (order) {
>  			split_page(pages[i], order);

I think this makes sense, but the problem is the unconditional setting and 
clearing of __GFP_NORETRY.  Strictly speaking, gfp may already have 
__GFP_NORETRY set when calling this function so it would be better to do 
the loop with alloc_pages(gfp | __GFP_NORETRY, order) and then the 
fallback as alloc_page(gfp).
--
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