mm/slub: Add a dump_stack() to the unexpected GFP check
Subsystems (2)
PATCH 1/1 mm/slub: Add a dump_stack() to the unexpected GFP check
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like slab.c does that.
--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)
mm/slub.c +1 -0
@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack (); } return allocate_slab(s,
Signature · 1 line
2.11.0
Quoted 14 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.Signed-off-by Borislav Petkov <[email protected]>--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)mm/slub.c +0
-0
mm/slub.c static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) · line 1626
Quoted 4 lines
mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack ();
Will it make sense to change these two lines above to WARN(true, .....)?
Quoted 6 lines
mm/slub.c +0
-1} return allocate_slab(s, --2.11.0
Quoted 10 lines · Leon Romanovsky
Quoted 9 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.Signed-off-by Borislav Petkov <[email protected]>--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)
Quoted 11 lines
mm/slub.c static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) · line 1626
Quoted 9 lines
mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack ();Will it make sense to change these two lines above to
WARN(true, .....)?
Should be equivalent.
I'd even go a step further and make this a small inline function, something like warn_unexpected_gfp(flags) or so and call it from both from slab.c and slub.c.
Depending on what mm folks prefer, that is.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 23 lines · Borislav Petkov
Quoted 10 lines · Leon Romanovsky
Quoted 9 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.Signed-off-by Borislav Petkov <[email protected]>--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)Quoted 11 lines
mm/slub.c static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) · line 1626
Quoted 9 lines
mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack ();Will it make sense to change these two lines above to
WARN(true, .....)?
Quoted 1 line
Should be equivalent.
Almost, except one point - pr_warn and dump_stack have different log levels. There is a chance that user won't see pr_warn message above, but dump_stack will be always present.
For WARN_XXX, users will always see message and stack at the same time.
Quoted 12 lines
I'd even go a step further and make this a small inline function, something like
warn_unexpected_gfp(flags)or so and call it from both fromslab.candslub.c.Depending on what mm folks prefer, that is.
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Quoted 1 line · Leon Romanovsky
Almost, except one point -
pr_warnanddump_stackhave different log
Actually, Michal pointed out on IRC a more relevant difference:
WARN() taints the kernel and we don't want that for GFP flags misuse. Also, from looking at __warn(), it checks panic_on_warn and we explode if set.
So no, we probably don't want WARN() here.
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 6 lines · Borislav Petkov
Quoted 1 line · Leon Romanovsky
Almost, except one point -
pr_warnanddump_stackhave different logActually, Michal pointed out on IRC a more relevant difference:
WARN()taints the kernel and we don't want that for GFP flags misuse.
And doesn't dump_stack do the same? It pollutes the log too.
Quoted 2 lines
Also, from looking at
__warn(), it checkspanic_on_warnand we explode if set.
Right, it is very valid point.
Quoted 2 lines
So no, we probably don't want
WARN()here.
I understand, Thanks.
Quoted 6 lines
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Quoted 1 line · Leon Romanovsky
And doesn't
dump_stackdo the same? It pollutes the log too.
It is not about polluting the log - it is about tainting.
__warn()->add_taint(taint, LOCKDEP_STILL_OK);
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.Quoted 6 lines · Borislav Petkov
Quoted 1 line · Leon Romanovsky
And doesn't
dump_stackdo the same? It pollutes the log too.It is not about polluting the log - it is about tainting.
__warn()->add_taint(taint,
LOCKDEP_STILL_OK);
Thanks,
I had something different in mind for word "taint". Sorry for that.
Quoted 6 lines
--
Regards/Gruss,
Boris.Good mailing practices for 400: avoid top-posting and trim the reply.
Quoted 24 lines · Leon Romanovsky
Quoted 23 lines · Borislav Petkov
Quoted 21 lines · Leon Romanovsky
Quoted 14 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.Signed-off-by Borislav Petkov <[email protected]>--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)mm/slub.c +0
-0mm/slub.c static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) · line 1626
Quoted 4 lines
mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack ();Will it make sense to change these two lines above to
WARN(true, .....)?
Quoted 7 lines
Quoted 1 line
Should be equivalent.
Almost, except one point -
pr_warnanddump_stackhave different log levels. There is a chance that user won't seepr_warnmessage above, butdump_stackwill be always present.For
WARN_XXX, users will always see message and stack at the same time.
On the other hand WARN* will taint the kernel and this sounds a bit overreacting for something like a wrong gfp mask which is perfectly recoverable. Not to mention users who care configured to panic on warning.
So while I do not have a strong opinion on this I would rather stay with the dump_stack.
Signature · 8 lines
Michal Hocko SUSE Labs -- 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>
[Let's add Andrew]
Quoted 3 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.
Yes this was an omission on my side in 72baeef0c271 ("slab: do not panic on invalid gfp_mask").
Quoted 2 lines
Signed-off-by Borislav Petkov <[email protected]>
Thanks!
Quoted 18 lines
--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack (); } return allocate_slab(s,Signature · 1 line
2.11.0
Signature · 8 lines
Michal Hocko SUSE Labs -- 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>
Quoted 5 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
We wanna know who's doing such a thing. Like
slab.cdoes that.Signed-off-by Borislav Petkov <[email protected]>
Quoted 10 lines
--- mm/slub.c | 1 + 1 file changed, 1 insertion(+)mm/slub.c +0
-0
mm/slub.c static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) · line 1629
Quoted 7 lines
mm/slub.c +1
-0@@ -1623,6 +1623,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) flags &= ~GFP_SLAB_BUG_MASK ;pr_warn ("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n" , invalid_mask, &invalid_mask, flags, &flags); +dump_stack (); } return allocate_slab(s,
--
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>