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

From: Christoph Hellwig
Date: Mon Apr 10 2023 - 23:45:10 EST


On Fri, Apr 07, 2023 at 10:01:13PM +0000, Michael Kelley (LINUX) wrote:
> 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.

I don't think there is a a hard and clear rule. Actual ifdefs have the
benefit of allowing to actually remove struct fields as well. But
the important bit is that I do want the accounting in helpers instead
of in the main swiotlb logic. And once you do that, having #ifdefed
stubs for the functions make sense to me.