On Thu, 7 Oct 2021 12:59:32 +0200 Karsten Graul <kgraul@xxxxxxxxxxxxx> wrote: [...] > > > >>> BTW, there is already a WARN in the add_dma_entry() path, related > >>> to cachlline overlap and -EEXIST: > >>> > >>> add_dma_entry() -> active_cacheline_insert() -> -EEXIST -> > >>> active_cacheline_inc_overlap() > >>> > >>> That will only trigger when "overlap > ACTIVE_CACHELINE_MAX_OVERLAP". > >>> Not familiar with that code, but it seems that there are now two > >>> warnings for more or less the same, and the new warning is much more > >>> prone to false-positives. > >>> > >>> How do these 2 warnings relate, are they both really necessary? > >>> I think the new warning was only introduced because of some old > >>> TODO comment in add_dma_entry(), see commit 2b4bbc6231d78 > >>> ("dma-debug: report -EEXIST errors in add_dma_entry"). > > > > AFAICS they are different things. I believe the new warning is supposed to be for the fundementally incorrect API usage (as above) of mapping different regions overlapping within the same cacheline. The existing one is about dma-debug losing internal consistency when tracking the *same* region being mapped multiple times, which is a legal thing to do - e.g. buffer sharing between devices - but if anyone's doing it to excess that's almost certainly a bug (i.e. they probably intended to unmap it in between but missed that out). > > Thanks for the explanation Robin. > > In our case its really that a buffer is mapped twice for 2 different devices which we use in SMC to provide failover capabilities. We see that -EEXIST is returned when a buffer is mapped for the second device. Since there is a maximum of 2 parallel mappings we never see the warning shown by active_cacheline_inc_overlap() because we don't exceed ACTIVE_CACHELINE_MAX_OVERLAP. > > So how to deal with this kind of "legal thing", looks like there is no way to suppress the newly introduced EEXIST warning for that case? Thanks Karsten, very interesting. We assumed so far that we hit the same case as Ioana, i.e. having multiple sg elements in one cacheline. With debug output it now seems that we hit a completely different case, not at all related to any cacheline or coherency issues. So it really seems that the new warning is basically the same as the already present one, with the difference that it already triggers on the first occurrence. Looking at the code again, it also seems rather obvious now... IIUC, from what Robin described, this means that the "legal thing to do - e.g. buffer sharing between devices" will now immediately trigger the new warning? Not sure if I missed something (again), because then I would expect much more reports on this, and of course it would then obviously be false-positive.