RE: [PATCH v3 1/1] swiotlb: Track and report io_tlb_used high water mark in debugfs

From: Michael Kelley (LINUX)
Date: Fri Apr 07 2023 - 18:01:21 EST


From: Christoph Hellwig <hch@xxxxxx> Sent: Thursday, April 6, 2023 10:50 PM
>
> On Fri, Mar 31, 2023 at 09:45:00PM -0700, Michael Kelley wrote:
> > Changes in v3:
> > * Do high water mark accounting only when CONFIG_DEBUG_FS=y. As
> > as a result, add back the mem_used() function for the "swiotlb
> > buffer is full" error message. [Christoph -- I didn't hear back
> > whether this approach addresses your concern about one additional
> > atomic operation when slots are allocated and again when freed. I've
> > gone ahead with this new version, and we can obviously have further
> > discussion.]
>
> Still not too happy, but at least debugfs is an interfact we could
> remove at any time.
>
> But can you please factor the used_hiwater accounting into two
> separate helpers that are udner CONFIG_DEBUG_FS and otherwise
> stubbed out, instead of adding the logic directly into
> swiotlb_do_find_slots and swiotlb_release_slots?

I coded the way I did to follow the kernel coding style guidance
that prefers converting a Kconfig symbol into a C boolean
expression, and using it in a normal C conditional instead of
using #ifdef. If CONFIG_DEBUG_FS=n, the compiler will constant
fold the conditional away so there's no runtime overhead. I
like the way that approached worked out in this case, but if you prefer
separate functions with #ifdef and stubs, I don't feel strongly either way.

Michael