kmemleak: record accurate early log buffer count and report when exceeded
Subsystems (2)
PATCH 1/1 kmemleak: record accurate early log buffer count and report when exceeded
In log_early function, crt_early_log should also count once when 'crt_early_log >= ARRAY_SIZE(early_log)'. Otherwise the reported count from kmemleak_init is one less than 'actual number'.
Then, in kmemleak_init, if early_log buffer size equal actual number, kmemleak will init sucessful, so change warning condition to 'crt_early_log > ARRAY_SIZE(early_log)'.
--- mm/kmemleak.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/kmemleak.c +4 -1
@@ -814,6 +814,8 @@ static void __init log_early(int op_type, const void *ptr, size_t size, }if (crt_early_log >=ARRAY_SIZE (early_log)) { +/* kmemleak will stop recording, just count the requests */ + crt_early_log++;kmemleak_disable ();return ; }
@@ -1829,7 +1831,8 @@ void __init kmemleak_init(void) object_cache =KMEM_CACHE (kmemleak_object,SLAB_NOLEAKTRACE ); scan_area_cache =KMEM_CACHE (kmemleak_scan_area,SLAB_NOLEAKTRACE ); -if (crt_early_log >=ARRAY_SIZE (early_log)) +/* Don't warning when crt_early_log == ARRAY_SIZE(early_log) */ +if (crt_early_log >ARRAY_SIZE (early_log))pr_warning ("Early log buffer exceeded (%d), please increase " "DEBUG_KMEMLEAK_EARLY_LOG_SIZE\n" , crt_early_log);
Signature · 1 line
1.7.9.5
(I see you corrected the LKML address; I replied to your early patch)
Quoted 18 lines · Wang Kai
In
log_earlyfunction,crt_early_logshould also count once when 'crt_early_log>=ARRAY_SIZE(early_log)'. Otherwise the reported count fromkmemleak_initis one less than 'actual number'.Then, in
kmemleak_init, ifearly_logbuffer size equal actual number, kmemleak will init sucessful, so change warning condition to 'crt_early_log>ARRAY_SIZE(early_log)'.Signed-off-by Wang Kai <[email protected]>--- mm/kmemleak.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)mm/kmemleak.c +0
-0
mm/kmemleak.c static void __init log_early(int op_type, const void *ptr, size_t size, · line 817
Quoted 4 lines
mm/kmemleak.c +1
-0@@ -814,6 +814,8 @@ static void __init log_early(int op_type, const void *ptr, size_t size, }if (crt_early_log >=ARRAY_SIZE (early_log)) { +/* kmemleak will stop recording, just count the requests */
You could say "just count the last request" since kmemleak_disable() would set kmemleak_error to 1 and you never get to this block again.
mm/kmemleak.c void __init kmemleak_init(void) · line 1834
Quoted 10 lines
mm/kmemleak.c +2
-1+ crt_early_log++;kmemleak_disable ();return ; }@@ -1829,7 +1831,8 @@ void __init kmemleak_init(void) object_cache =KMEM_CACHE (kmemleak_object,SLAB_NOLEAKTRACE ); scan_area_cache =KMEM_CACHE (kmemleak_scan_area,SLAB_NOLEAKTRACE ); -if (crt_early_log >=ARRAY_SIZE (early_log)) +/* Don't warning when crt_early_log == ARRAY_SIZE(early_log) */
s/warning/warn/
But I don't think this comment is needed, just add it to the commit log.
mm/kmemleak.c void __init kmemleak_init(void) · line 1837
Quoted 3 lines
mm/kmemleak.c +1
-0+if (crt_early_log >ARRAY_SIZE (early_log))pr_warning ("Early log buffer exceeded (%d), please increase " "DEBUG_KMEMLEAK_EARLY_LOG_SIZE\n" , crt_early_log);
Otherwise, my ack still stands:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Thanks a lot for the correction.
Quoted 54 lines · Catalin Marinas
(I see you corrected the LKML address; I replied to your early patch)
Quoted 18 lines · Wang Kai
In
log_earlyfunction,crt_early_logshould also count once when 'crt_early_log>=ARRAY_SIZE(early_log)'. Otherwise the reported count fromkmemleak_initis one less than 'actual number'.Then, in
kmemleak_init, ifearly_logbuffer size equal actual number, kmemleak will init sucessful, so change warning condition to 'crt_early_log>ARRAY_SIZE(early_log)'.Signed-off-by Wang Kai <[email protected]>--- mm/kmemleak.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)mm/kmemleak.c +0
-0mm/kmemleak.c static void __init log_early(int op_type, const void *ptr, size_t size, · line 817
Quoted 4 lines
mm/kmemleak.c +1
-0@@ -814,6 +814,8 @@ static void __init log_early(int op_type, const void *ptr, size_t size, }if (crt_early_log >=ARRAY_SIZE (early_log)) { +/* kmemleak will stop recording, just count the requests */ You could say "just count the last request" since
kmemleak_disable()would setkmemleak_errorto 1 and you never get to this block again.mm/kmemleak.c void __init kmemleak_init(void) · line 1834
Quoted 10 lines
mm/kmemleak.c +2
-1+ crt_early_log++;kmemleak_disable ();return ; }@@ -1829,7 +1831,8 @@ void __init kmemleak_init(void) object_cache =KMEM_CACHE (kmemleak_object,SLAB_NOLEAKTRACE ); scan_area_cache =KMEM_CACHE (kmemleak_scan_area,SLAB_NOLEAKTRACE ); -if (crt_early_log >=ARRAY_SIZE (early_log)) +/* Don't warning when crt_early_log == ARRAY_SIZE(early_log) */ s/warning/warn/
But I don't think this comment is needed, just add it to the commit log.
mm/kmemleak.c void __init kmemleak_init(void) · line 1837
Quoted 3 lines
mm/kmemleak.c +1
-0+if (crt_early_log >ARRAY_SIZE (early_log))pr_warning ("Early log buffer exceeded (%d), please increase " "DEBUG_KMEMLEAK_EARLY_LOG_SIZE\n" , crt_early_log);Otherwise, my ack still stands:
Acked-by Catalin Marinas <[email protected]>.