lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 30 Jan 2020 11:10:49 -0800
From:   Eric Dumazet <edumazet@...gle.com>
To:     Christoph Hellwig <hch@....de>, Joerg Roedel <jroedel@...e.de>
Cc:     linux-kernel <linux-kernel@...r.kernel.org>,
        iommu@...ts.linux-foundation.org,
        Eric Dumazet <edumazet@...gle.com>,
        Eric Dumazet <eric.dumazet@...il.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>
Subject: [PATCH] dma-debug: dynamic allocation of hash table

Increasing the size of dma_entry_hash size by 327680 bytes
has reached some bootloaders limitations.

Simply use dynamic allocations instead, and take
this opportunity to increase the hash table to 65536
buckets. Finally my 40Gbit mlx4 NIC can sustain
line rate with CONFIG_DMA_API_DEBUG=y.

Fixes: 5e76f564572b ("dma-debug: increase HASH_SIZE")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Reported-by: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Christoph Hellwig <hch@....de>
---
 kernel/dma/debug.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c
index 2031ed1ad7fa109bb8a8c290bbbc5f825362baba..a310dbb1515e92c081f8f3f9a7290dd5e53fc889 100644
--- a/kernel/dma/debug.c
+++ b/kernel/dma/debug.c
@@ -27,7 +27,7 @@
 
 #include <asm/sections.h>
 
-#define HASH_SIZE       16384ULL
+#define HASH_SIZE       65536ULL
 #define HASH_FN_SHIFT   13
 #define HASH_FN_MASK    (HASH_SIZE - 1)
 
@@ -90,7 +90,8 @@ struct hash_bucket {
 };
 
 /* Hash list to save the allocated dma addresses */
-static struct hash_bucket dma_entry_hash[HASH_SIZE];
+static struct hash_bucket *dma_entry_hash __read_mostly;
+
 /* List of pre-allocated dma_debug_entry's */
 static LIST_HEAD(free_entries);
 /* Lock for the list above */
@@ -934,6 +935,10 @@ static int dma_debug_init(void)
 	if (global_disable)
 		return 0;
 
+	dma_entry_hash = vmalloc(HASH_SIZE * sizeof(*dma_entry_hash));
+	if (!dma_entry_hash)
+		goto err;
+
 	for (i = 0; i < HASH_SIZE; ++i) {
 		INIT_LIST_HEAD(&dma_entry_hash[i].list);
 		spin_lock_init(&dma_entry_hash[i].lock);
@@ -950,6 +955,7 @@ static int dma_debug_init(void)
 		pr_warn("%d debug entries requested but only %d allocated\n",
 			nr_prealloc_entries, nr_total_entries);
 	} else {
+err:
 		pr_err("debugging out of memory error - disabled\n");
 		global_disable = true;
 
-- 
2.25.0.341.g760bfbb309-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ