Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-10-07 Thread Karsten Graul
On 06/10/2021 16:23, Robin Murphy wrote:
> On 2021-10-06 14:10, Gerald Schaefer wrote:
>> On Fri, 1 Oct 2021 14:52:56 +0200
>> Gerald Schaefer  wrote:
>>
>>> On Thu, 30 Sep 2021 15:37:33 +0200
>>> Karsten Graul  wrote:
>>>
>>>> On 14/09/2021 17:45, Ioana Ciornei wrote:
>>>>> On Wed, Sep 08, 2021 at 10:33:26PM -0500, Jeremy Linton wrote:
>>>>>> +DPAA2, netdev maintainers
>>>>>> Hi,
>>>>>>
>>>>>> On 5/18/21 7:54 AM, Hamza Mahfooz wrote:
>>>>>>> Since, overlapping mappings are not supported by the DMA API we should
>>>>>>> report an error if active_cacheline_insert returns -EEXIST.
>>>>>>
>>>>>> It seems this patch found a victim. I was trying to run iperf3 on a
>>>>>> honeycomb (5.14.0, fedora 35) and the console is blasting this error 
>>>>>> message
>>>>>> at 100% cpu. So, I changed it to a WARN_ONCE() to get the call trace, 
>>>>>> which
>>>>>> is attached below.
>>>>>>
>>>>>
>>>>> These frags are allocated by the stack, transformed into a scatterlist
>>>>> by skb_to_sgvec and then DMA mapped with dma_map_sg. It was not the
>>>>> dpaa2-eth's decision to use two fragments from the same page (that will
>>>>> also end un in the same cacheline) in two different in-flight skbs.
>>>>>
>>>>> Is this behavior normal?
>>>>>
>>>>
>>>> We see the same problem here and it started with 5.15-rc2 in our nightly 
>>>> CI runs.
>>>> The CI has panic_on_warn enabled so we see the panic every day now.
>>>
>>> Adding a WARN for a case that be detected false-positive seems not
>>> acceptable, exactly for this reason (kernel panic on unaffected
>>> systems).
>>>
>>> So I guess it boils down to the question if the behavior that Ioana
>>> described is legit behavior, on a system that is dma coherent. We
>>> are apparently hitting the same scenario, although it could not yet be
>>> reproduced with debug printks for some reason.
>>>
>>> If the answer is yes, than please remove at lease the WARN, so that
>>> it will not make systems crash that behave valid, and have
>>> panic_on_warn set. Even a normal printk feels wrong to me in that
>>> case, it really sounds rather like you want to fix / better refine
>>> the overlap check, if you want to report anything here.
>>
>> Dan, Christoph, any opinion?
>>
>> So far it all looks a lot like a false positive, so could you please
>> see that those patches get reverted? I do wonder a bit why this is
>> not an issue for others, we surely cannot be the only ones running
>> CI with panic_on_warn.
> 
> What convinces you it's a false-positive? I'm hardly familiar with most of 
> that callstack, but it appears to be related to mlx5, and I know that exists 
> on expansion cards which could be plugged into a system with non-coherent 
> PCIe where partial cacheline overlap *would* be a real issue. Of course it's 
> dubious that there are many real use-cases for plugging a NIC with a 4-figure 
> price tag into a little i.MX8 or whatever, but the point is that it *should* 
> still work correctly.
> 
>> We would need to disable DEBUG_DMA if this WARN stays in, which
>> would be a shame. Of course, in theory, this might also indicate
>> some real bug, but there really is no sign of that so far.
> 
> The whole point of DMA debug is to flag up things that you *do* get away with 
> on the vast majority of systems, precisely because most testing happens on 
> those systems rather than more esoteric embedded setups. Say your system only 
> uses dma-direct and a driver starts triggering the warning for not calling 
> dma_mapping_error(), would you argue for removing that warning as well since 
> dma_map_single() can't fail on your machine so it's "not a bug"?
> 
>> Having multiple sg elements in the same page (or cacheline) is
>> valid, correct? And this is also not a decision of the driver
>> IIUC, so if it was bug, it should be addressed in common code,
>> correct?
> 
> According to the streaming DMA API documentation, it is *not* valid:
> 
> ".. warning::
> 
>   Memory coherency operates at a granularity called the cache
>   line width.  In order for memory mapped by this API to operate
>   correctly, the mapped region must begin exactly on a cache line
>   boundary and end ex

Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-09-30 Thread Karsten Graul
On 14/09/2021 17:45, Ioana Ciornei wrote:
> On Wed, Sep 08, 2021 at 10:33:26PM -0500, Jeremy Linton wrote:
>> +DPAA2, netdev maintainers
>> Hi,
>>
>> On 5/18/21 7:54 AM, Hamza Mahfooz wrote:
>>> Since, overlapping mappings are not supported by the DMA API we should
>>> report an error if active_cacheline_insert returns -EEXIST.
>>
>> It seems this patch found a victim. I was trying to run iperf3 on a
>> honeycomb (5.14.0, fedora 35) and the console is blasting this error message
>> at 100% cpu. So, I changed it to a WARN_ONCE() to get the call trace, which
>> is attached below.
>>
> 
> These frags are allocated by the stack, transformed into a scatterlist
> by skb_to_sgvec and then DMA mapped with dma_map_sg. It was not the
> dpaa2-eth's decision to use two fragments from the same page (that will
> also end un in the same cacheline) in two different in-flight skbs.
> 
> Is this behavior normal?
> 

We see the same problem here and it started with 5.15-rc2 in our nightly CI 
runs.
The CI has panic_on_warn enabled so we see the panic every day now.

Its always the same pattern: module SMC calls dma_map_sg_attrs() which ends
up in the EEXIST warning sooner or later.

It would be better to revert this patch now and start to better understand the 
checking logic for overlapping areas.

Thank you.


The call trace for reference:

[  864.189864] DMA-API: mlx5_core 0662:00:00.0: cacheline tracking EEXIST, 
overlapping mappings aren't supported
[  864.189883] WARNING: CPU: 0 PID: 33720 at kernel/dma/debug.c:570 
add_dma_entry+0x208/0x2c8
...
[  864.190747] CPU: 0 PID: 33720 Comm: smcapp Not tainted 
5.15.0-20210928.rc3.git0.a59bf04db7bb.300.fc34.s390x+debug #1
[  864.190758] Hardware name: IBM 8561 T01 701 (z/VM 7.2.0)
[  864.190766] Krnl PSW : 0704d0018000 fa6239fc 
(add_dma_entry+0x20c/0x2c8)
[  864.190783]R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 
RI:0 EA:3
[  864.190795] Krnl GPRS: c000bfff 8000 0061 

[  864.190804]0001 0001 0001 
0001
[  864.190813]0701 0020ff00  
8137b300
[  864.190822]20020100 0001 fa6239f8 
0380074536f8
[  864.190837] Krnl Code: fa6239ec: c020007a4964larl
%r2,fb56ccb4
  fa6239f2: c0e5005ef2ffbrasl   
%r14,fb201ff0
 #fa6239f8: af00mc  0,0
 >fa6239fc: ecb60057007ccgij
%r11,0,6,fa623aaa
  fa623a02: c01000866149larl
%r1,fb6efc94
  fa623a08: e3101012lt  
%r1,0(%r1)
  fa623a0e: a774ff73brc 
7,fa6238f4
  fa623a12: c010008a9227larl
%r1,fb775e60
[  864.202949] Call Trace:
[  864.202959]  [] add_dma_entry+0x20c/0x2c8 
[  864.202971] ([] add_dma_entry+0x208/0x2c8)
[  864.202981]  [] debug_dma_map_sg+0x140/0x160 
[  864.202992]  [] __dma_map_sg_attrs+0x9c/0xd8 
[  864.203002]  [] dma_map_sg_attrs+0x22/0x40 
[  864.203012]  [<03ff80483bde>] smc_ib_buf_map_sg+0x5e/0x90 [smc] 
[  864.203036]  [<03ff80486b44>] smcr_buf_map_link.part.0+0x12c/0x1e8 [smc] 
[  864.203053]  [<03ff80486cb6>] _smcr_buf_map_lgr+0xb6/0xf8 [smc] 
[  864.203071]  [<03ff8048b91c>] smcr_buf_map_lgr+0x4c/0x90 [smc] 
[  864.211496]  [<03ff80490ac2>] smc_llc_cli_add_link+0x152/0x420 [smc] 
[  864.211522]  [<03ff8047acbc>] smcr_clnt_conf_first_link+0x124/0x1e0 
[smc] 
[  864.211537]  [<03ff8047bfb2>] smc_connect_rdma+0x25a/0x2e8 [smc] 
[  864.211551]  [<03ff8047da4a>] __smc_connect+0x38a/0x650 [smc] 
[  864.211566]  [<03ff8047de70>] smc_connect+0x160/0x190 [smc] 
[  864.211580]  [] __sys_connect+0x98/0xd0 
[  864.211592]  [] __do_sys_socketcall+0x16a/0x350 
[  864.211603]  [] __do_syscall+0x1c2/0x1f0 
[  864.211616]  [] system_call+0x78/0xa0 

-- 
Karsten
___
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu