lkml.org 
[lkml]   [2018]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/2] dma-coherent: Add one parameter to save available coherent memory
On 1 June 2018 at 01:25, Robin Murphy <robin.murphy@arm.com> wrote:
> On 31/05/18 06:55, Baolin Wang wrote:
>>
>> It is incorrect to use mem->size to valid if there are enough coherent
>> memory to allocate in __dma_alloc_from_coherent(), since some devices
>> may mark some occupied coherent memory by
>> dma_mark_declared_memory_occupied().
>>
>> So we can introduce one 'avail' parameter to save the available device
>> coherent memory, to valid if we have enough coherent memory for the device
>> to allocate.
>
>
> We already have dma_mem->size stored for other reasons, so there's little
> harm in using it for a rough sanity check to short-circuit the odd
> allocation which cannot possibly succeed, but adding machinery purely for
> the sake an ever-so-slightly more accurate, but still far from exhaustive,
> check doesn't really seem worth it.
>
> Even if size <= dma_mem->avail there's still no guarantee that the
> allocation will actually succeed, so what benefit does the explicit
> accounting provide?
>

Yes, it can not guarantee one successful allocation, but it can avoid
some redundant bitmap operation and reducing the preempt-disable time
if we have not enough memory by checking the actual available coherent
memory. By the way, I think we should also add check in
dma_mark_declared_memory_occupied() and __dma_mmap_from_coherent().

--
Baolin.wang
Best Regards

\
 
 \ /
  Last update: 2018-06-03 04:13    [W:0.052 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site