LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCH] Remove GFP_DMA and GFP_DMA32 from flags before passing it into kmalloc.
[not found] <CAHkaATRAuo=Mh1tmMVDxnWeO8ARjW+KBfHNLpaFG3XxN5uY-hQ@mail.gmail.com>
@ 2014-09-27 15:13 ` Catalin Marinas
2014-09-28 0:44 ` Miles MH Chen
0 siblings, 1 reply; 3+ messages in thread
From: Catalin Marinas @ 2014-09-27 15:13 UTC (permalink / raw)
To: Miles MH Chen; +Cc: Will Deacon, linux-kernel
On 27 Sep 2014, at 16:09, Miles MH Chen <orca.chen@gmail.com> wrote:
> Signed-off-by: Min-Hua Chen <orca.chen@gmail.com>
> ---
> arch/arm64/mm/dma-mapping.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index 4164c5a..273cf6d 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -103,7 +103,8 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size,
> ptr = __dma_alloc_coherent(dev, size, dma_handle, flags, attrs);
> if (!ptr)
> goto no_mem;
> - map = kmalloc(sizeof(struct page *) << order, flags & ~GFP_DMA);
> + map = kmalloc(sizeof(struct page *) << order,
> + flags & ~(GFP_DMA | GFP_DMA32));
Do you have an explanation on why this is needed (and such explanation
should also be included in the commit log)? We don’t use ZONE_DMA32 on
arm64 (we did initially but it was for the wrong reasons).
Thanks,
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Remove GFP_DMA and GFP_DMA32 from flags before passing it into kmalloc.
2014-09-27 15:13 ` [PATCH] Remove GFP_DMA and GFP_DMA32 from flags before passing it into kmalloc Catalin Marinas
@ 2014-09-28 0:44 ` Miles MH Chen
2014-12-08 17:48 ` Catalin Marinas
0 siblings, 1 reply; 3+ messages in thread
From: Miles MH Chen @ 2014-09-28 0:44 UTC (permalink / raw)
To: Catalin Marinas; +Cc: Will Deacon, linux-kernel
On Sat, Sep 27, 2014 at 11:13 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On 27 Sep 2014, at 16:09, Miles MH Chen <orca.chen@gmail.com> wrote:
>> Signed-off-by: Min-Hua Chen <orca.chen@gmail.com>
>> ---
>> arch/arm64/mm/dma-mapping.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
>> index 4164c5a..273cf6d 100644
>> --- a/arch/arm64/mm/dma-mapping.c
>> +++ b/arch/arm64/mm/dma-mapping.c
>> @@ -103,7 +103,8 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size,
>> ptr = __dma_alloc_coherent(dev, size, dma_handle, flags, attrs);
>> if (!ptr)
>> goto no_mem;
>> - map = kmalloc(sizeof(struct page *) << order, flags & ~GFP_DMA);
>> + map = kmalloc(sizeof(struct page *) << order,
>> + flags & ~(GFP_DMA | GFP_DMA32));
>
> Do you have an explanation on why this is needed (and such explanation
> should also be included in the commit log)? We don’t use ZONE_DMA32 on
> arm64 (we did initially but it was for the wrong reasons).
If GFP_DMA32 is passed to dma_alloc_coherent, the flag will go to kmalloc and
trigger a BUG_ON check in slab allocator:
__dma_alloc_noncoherent
kmalloc
new_slab BUG_ON(flags & GFP_SLAB_BUG_MASK);
It can be avoided this by removing GFP_DMA32 before passing it to kmalloc
or we should block GFP_DMA32 flag earlier in arch/arm64/dma-mapping.c if
GFP_DMA32 is not allowed in arch/arm64/dma-mapping.c.
Thanks,
MH
>
> Thanks,
>
> Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Remove GFP_DMA and GFP_DMA32 from flags before passing it into kmalloc.
2014-09-28 0:44 ` Miles MH Chen
@ 2014-12-08 17:48 ` Catalin Marinas
0 siblings, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2014-12-08 17:48 UTC (permalink / raw)
To: Miles MH Chen; +Cc: Will Deacon, linux-kernel
On Sun, Sep 28, 2014 at 01:44:15AM +0100, Miles MH Chen wrote:
> On Sat, Sep 27, 2014 at 11:13 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On 27 Sep 2014, at 16:09, Miles MH Chen <orca.chen@gmail.com> wrote:
> >> Signed-off-by: Min-Hua Chen <orca.chen@gmail.com>
> >> ---
> >> arch/arm64/mm/dma-mapping.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> >> index 4164c5a..273cf6d 100644
> >> --- a/arch/arm64/mm/dma-mapping.c
> >> +++ b/arch/arm64/mm/dma-mapping.c
> >> @@ -103,7 +103,8 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size,
> >> ptr = __dma_alloc_coherent(dev, size, dma_handle, flags, attrs);
> >> if (!ptr)
> >> goto no_mem;
> >> - map = kmalloc(sizeof(struct page *) << order, flags & ~GFP_DMA);
> >> + map = kmalloc(sizeof(struct page *) << order,
> >> + flags & ~(GFP_DMA | GFP_DMA32));
> >
> > Do you have an explanation on why this is needed (and such explanation
> > should also be included in the commit log)? We don’t use ZONE_DMA32 on
> > arm64 (we did initially but it was for the wrong reasons).
>
> If GFP_DMA32 is passed to dma_alloc_coherent, the flag will go to kmalloc and
> trigger a BUG_ON check in slab allocator:
>
> __dma_alloc_noncoherent
> kmalloc
> new_slab BUG_ON(flags & GFP_SLAB_BUG_MASK);
>
> It can be avoided this by removing GFP_DMA32 before passing it to kmalloc
> or we should block GFP_DMA32 flag earlier in arch/arm64/dma-mapping.c if
> GFP_DMA32 is not allowed in arch/arm64/dma-mapping.c.
With commit d4932f9e81ae (arm64: add atomic pool for non-coherent and CMA
allocations), this fix is no longer needed. Prior to this we could
simply use GFP_KERNEL rather than masking out bits as we don't care
about atomic contexts prior to the commit I mentioned.
--
Catalin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-08 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAHkaATRAuo=Mh1tmMVDxnWeO8ARjW+KBfHNLpaFG3XxN5uY-hQ@mail.gmail.com>
2014-09-27 15:13 ` [PATCH] Remove GFP_DMA and GFP_DMA32 from flags before passing it into kmalloc Catalin Marinas
2014-09-28 0:44 ` Miles MH Chen
2014-12-08 17:48 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).