decode GFP flags in oom killer output.
Subsystems (4)
Decoding these flags by hand in oom reports is tedious, and error-prone.
include/linux/gfp.h +1 -0
@@ -10,6 +10,7 @@struct vm_area_struct ;/* Plain integer GFP bitmasks. Do not use this directly. */ +/* Update mm/oom_kill.c gfp_flag_texts when adding to/changing this list */ #define ___GFP_DMA 0x01u#define ___GFP_HIGHMEM 0x02u#define ___GFP_DMA32 0x04u
mm/oom_kill.c +29 -2
@@ -416,13 +416,40 @@ static void dump_tasks(const struct mem_ } } +static unsigned char *gfp_flag_texts[32 ] = { +"DMA" ,"HIGHMEM" ,"DMA32" ,"MOVABLE" , +"WAIT" ,"HIGH" ,"IO" ,"FS" , +"COLD" ,"NOWARN" ,"REPEAT" ,"NOFAIL" , +"NORETRY" ,NULL ,"COMP" ,"ZERO" , +"NOMEMALLOC" ,"HARDWALL" ,"THISNODE" ,"RECLAIMABLE" , +NULL ,"NOTRACK" ,"NO_KSWAPD" ,"OTHER_NODE" , +}; + +static void decode_gfp_mask (gfp_t gfp_mask,char *out_string) +{ +unsigned int i; + +for (i =0 ; i <32 ; i++) { +if (gfp_mask & (1 << i)) { +if (gfp_flag_texts[i]) + out_string +=sprintf (out_string,"%s " , gfp_flag_texts[i]); +else + out_string +=sprintf (out_string,"reserved! " ); + } + } + out_string ="\0" ; +} +static void dump_header (struct task_struct *p,gfp_t gfp_mask,int order,struct mem_cgroup *memcg,const nodemask_t *nodemask) { +char gfp_string[80 ];task_lock (current); -pr_warning ("%s invoked oom-killer: gfp_mask=0x%x, order=%d, " +decode_gfp_mask (gfp_mask, gfp_string); +pr_warning ("%s invoked oom-killer: gfp_mask=0x%x [%s], order=%d, " "oom_adj=%d, oom_score_adj=%d\n" , - current->comm, gfp_mask, order, current->signal->oom_adj, + current->comm, gfp_mask, gfp_string, + order, current->signal->oom_adj, current->signal->oom_score_adj);cpuset_print_task_mems_allowed (current);task_unlock (current);
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 33 lines · Dave Jones
Decoding these flags by hand in oom reports is tedious, and error-prone.
Signed-off-by Dave Jones <[email protected]>diff -durpN '--exclude-from=/home/davej/.exclude' -u
src/git-trees/kernel/linux/include/linux/gfp.hlinux-dj/include/linux/gfp.hinclude/linux/gfp.h +1
-0@@ -10,6 +10,7 @@struct vm_area_struct ;/* Plain integer GFP bitmasks. Do not use this directly. */ +/* Update mm/oom_kill.c gfp_flag_texts when adding to/changing this list */ #define ___GFP_DMA 0x01u#define ___GFP_HIGHMEM 0x02u#define ___GFP_DMA32 0x04udiff -durpN '--exclude-from=/home/davej/.exclude' -u
src/git-trees/kernel/linux/mm/oom_kill.clinux-dj/mm/oom_kill.cmm/oom_kill.c +12
-0@@ -416,13 +416,40 @@ static void dump_tasks(const struct mem_ } } +static unsigned char *gfp_flag_texts[32 ] = { +"DMA" ,"HIGHMEM" ,"DMA32" ,"MOVABLE" , +"WAIT" ,"HIGH" ,"IO" ,"FS" , +"COLD" ,"NOWARN" ,"REPEAT" ,"NOFAIL" , +"NORETRY" ,NULL ,"COMP" ,"ZERO" , +"NOMEMALLOC" ,"HARDWALL" ,"THISNODE" ,"RECLAIMABLE" , +NULL ,"NOTRACK" ,"NO_KSWAPD" ,"OTHER_NODE" , +}; + +static void decode_gfp_mask (gfp_t gfp_mask,char *out_string) +{ +unsigned int i;
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 439
Quoted 10 lines
mm/oom_kill.c +10
-0+ +for (i =0 ; i <32 ; i++) { +if (gfp_mask & (1 << i)) { +if (gfp_flag_texts[i]) + out_string +=sprintf (out_string,"%s " , gfp_flag_texts[i]); +else + out_string +=sprintf (out_string,"reserved! " ); + } + } + out_string ="\0" ;
Uh? Did you mean “*out_string = 0;” which is redundant anyway?
Also, this leaves a trailing space at the end of the string.
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 446
Quoted 6 lines
mm/oom_kill.c +3
-0+} +static void dump_header (struct task_struct *p,gfp_t gfp_mask,int order,struct mem_cgroup *memcg,const nodemask_t *nodemask) { +char gfp_string[80 ];
For ~0, the string will be 256 characters followed by a NUL byte byte at the end. This combination may make no sense, but the point is that you need to take length of the buffer into account, probably by using snprintf() and a counter.
Quoted 19 lines
mm/oom_kill.c +4
-3task_lock (current); -pr_warning ("%s invoked oom-killer: gfp_mask=0x%x, order=%d, " +decode_gfp_mask (gfp_mask, gfp_string); +pr_warning ("%s invoked oom-killer: gfp_mask=0x%x [%s], order=%d, " "oom_adj=%d, oom_score_adj=%d\n" , - current->comm, gfp_mask, order, current->signal->oom_adj, + current->comm, gfp_mask, gfp_string, + order, current->signal->oom_adj, current->signal->oom_score_adj);cpuset_print_task_mems_allowed (current);task_unlock (current); --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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 11 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Michal Nazarewicz
Quoted 7 lines
mm/oom_kill.c +7
-0+static void decode_gfp_mask (gfp_t gfp_mask,char *out_string) +{ +unsigned int i; + +for (i =0 ; i <32 ; i++) { +if (gfp_mask & (1 << i)) { +if (gfp_flag_texts[i])
Quoted 8 lines
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 440
Quoted 6 lines
mm/oom_kill.c +6
-0+ out_string +=sprintf (out_string,"%s " , gfp_flag_texts[i]); + else + out_string += sprintf(out_string, "reserved! "); + } + } + out_string ="\0" ;Uh? Did you mean a??*out_string = 0;a?? which is redundant anyway?
Yeah, that was the intent.
Quoted 1 line
Also, this leaves a trailing space at the end of the string.
The zero was supposed to wipe it out, but I just realized it's advanced past it.
Quoted 8 lines
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 446
Quoted 4 lines
static void dump_header(struct
task_struct*p,gfp_tgfp_mask, int order,mm/oom_kill.c +1
-0struct mem_cgroup *memcg, const nodemask_t *nodemask) { + char gfp_string[80];For ~0, the string will be 256 characters followed by a NUL byte byte at the end. This combination may make no sense, but the point is that you need to take length of the buffer into account, probably by using
snprintf()and a counter.
alternatively, we could just use a bigger buffer here.
thanks,
Dave
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Dave Jones
Quoted 8 lines · Michal Nazarewicz
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 446
Quoted 4 lines
static void dump_header(struct
task_struct*p,gfp_tgfp_mask, int order,mm/oom_kill.c +1
-0struct mem_cgroup *memcg, const nodemask_t *nodemask) { + char gfp_string[80];For ~0, the string will be 256 characters followed by a NUL byte byte at the end. This combination may make no sense, but the point is that you need to take length of the buffer into account, probably by using
snprintf()and a counter.alternatively, we could just use a bigger buffer here.
Allocating 257 bytes on stack does not seem like a good idea especially inside of OOM killer, where probably quite a bit of the stack was already consumed prior to reaching this function.
Signature · 11 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 21 lines · Dave Jones
Decoding these flags by hand in oom reports is tedious, and error-prone.
Signed-off-by Dave Jones <[email protected]>diff -durpN '--exclude-from=/home/davej/.exclude' -u
src/git-trees/kernel/linux/include/linux/gfp.hlinux-dj/include/linux/gfp.hinclude/linux/gfp.h +1
-0@@ -10,6 +10,7 @@struct vm_area_struct ;/* Plain integer GFP bitmasks. Do not use this directly. */ +/* Update mm/oom_kill.c gfp_flag_texts when adding to/changing this list */ #define ___GFP_DMA 0x01u#define ___GFP_HIGHMEM 0x02u#define ___GFP_DMA32 0x04udiff -durpN '--exclude-from=/home/davej/.exclude' -u
src/git-trees/kernel/linux/mm/oom_kill.clinux-dj/mm/oom_kill.cmm/oom_kill.c +0
-0@@ -416,13 +416,40 @@ static void dump_tasks(const struct mem_ }
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 426
Quoted 10 lines
mm/oom_kill.c +8
-0} +static unsigned char *gfp_flag_texts[32 ] = { +"DMA" ,"HIGHMEM" ,"DMA32" ,"MOVABLE" , +"WAIT" ,"HIGH" ,"IO" ,"FS" , +"COLD" ,"NOWARN" ,"REPEAT" ,"NOFAIL" , +"NORETRY" ,NULL ,"COMP" ,"ZERO" , +"NOMEMALLOC" ,"HARDWALL" ,"THISNODE" ,"RECLAIMABLE" , +NULL ,"NOTRACK" ,"NO_KSWAPD" ,"OTHER_NODE" , +};
Hmm, there are 24 entries in this list, yet you allocate an array of size 32 - why?
Shouldn't this just be 'static unsigned char *gfp_flag_texts[] = {...}' and let the compiler worry about the size? Or am I overlooking something obvious?
Signature · 10 lines
Jesper Juhl <[email protected]> http://www.chaosbits.net/ Don't top-post http://www.catb.org/jargon/html/T/top-post.html Plain text mails only, please. -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 3 lines · Dave Jones
Decoding these flags by hand in oom reports is tedious, and error-prone.
Something like this is already done in include/trace/events/gfpflags.h so there should be a generic version of this or something you can already use.
The problem here is that you have to allocate an additional 80-bytes for the string and the oom killer is notorious for being called deep in the stack and you can't statically allocate a string buffer without adding additional syncronization.
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Dave Jones
Decoding these flags by hand in oom reports is tedious, and error-prone.
trivial notes...
Quoted 1 line
diff -durpN '--exclude-from=/home/davej/.exclude' -u
src/git-trees/kernel/linux/mm/oom_kill.clinux-dj/mm/oom_kill.c
[]
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 419
Quoted 5 lines
mm/oom_kill.c +1
-0@@ -416,13 +416,40 @@ static void dump_tasks(const struct mem_ } } +static unsigned char *gfp_flag_texts[32 ] = {
static const char *gfp_flags_text[sizeof(gfp_t) * 8)
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 432
Quoted 13 lines
mm/oom_kill.c +13
-0+"DMA" ,"HIGHMEM" ,"DMA32" ,"MOVABLE" , +"WAIT" ,"HIGH" ,"IO" ,"FS" , +"COLD" ,"NOWARN" ,"REPEAT" ,"NOFAIL" , +"NORETRY" ,NULL ,"COMP" ,"ZERO" , +"NOMEMALLOC" ,"HARDWALL" ,"THISNODE" ,"RECLAIMABLE" , + NULL, "NOTRACK", "NO_KSWAPD", "OTHER_NODE", +}; + +static void decode_gfp_mask (gfp_t gfp_mask,char *out_string) +{ +unsigned int i; + +for (i =0 ; i <32 ; i++) {
< sizeof(gfp_t * 8)
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 433
Quoted 1 line
mm/oom_kill.c +1
-0+if (gfp_mask & (1 << i)) {
(gfp_t)1 << i
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 437
Quoted 4 lines
mm/oom_kill.c +4
-0+if (gfp_flag_texts[i]) + out_string +=sprintf (out_string,"%s " , gfp_flag_texts[i]); +else + out_string +=sprintf (out_string,"reserved! " );
not much use to exclamation points.
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 440
Quoted 3 lines
mm/oom_kill.c +3
-0+ } + } + out_string ="\0" ;
out_string[-1] = 0;
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 446
Quoted 6 lines
mm/oom_kill.c +3
-0+} +static void dump_header (struct task_struct *p,gfp_t gfp_mask,int order,struct mem_cgroup *memcg,const nodemask_t *nodemask) { +char gfp_string[80 ];
maybe a static buffer instead of stack?
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 450
Quoted 5 lines
mm/oom_kill.c +2
-1task_lock (current); - pr_warning("%s invoked oom-killer: gfp_mask=0x%x, order=%d, " +decode_gfp_mask (gfp_mask, gfp_string); + pr_warning("%s invoked oom-killer: gfp_mask=0x%x [%s], order=%d, " "oom_adj=%d, oom_score_adj=%d\n",
Maybe nicer to coalesce the format.
Quoted 8 lines
mm/oom_kill.c +2
-2- current->comm, gfp_mask, order, current->signal->oom_adj, + current->comm, gfp_mask, gfp_string, + order, current->signal->oom_adj, current->signal->oom_score_adj);cpuset_print_task_mems_allowed (current);task_unlock (current); --
Quoted 5 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 20 lines · Joe Perches
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 432
Quoted 5 lines · Dave Jones
mm/oom_kill.c +5
-0+static void decode_gfp_mask (gfp_t gfp_mask,char *out_string) +{ +unsigned int i; + +for (i =0 ; i <32 ; i++) {<
sizeof(gfp_t * 8)mm/oom_kill.c static void dump_tasks(const struct mem_ · line 433
Quoted 1 line
mm/oom_kill.c +1
-0+if (gfp_mask & (1 << i)) {(gfp_t)1 << i
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 437
Quoted 4 lines
mm/oom_kill.c +4
-0+if (gfp_flag_texts[i]) + out_string +=sprintf (out_string,"%s " , gfp_flag_texts[i]); +else + out_string +=sprintf (out_string,"reserved! " );not much use to exclamation points.
Quoted 5 lines
mm/oom_kill.c static void dump_tasks(const struct mem_ · line 440
Quoted 3 lines
mm/oom_kill.c +3
-0+ } + } + out_string ="\0" ;out_string[-1] = 0;
Will break if gfp_mask == 0.
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+} +
Signature · 11 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: [email protected]>--------------ooO--(_)--Ooo-- -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 3 lines · Dave Jones
Decoding these flags by hand in oom reports is tedious, and error-prone.
It's not really a proper solution but scripts/gfp-translate is less error-prone than doing it by hand but requires that you have the kernel source available.
Signature · 9 lines
Mel Gorman 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>