[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALk7dXqnax7YeRu3Xp1GwG4TUqSWBfPb6iJ+tgYrbfotMVk9XQ@mail.gmail.com>
Date: Thu, 26 Mar 2015 10:01:46 +0530
From: Ritesh Harjani <ritesh.list@...il.com>
To: David Rientjes <rientjes@...gle.com>
Cc: Tomasz Figa <tfiga@...omium.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
Laura Abbott <lauraa@...eaurora.org>,
Will Deacon <will.deacon@....com>,
LKML <linux-kernel@...r.kernel.org>,
Douglas Anderson <dianders@...omium.org>,
Carlo Caione <carlo@...one.org>,
Russell King <linux@....linux.org.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Sonny Rao <sonnyrao@...omium.org>,
Marek Szyprowski <m.szyprowski@...sung.com>
Subject: Re: [PATCH v2] ARM: mm: Do not invoke OOM for higher order IOMMU DMA allocations
On Thu, Mar 26, 2015 at 6:04 AM, David Rientjes <rientjes@...gle.com> wrote:
> On Thu, 26 Mar 2015, Ritesh Harjani wrote:
>
>> > 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);
>> I think down the code in this while loop, i & count is being
>> calculated based on the "order" of allocation in the current
>> iteration.
>> Since value of order will be automatically 0 here if (!pages[i]) is
>> true then, why hard code order to value of 0 here.
>> Comment clearly says what this code is doing right?
>>
>
> Gcc is smart enough to know that order == 0 here, the code generation on
> arm will be the same, so this is only a matter of how the source looks.
Agreed.
> To me, it doesn't make a lot of sense to write it as alloc_pages(gfp,
> order) when order is always equal to 0. I think it's clearer the way that
> Tomasz wrote it.
Ok
>
>> I know it is just a minor thing. Don't know if it is relevant.
>>
>> > + if (!pages[i])
>> > + goto error;
>> > + }
>> >
>> > if (order) {
>> > split_page(pages[i], order);
Thanks
Ritesh
--
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