Skip to contentSkip to conversation

dma-debug: increase HASH_SIZE

PATCH Applied Eric Dumazet 3 participants 7 messages Oct 30, 2019 – Jan 30, 2020 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-debug: increase HASH_SIZE

With modern NIC, it is not unusual having about ~256,000 active dma mappings. Hash size of 1024 buckets is too small.

Forcing full cache line per bucket does not seem useful, especially now that we have a contention on free_entries_lock for allocations and freeing of entries. Better using space to fit more buckets.

Cc Christoph Hellwig <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 kernel/dma/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/dma/debug.c +2 -2
index 4ad74f5987ea9e95f9bb5e2d1592254e367d24fb..35e2a853bff9c482d789ab331d79aaee07753a97 100644
@@ -27,7 +27,7 @@
 
 #include <asm/sections.h>
 
-#define HASH_SIZE       1024ULL
+#define HASH_SIZE       16384ULL
 #define HASH_FN_SHIFT   13
 #define HASH_FN_MASK    (HASH_SIZE - 1)
 
@@ -87,7 +87,7 @@ typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *);
 struct hash_bucket {
 	struct list_head list;
 	spinlock_t lock;
-} ____cacheline_aligned_in_smp;
+};
 
 /* Hash list to save the allocated dma addresses */
 static struct hash_bucket dma_entry_hash[HASH_SIZE];
Signature · 1 line
2.24.0.rc0.303.g954a862665-goog
#2 lore raw
In reply to Eric Dumazet
Quoted 29 lines · Eric Dumazet

With modern NIC, it is not unusual having about ~256,000 active dma mappings. Hash size of 1024 buckets is too small.

Forcing full cache line per bucket does not seem useful, especially now that we have a contention on free_entries_lock for allocations and freeing of entries. Better using space to fit more buckets.

Cc Christoph Hellwig <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 kernel/dma/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/dma/debug.c +1 -1
index 4ad74f5987ea9e95f9bb5e2d1592254e367d24fb..35e2a853bff9c482d789ab331d79aaee07753a97 100644
@@ -27,7 +27,7 @@
 
 #include <asm/sections.h>
 
-#define HASH_SIZE       1024ULL
+#define HASH_SIZE       16384ULL
 #define HASH_FN_SHIFT   13
 #define HASH_FN_MASK    (HASH_SIZE - 1)
 

kernel/dma/debug.c typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *); · line 93

Quoted 8 lines
kernel/dma/debug.c +1 -1
@@ -87,7 +87,7 @@ typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *);
 struct hash_bucket {
        struct list_head list;
        spinlock_t lock;
-} ____cacheline_aligned_in_smp;
+};
 
 /* Hash list to save the allocated dma addresses */
 static struct hash_bucket dma_entry_hash[HASH_SIZE];

JFTR, this increases dma_entry_hash size by 327680 bytes, and pushes a few more boards beyond their bootloader-imposed kernel size limits.

Disabling CONFIG_DMA_API_DEBUG fixes that. Of course the real fix is to fix the bootloaders...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw
Quoted 6 lines · Geert Uytterhoeven

JFTR, this increases dma_entry_hash size by 327680 bytes, and pushes a few more boards beyond their bootloader-imposed kernel size limits.

Disabling CONFIG_DMA_API_DEBUG fixes that. Of course the real fix is to fix the bootloaders...

Hi Geert

Maybe we can make the hash size arch-dependent, or better dynamically allocate this memory ?

#4 lore raw

Hi Eric,

Quoted 9 lines · Eric Dumazet
Quoted 5 lines · Geert Uytterhoeven

JFTR, this increases dma_entry_hash size by 327680 bytes, and pushes a few more boards beyond their bootloader-imposed kernel size limits.

Disabling CONFIG_DMA_API_DEBUG fixes that. Of course the real fix is to fix the bootloaders...

Maybe we can make the hash size arch-dependent, or better dynamically allocate this memory ?

Dynamically allocating would be the better solution, IMHO.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#5 lore raw
In reply to Geert Uytterhoeven
Quoted 36 lines · Geert Uytterhoeven
Quoted 35 lines · Eric Dumazet

With modern NIC, it is not unusual having about ~256,000 active dma mappings. Hash size of 1024 buckets is too small.

Forcing full cache line per bucket does not seem useful, especially now that we have a contention on free_entries_lock for allocations and freeing of entries. Better using space to fit more buckets.

Cc Christoph Hellwig <[email protected]>
Cc Marek Szyprowski <[email protected]>
---
 kernel/dma/debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/dma/debug.c +2 -2
index 4ad74f5987ea9e95f9bb5e2d1592254e367d24fb..35e2a853bff9c482d789ab331d79aaee07753a97 100644
@@ -27,7 +27,7 @@
 
 #include <asm/sections.h>
 
-#define HASH_SIZE       1024ULL
+#define HASH_SIZE       16384ULL
 #define HASH_FN_SHIFT   13
 #define HASH_FN_MASK    (HASH_SIZE - 1)
 
@@ -87,7 +87,7 @@ typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *);
 struct hash_bucket {
        struct list_head list;
        spinlock_t lock;
-} ____cacheline_aligned_in_smp;
+};
 
Quoted 8 lines

kernel/dma/debug.c typedef bool (*match_fn)(struct dma_debug_entry *, struct dma_debug_entry *); · line 93

Quoted 2 lines
kernel/dma/debug.c +0 -0
 /* Hash list to save the allocated dma addresses */
 static struct hash_bucket dma_entry_hash[HASH_SIZE];

JFTR, this increases dma_entry_hash size by 327680 bytes, and pushes a few more boards beyond their bootloader-imposed kernel size limits.

Disabling CONFIG_DMA_API_DEBUG fixes that. Of course the real fix is to fix the bootloaders...

Can someone just send a patch to switch this to a dynamic allocation?

#6 lore raw
Quoted 5 lines · Christoph Hellwig

On Tue, Dec 10, 2019 at 03:55:08PM +0100, Geert Uytterhoeven wrote:

Can someone just send a patch to switch this to a dynamic allocation?

Yes I can do that, thanks for the reminder.