Re: [PATCH] dma-debug: defer __dma_entry_alloc_check_leak() printk output
From: Sergey Senozhatsky
Date: Tue Aug 15 2023 - 12:53:12 EST
On (23/08/15 17:42), Robin Murphy wrote:
> On 15/08/2023 4:26 pm, Sergey Senozhatsky wrote:
> > __dma_entry_alloc_check_leak() calls printk -> serial console
> > output (qcom geni) and grabs port->lock under free_entries_lock,
> > which is a conflicting locking dependency chain as qcom_geni IRQ
> > handler can call into dma-debug code and grab free_entries_lock
> > under port->lock.
> >
> > Use deferred printk in __dma_entry_alloc_check_leak() so that we
> > don't acquire serial console's port->lock under free_entries_lock.
>
> Hmm, the print really doesn't need to be under the lock anyway, it only
> needs to key off whether the "num_free_entries == 0" condition was hit or
> not.
I thought about it, briefly. __dma_entry_alloc_check_leak() reads
global nr_total_entries / nr_prealloc_entries which are updated
(inc/dec) under free_entries_lock, so I didn't want to move
__dma_entry_alloc_check_leak() outside of free_entries_lock scope.