swiotlb: save io_tlb_used to local variable before leaving critical section
PATCH 1/1 swiotlb: save io_tlb_used to local variable before leaving critical section
When swiotlb is full, the kernel would print io_tlb_used. However, the result might be inaccurate at that time because we have left the critical section protected by spinlock.
Therefore, we backup the io_tlb_used into local variable before leaving critical section.
--- kernel/dma/swiotlb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/dma/swiotlb.c +5 -2
@@ -452,6 +452,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,unsigned long mask;unsigned long offset_slots;unsigned long max_slots; +unsigned long tmp_io_tlb_used;if (no_iotlb_memory)panic ("Can not allocate SWIOTLB buffer earlier and can't now provide you with the DMA bounce buffer" );
@@ -538,10 +539,12 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev, }while (index != wrap); not_found: + tmp_io_tlb_used = io_tlb_used; +spin_unlock_irqrestore (&io_tlb_lock, flags);if (!(attrs &DMA_ATTR_NO_WARN ) &&printk_ratelimit ()) -dev_warn (hwdev,"swiotlb buffer is full (sz: %zd bytes), total %lu, used %lu\n" , - size, io_tlb_nslabs, io_tlb_used); +dev_warn (hwdev,"swiotlb buffer is full (sz: %zd bytes), total %lu (slots), used %lu (slots)\n" , + size, io_tlb_nslabs, tmp_io_tlb_used);return DMA_MAPPING_ERROR ; found: io_tlb_used += nslots;
Signature · 6 lines
2.7.4 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
I'm good to have this patch, which helps identify the cause of failure is fragmentation or it really been used up.
Quoted 10 lines · Dongli Zhang
When swiotlb is full, the kernel would print
io_tlb_used. However, the result might be inaccurate at that time because we have left the critical section protected by spinlock.Therefore, we backup the
io_tlb_usedinto local variable before leaving critical section.Fixes 83ca25948940 ("swiotlb: dump used and total slots when swiotlb buffer is full")Suggested-by Håkon Bugge <[email protected]>Signed-off-by Dongli Zhang <[email protected]>
Thanks,
Joe
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
As the patch to be fixed is still in Konrad's own tree, I will send the v2 for the patch to be fixed, instead of an incremental fix.
Dongli Zhang
Quoted 11 lines · Joe Jin
I'm good to have this patch, which helps identify the cause of failure is fragmentation or it really been used up.
Quoted 7 lines · Dongli Zhang
When swiotlb is full, the kernel would print
io_tlb_used. However, the result might be inaccurate at that time because we have left the critical section protected by spinlock.Therefore, we backup the
io_tlb_usedinto local variable before leaving critical section.
Quoted 9 lines
Quoted 3 lines
Fixes 83ca25948940 ("swiotlb: dump used and total slots when swiotlb buffer is full")Suggested-by Håkon Bugge <[email protected]>Signed-off-by Dongli Zhang <[email protected]>Reviewed-by Joe Jin <[email protected]>Thanks,
Joe
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
A message that is not in the archive (sent off-list or not yet received): 38f6f868-013e-5619-b939-a8273fc64ee4-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
Quoted 4 lines · Dongli Zhang
As the patch to be fixed is still in Konrad's own tree, I will send the v2 for
the patch to be fixed, instead of an incremental fix.
I squashed it in.
Quoted 29 lines
Dongli Zhang
Quoted 6 lines · Joe Jin
I'm good to have this patch, which helps identify the cause of failure is fragmentation or it really been used up.
Quoted 2 lines · Dongli Zhang
When swiotlb is full, the kernel would print
io_tlb_used. However, the result might be inaccurate at that time because we have left thecritical
Quoted 6 lines
Quoted 6 lines
section protected by spinlock.
Therefore, we backup the
io_tlb_usedinto local variable before leaving critical section.Fixes 83ca25948940 ("swiotlb: dump used and total slots when swiotlbbuffer is full")
Quoted 8 lines
Quoted 2 lines
Suggested-by Håkon Bugge <[email protected]>Signed-off-by Dongli Zhang <[email protected]>Reviewed-by Joe Jin <[email protected]>Thanks,
Joe_______________________________________________
iommu mailing list iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 10 lines · Konrad Rzeszutek Wilk
On Mon, Apr 15, 2019, 2:50 AM Dongli Zhang <[email protected] <mailto:[email protected]>> wrote:
As the patch to be fixed is still in Konrad's own tree, I will send the v2 for the patch to be fixed, instead of an incremental fix.
I squashed it in.
Thank you very much!
I saw it is at:
Dongli Zhang