kmemleak: Adjustments for three function implementations
Subsystems (3)
cover kmemleak: Adjustments for three function implementations
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 11:30:22 +0200
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in two functions Use seq_puts() in print_unreferenced()
mm/kmemleak.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.0
PATCH 1/2 kmemleak: Delete an error message for a failed memory allocation in two functions
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 10:50:22 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
--- mm/kmemleak.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/kmemleak.c +1 -4
@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size, object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();return NULL ; }
@@ -775,10 +774,8 @@ static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp) } area =kmem_cache_alloc (scan_area_cache,gfp_kmemleak_mask (gfp)); -if (!area) { -pr_warn ("Cannot allocate a scan area\n" ); +if (!area) goto out; - }spin_lock_irqsave (&object->lock, flags);if (size =SIZE_MAX ) {
Signature · 1 line
2.14.0
Catalin Marinas
maintainerRe: [PATCH 1/2] kmemleak: Delete an error message for a failed memory allocation in two functions
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 10:50:22 +0200Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- mm/kmemleak.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/kmemleak.c +0
-0
mm/kmemleak.c static struct kmemleak_object *create_object(unsigned long ptr, size_t size, · line 558
Quoted 5 lines
mm/kmemleak.c +0
-1@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size, object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();
I don't really get what this patch is trying to achieve. Given that kmemleak will be disabled after this, I'd rather know why it happened.
Signature · 1 line
Catalin
Re: [PATCH 1/2] kmemleak: Delete an error message for a failed memory allocation in two functions
Quoted 9 lines
mm/kmemleak.c static struct kmemleak_object *create_object(unsigned long ptr, size_t size, · line 558
Quoted 7 lines
+++
b/mm/kmemleak.cmm/kmemleak.c +0
-1@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size, object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();I don't really get what this patch is trying to achieve.
I suggest to reduce the code size a bit.
Quoted 1 line
Given that kmemleak will be disabled after this,
I have got difficulties to interpret this information.
Quoted 1 line
I'd rather know why it happened.
Do you find the default allocation failure report sufficient?
Regards,
Markus
Re: [PATCH 1/2] kmemleak: Delete an error message for a failed memory allocation in two functions
In reply to Catalin MarinasQuoted 19 lines · Catalin Marinas
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 10:50:22 +0200Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- mm/kmemleak.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/kmemleak.c +0
-0@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
Quoted 7 lines
mm/kmemleak.c static struct kmemleak_object *create_object(unsigned long ptr, size_t size, · line 558
Quoted 4 lines
mm/kmemleak.c +0
-1object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();I don't really get what this patch is trying to achieve. Given that kmemleak will be disabled after this, I'd rather know why it happened.
kmem_cache_alloc() will generate a stack trace and a bunch of more useful information if it fails. The allocation isn't likely to fail, but if it does you will know. The extra message is just wasting RAM.
regards,
dan carpenter
Catalin Marinas
maintainerRe: [PATCH 1/2] kmemleak: Delete an error message for a failed memory allocation in two functions
Quoted 28 lines · Dan Carpenter
Quoted 19 lines · Catalin Marinas
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 10:50:22 +0200Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- mm/kmemleak.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/kmemleak.c +0
-0@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,Quoted 7 lines
mm/kmemleak.c static struct kmemleak_object *create_object(unsigned long ptr, size_t size, · line 558
Quoted 4 lines
mm/kmemleak.c +0
-1object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();I don't really get what this patch is trying to achieve. Given that kmemleak will be disabled after this, I'd rather know why it happened.
Quoted 3 lines
kmem_cache_alloc()will generate a stack trace and a bunch of more useful information if it fails. The allocation isn't likely to fail, but if it does you will know. The extra message is just wasting RAM.
Currently kmemleak uses __GFP_NOWARN for its own metadata allocation, so we wouldn't see the sl*b warnings. I don't fully remember why I went for this gfp flag, probably not to interfere with other messages printed by the allocator (kmemleak_alloc is called from within sl*b).
I'm fine to drop __GFP_NOWARN and remove those extra messages.
Signature · 1 line
Catalin
Re: [PATCH 1/2] kmemleak: Delete an error message for a failed memory allocation in two functions
Quoted 33 lines · Catalin Marinas
Quoted 28 lines · Dan Carpenter
Quoted 19 lines · Catalin Marinas
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 10:50:22 +0200Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- mm/kmemleak.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)mm/kmemleak.c +0
-0@@ -555,7 +555,6 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,Quoted 7 lines
mm/kmemleak.c static struct kmemleak_object *create_object(unsigned long ptr, size_t size, · line 558
Quoted 4 lines
mm/kmemleak.c +0
-1object =kmem_cache_alloc (object_cache,gfp_kmemleak_mask (gfp));if (!object) { -pr_warn ("Cannot allocate a kmemleak_object structure\n" );kmemleak_disable ();I don't really get what this patch is trying to achieve. Given that kmemleak will be disabled after this, I'd rather know why it happened.
Quoted 3 lines
kmem_cache_alloc()will generate a stack trace and a bunch of more useful information if it fails. The allocation isn't likely to fail, but if it does you will know. The extra message is just wasting RAM.
Quoted 7 lines
Currently kmemleak uses
__GFP_NOWARNfor its own metadata allocation, so we wouldn't see the sl*b warnings. I don't fully remember why I went for this gfp flag, probably not to interfere with other messages printed by the allocator (kmemleak_allocis called from within sl*b).I'm fine to drop
__GFP_NOWARNand remove those extra messages.
Ah. I considered that, but didn't see a NOWARN in the diff and was too lazy to check the code. Probably I would just leave it as-is.
regards,
dan carpenter
PATCH 2/2 kmemleak: Use seq_puts() in print_unreferenced()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 14 Aug 2017 11:23:11 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: Prefer seq_puts to seq_printf
Thus fix the affected source code place.
--- mm/kmemleak.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kmemleak.c +1 -1
@@ -373,7 +373,7 @@ static void print_unreferenced(struct seq_file *seq, object->comm, object->pid, object->jiffies, msecs_age / 1000, msecs_age % 1000);hex_dump_object (seq, object); -seq_printf (seq," backtrace:\n" ); +seq_puts (seq," backtrace:\n" );for (i =0 ; i < object->trace_len; i++) {void *ptr = (void *)object->trace[i];
Signature · 1 line
2.14.0