public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: m.szyprowski@samsung•com (Marek Szyprowski)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH v2] ARM: mm: Do not invoke OOM for higher order IOMMU DMA allocations
Date: Tue, 24 Mar 2015 10:02:32 +0100	[thread overview]
Message-ID: <55112828.3010806@samsung.com> (raw)
In-Reply-To: <1427095620-20994-1-git-send-email-tfiga@chromium.org>

Hello,

On 2015-03-23 08:27, Tomasz Figa wrote:
> IOMMU should be able to use single pages as well as bigger blocks, so if
> higher order allocations fail, we should not affect state of the system,
> with events such as OOM killer, but rather fall back to order 0
> allocations.
>
> This patch changes the behavior of ARM IOMMU DMA allocator to use
> __GFP_NORETRY, which bypasses OOM invocation, for orders higher than
> zero and, only if that fails, fall back to normal order 0 allocation
> which might invoke OOM killer.
>
> Signed-off-by: Tomasz Figa <tfiga@chromium•org>

Acked-by: Marek Szyprowski <m.szyprowski@samsung•com>

> ---
>   arch/arm/mm/dma-mapping.c | 27 +++++++++++++++++++++------
>   1 file changed, 21 insertions(+), 6 deletions(-)
>
> Changes since v1:
> (https://patchwork.kernel.org/patch/6015921/)
>   - do not clear __GFP_NORETRY, as it might come from the caller,
>   - s/positive order/order higher than 0/.
>
> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
> index 83cd5ac..3f1ac51 100644
> --- a/arch/arm/mm/dma-mapping.c
> +++ b/arch/arm/mm/dma-mapping.c
> @@ -1150,13 +1150,28 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
>   	gfp |= __GFP_NOWARN | __GFP_HIGHMEM;
>   
>   	while (count) {
> -		int j, order = __fls(count);
> +		int j, order;
> +
> +		for (order = __fls(count); order > 0; --order) {
> +			/*
> +			 * We do not want OOM killer to be invoked as long
> +			 * as we can fall back to single pages, so we force
> +			 * __GFP_NORETRY for orders higher than zero.
> +			 */
> +			pages[i] = alloc_pages(gfp | __GFP_NORETRY, order);
> +			if (pages[i])
> +				break;
> +		}
>   
> -		pages[i] = alloc_pages(gfp, order);
> -		while (!pages[i] && order)
> -			pages[i] = alloc_pages(gfp, --order);
> -		if (!pages[i])
> -			goto error;
> +		if (!pages[i]) {
> +			/*
> +			 * Fall back to single page allocation.
> +			 * Might invoke OOM killer as last resort.
> +			 */
> +			pages[i] = alloc_pages(gfp, 0);
> +			if (!pages[i])
> +				goto error;
> +		}
>   
>   		if (order) {
>   			split_page(pages[i], order);

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

  parent reply	other threads:[~2015-03-24  9:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23  7:27 [PATCH v2] ARM: mm: Do not invoke OOM for higher order IOMMU DMA allocations Tomasz Figa
2015-03-23 16:30 ` Doug Anderson
2015-03-23 23:07 ` David Rientjes
2015-03-24  9:02 ` Marek Szyprowski [this message]
2015-03-25 18:39 ` Ritesh Harjani
2015-03-26  0:34   ` David Rientjes
2015-03-26  4:31     ` Ritesh Harjani

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=55112828.3010806@samsung.com \
    --to=m.szyprowski@samsung$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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