* [PATCH v1 0/1] swiotlb: Clean up unused code if !CONFIG_DEBUG_FS
@ 2023-04-20 9:58 Petr Tesarik
2023-04-20 9:58 ` [PATCH v1 1/1] swiotlb: Omit total_used and used_hiwater " Petr Tesarik
0 siblings, 1 reply; 3+ messages in thread
From: Petr Tesarik @ 2023-04-20 9:58 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
open list:DMA MAPPING HELPERS, open list
Cc: Roberto Sassu, petr
From: Petr Tesarik <petr.tesarik.ext@huawei.com>
While verifying that the swiotlb high water marks are never used
if CONFIG_DEBUG_FS is unset, I guarded the corresponding fields
in strut io_tlb_mem with an #ifdef, but then I ran into a build
failure. This patch tries to clean up the optional debugfs code
in swiotlb.
The patch should be applied to the dma-mapping for-next tree.
Petr Tesarik (1):
swiotlb: Omit total_used and used_hiwater if !CONFIG_DEBUG_FS
include/linux/swiotlb.h | 2 ++
kernel/dma/swiotlb.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v1 1/1] swiotlb: Omit total_used and used_hiwater if !CONFIG_DEBUG_FS
2023-04-20 9:58 [PATCH v1 0/1] swiotlb: Clean up unused code if !CONFIG_DEBUG_FS Petr Tesarik
@ 2023-04-20 9:58 ` Petr Tesarik
2023-04-20 12:51 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Petr Tesarik @ 2023-04-20 9:58 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
open list:DMA MAPPING HELPERS, open list
Cc: Roberto Sassu, petr
From: Petr Tesarik <petr.tesarik.ext@huawei.com>
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>
---
include/linux/swiotlb.h | 2 ++
kernel/dma/swiotlb.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 6dc4598d2260..44767844e12b 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -107,8 +107,10 @@ struct io_tlb_mem {
unsigned int area_nslabs;
struct io_tlb_area *areas;
struct io_tlb_slot *slots;
+#ifdef CONFIG_DEBUG_FS
atomic_long_t total_used;
atomic_long_t used_hiwater;
+#endif
};
extern struct io_tlb_mem io_tlb_default_mem;
diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index 9bbc2802a444..e67dafc255f2 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -966,6 +966,8 @@ bool is_swiotlb_active(struct device *dev)
}
EXPORT_SYMBOL_GPL(is_swiotlb_active);
+#ifdef CONFIG_DEBUG_FS
+
static int io_tlb_used_get(void *data, u64 *val)
{
struct io_tlb_mem *mem = data;
@@ -1015,15 +1017,22 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
&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");
return 0;
}
-#ifdef CONFIG_DEBUG_FS
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
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] swiotlb: Omit total_used and used_hiwater if !CONFIG_DEBUG_FS
2023-04-20 9:58 ` [PATCH v1 1/1] swiotlb: Omit total_used and used_hiwater " Petr Tesarik
@ 2023-04-20 12:51 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-04-20 12:51 UTC (permalink / raw)
To: Petr Tesarik
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy,
open list:DMA MAPPING HELPERS, open list, Roberto Sassu, petr
Thanks,
applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-20 12:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-20 9:58 [PATCH v1 0/1] swiotlb: Clean up unused code if !CONFIG_DEBUG_FS Petr Tesarik
2023-04-20 9:58 ` [PATCH v1 1/1] swiotlb: Omit total_used and used_hiwater " Petr Tesarik
2023-04-20 12:51 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.