mm/kmemleak: Minor cleanup & performance tuning
Subsystems (2)
cover mm/kmemleak: Minor cleanup & performance tuning
This series contains 2 simple cleanup patches to slightly reduce memory and performance overhead.
Waiman Long (2):
mm/kmemleak: Compact kmemleak_object further mm/kmemleak: Disable KASAN instrumentation in kmemleak
mm/Makefile | 1 + mm/kmemleak.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.3
PATCH 1/2 mm/kmemleak: Compact kmemleak_object further
With commit 56a61617dd22 ("mm: use stack_depot for recording kmemleak's backtrace"), the size of kmemleak_object has been reduced by 128 bytes for 64-bit arches. The replacement "depot_stack_handle_t trace_handle" is actually just 4 bytes long leaving a hole of 4 bytes. By moving up trace_handle to another existing 4-byte hold, we can save 8 more bytes from kmemleak_object reducing its overall size from 248 to 240 bytes.
--- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
@@ -158,9 +158,9 @@ struct kmemleak_object {int count;/* checksum for detecting modified objects */ u32 checksum; +depot_stack_handle_t trace_handle;/* memory ranges to be scanned inside an object (empty for all) */ struct hlist_head area_list; -depot_stack_handle_t trace_handle;unsigned long jiffies;/* creation timestamp */ pid_t pid;/* pid of the current task */ char comm[TASK_COMM_LEN ];/* executable name */
Signature · 1 line
2.39.3
Re: [PATCH 1/2] mm/kmemleak: Compact kmemleak_object further
Quoted 8 lines · Waiman Long
With commit
56a61617dd22("mm: usestack_depotfor recording kmemleak's backtrace"), the size ofkmemleak_objecthas been reduced by 128 bytes for 64-bit arches. The replacement "depot_stack_handle_ttrace_handle" is actually just 4 bytes long leaving a hole of 4 bytes. By moving uptrace_handleto another existing 4-byte hold, we can save 8 more bytes fromkmemleak_objectreducing its overall size from 248 to 240 bytes.Signed-off-by Waiman Long <[email protected]>
PATCH 2/2 mm/kmemleak: Disable KASAN instrumentation in kmemleak
In reply to Waiman LongKmemleak ia a memory leak checker. KASAN is also a memory checker but it focuses more on finding out-of-bounds and use-after-free bugs. Since kmemleak is inherently slow especially on systems with large number of CPUs, adding KASAN instrumentation will make it slower even more. As kmemleak is not for production use, the utility of enabling KASAN there is questionable.
This patch disables KASAN instrumentation for configurations that enable both of them to slightly reduce performance overhead.
--- mm/Makefile | 1 + 1 file changed, 1 insertion(+)
mm/Makefile +1 -0
@@ -5,6 +5,7 @@ KASAN_SANITIZE_slab_common.o := n KASAN_SANITIZE_slub.o := n +KASAN_SANITIZE_kmemleak.o := n KCSAN_SANITIZE_kmemleak.o := n # These produce frequent data race reports: most of them are due to races on
Signature · 1 line
2.39.3
Re: [PATCH 2/2] mm/kmemleak: Disable KASAN instrumentation in kmemleak
Quoted 11 lines · Waiman Long
Kmemleak ia a memory leak checker. KASAN is also a memory checker but it focuses more on finding out-of-bounds and use-after-free bugs. Since kmemleak is inherently slow especially on systems with large number of CPUs, adding KASAN instrumentation will make it slower even more. As kmemleak is not for production use, the utility of enabling KASAN there is questionable.
This patch disables KASAN instrumentation for configurations that enable both of them to slightly reduce performance overhead.
Signed-off-by Waiman Long <[email protected]>