Commit ec274aff authored by Petr Tesarik's avatar Petr Tesarik Committed by Christoph Hellwig

swiotlb: Omit total_used and used_hiwater if !CONFIG_DEBUG_FS

The tracking of used_hiwater adds an atomic operation to the hot
path. This is acceptable only when debugging the kernel. To make
sure that the fields can never be used by mistake, do not even
include them in struct io_tlb_mem if CONFIG_DEBUG_FS is not set.

The build fails after doing that. To fix it, it is necessary to
remove all code specific to debugfs and instead provide a stub
implementation of swiotlb_create_debugfs_files(). As a bonus, this
change allows to remove one __maybe_unused attribute.
Signed-off-by: default avatarPetr Tesarik <petr.tesarik.ext@huawei.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 8b0977ec
...@@ -107,8 +107,10 @@ struct io_tlb_mem { ...@@ -107,8 +107,10 @@ struct io_tlb_mem {
unsigned int area_nslabs; unsigned int area_nslabs;
struct io_tlb_area *areas; struct io_tlb_area *areas;
struct io_tlb_slot *slots; struct io_tlb_slot *slots;
#ifdef CONFIG_DEBUG_FS
atomic_long_t total_used; atomic_long_t total_used;
atomic_long_t used_hiwater; atomic_long_t used_hiwater;
#endif
}; };
extern struct io_tlb_mem io_tlb_default_mem; extern struct io_tlb_mem io_tlb_default_mem;
......
...@@ -966,6 +966,8 @@ bool is_swiotlb_active(struct device *dev) ...@@ -966,6 +966,8 @@ bool is_swiotlb_active(struct device *dev)
} }
EXPORT_SYMBOL_GPL(is_swiotlb_active); EXPORT_SYMBOL_GPL(is_swiotlb_active);
#ifdef CONFIG_DEBUG_FS
static int io_tlb_used_get(void *data, u64 *val) static int io_tlb_used_get(void *data, u64 *val)
{ {
struct io_tlb_mem *mem = data; struct io_tlb_mem *mem = data;
...@@ -1015,15 +1017,22 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem, ...@@ -1015,15 +1017,22 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
&fops_io_tlb_hiwater); &fops_io_tlb_hiwater);
} }
static int __init __maybe_unused swiotlb_create_default_debugfs(void) static int __init swiotlb_create_default_debugfs(void)
{ {
swiotlb_create_debugfs_files(&io_tlb_default_mem, "swiotlb"); swiotlb_create_debugfs_files(&io_tlb_default_mem, "swiotlb");
return 0; return 0;
} }
#ifdef CONFIG_DEBUG_FS
late_initcall(swiotlb_create_default_debugfs); late_initcall(swiotlb_create_default_debugfs);
#endif
#else /* !CONFIG_DEBUG_FS */
static inline void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
const char *dirname)
{
}
#endif /* CONFIG_DEBUG_FS */
#ifdef CONFIG_DMA_RESTRICTED_POOL #ifdef CONFIG_DMA_RESTRICTED_POOL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment