[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220313140827.1503359-1-trix@redhat.com>
Date: Sun, 13 Mar 2022 07:08:27 -0700
From: trix@...hat.com
To: apw@...onical.com, joe@...ches.com, dwaipayanray1@...il.com,
lukas.bulwahn@...il.com
Cc: linux-kernel@...r.kernel.org, Tom Rix <trix@...hat.com>
Subject: [PATCH] checkpatch: warn that small allocs should be combined
From: Tom Rix <trix@...hat.com>
A memory allocation has overhead. When a
small allocation is made the overhead dominates.
By combining the fixed sized small allocations
with others, the memory usage can be reduced
by eliminating the overhead of the small allocs.
Signed-off-by: Tom Rix <trix@...hat.com>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 577e029987011..605d5278677fc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -7076,6 +7076,12 @@ sub process {
"$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
}
+# check for small allocs
+ if ($line =~ /\b(?:kv|k|v)[zm]alloc\s*\(\s*(\d|sizeof\s*\([su](8|16|32)s*\))\s*,/) {
+ WARN("SMALL_ALLOC",
+ "Small allocs should be combined\n" . $herecurr);
+ }
+
# check for multiple semicolons
if ($line =~ /;\s*;\s*$/) {
if (WARN("ONE_SEMICOLON",
--
2.26.3
Powered by blists - more mailing lists