Skip to content

Commit ec274af

Browse files
Petr TesarikChristoph Hellwig
authored andcommitted
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: Petr Tesarik <petr.tesarik.ext@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 8b0977e commit ec274af

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

include/linux/swiotlb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ struct io_tlb_mem {
107107
unsigned int area_nslabs;
108108
struct io_tlb_area *areas;
109109
struct io_tlb_slot *slots;
110+
#ifdef CONFIG_DEBUG_FS
110111
atomic_long_t total_used;
111112
atomic_long_t used_hiwater;
113+
#endif
112114
};
113115
extern struct io_tlb_mem io_tlb_default_mem;
114116

kernel/dma/swiotlb.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ bool is_swiotlb_active(struct device *dev)
966966
}
967967
EXPORT_SYMBOL_GPL(is_swiotlb_active);
968968

969+
#ifdef CONFIG_DEBUG_FS
970+
969971
static int io_tlb_used_get(void *data, u64 *val)
970972
{
971973
struct io_tlb_mem *mem = data;
@@ -1015,15 +1017,22 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
10151017
&fops_io_tlb_hiwater);
10161018
}
10171019

1018-
static int __init __maybe_unused swiotlb_create_default_debugfs(void)
1020+
static int __init swiotlb_create_default_debugfs(void)
10191021
{
10201022
swiotlb_create_debugfs_files(&io_tlb_default_mem, "swiotlb");
10211023
return 0;
10221024
}
10231025

1024-
#ifdef CONFIG_DEBUG_FS
10251026
late_initcall(swiotlb_create_default_debugfs);
1026-
#endif
1027+
1028+
#else /* !CONFIG_DEBUG_FS */
1029+
1030+
static inline void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
1031+
const char *dirname)
1032+
{
1033+
}
1034+
1035+
#endif /* CONFIG_DEBUG_FS */
10271036

10281037
#ifdef CONFIG_DMA_RESTRICTED_POOL
10291038

0 commit comments

Comments
 (0)