Skip to content

Commit a1255cc

Browse files
dcuiChristoph Hellwig
authored andcommitted
swiotlb: do not set total_used to 0 in swiotlb_create_debugfs_files()
Sometimes the readout of /sys/kernel/debug/swiotlb/io_tlb_used and io_tlb_used_hiwater can be a huge number (e.g. 18446744073709551615), which is actually a negative number if we use "%ld" to print the number. When swiotlb_create_default_debugfs() is running from late_initcall, mem->total_used may already be non-zero, because the storage driver may have already started to perform I/O operations: if the storage driver is built-in, its probe() callback is called before late_initcall. swiotlb_create_debugfs_files() should not blindly set mem->total_used and mem->used_hiwater to 0; actually it doesn't have to initialize the fields at all, because the fields, as part of the global struct io_tlb_default_mem, have been implicitly initialized to zero. Also don't explicitly set mem->transient_nslabs to 0. Fixes: 8b0977e ("swiotlb: track and report io_tlb_used high water marks in debugfs") Fixes: 02e7656 ("swiotlb: add debugfs to track swiotlb transient pool usage") Signed-off-by: Dexuan Cui <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Reviewed-by: ZhangPeng <[email protected]> Reviewed-by: Petr Tesarik <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent e8068f2 commit a1255cc

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

kernel/dma/swiotlb.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,9 +1676,6 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_io_tlb_hiwater, io_tlb_hiwater_get,
16761676
static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
16771677
const char *dirname)
16781678
{
1679-
atomic_long_set(&mem->total_used, 0);
1680-
atomic_long_set(&mem->used_hiwater, 0);
1681-
16821679
mem->debugfs = debugfs_create_dir(dirname, io_tlb_default_mem.debugfs);
16831680
if (!mem->nslabs)
16841681
return;
@@ -1689,7 +1686,6 @@ static void swiotlb_create_debugfs_files(struct io_tlb_mem *mem,
16891686
debugfs_create_file("io_tlb_used_hiwater", 0600, mem->debugfs, mem,
16901687
&fops_io_tlb_hiwater);
16911688
#ifdef CONFIG_SWIOTLB_DYNAMIC
1692-
atomic_long_set(&mem->transient_nslabs, 0);
16931689
debugfs_create_file("io_tlb_transient_nslabs", 0400, mem->debugfs,
16941690
mem, &fops_io_tlb_transient_used);
16951691
#endif

0 commit comments

Comments
 (0)