diff mbox

[1/5] powerpc: Print MSR TM bits in oops message

Message ID 1447390652-28355-1-git-send-email-mikey@neuling.org (mailing list archive)
State Superseded
Headers show

Commit Message

Michael Neuling Nov. 13, 2015, 4:57 a.m. UTC
Print the MSR TM bits in oops messages.  This appends them to the end
like this:
 MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>

You get the TM[] only if at least one TM MSR bit is set.  Inside the
TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T
means Transactional (bit 34)

If no bits are set, you get no TM[] output.

Include rework of printbits() to handle this case.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 arch/powerpc/kernel/process.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)

Comments

Anshuman Khandual Nov. 16, 2015, 7:22 a.m. UTC | #1
On 11/13/2015 10:27 AM, Michael Neuling wrote:
> Print the MSR TM bits in oops messages.  This appends them to the end
> like this:
>  MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>
> 
> You get the TM[] only if at least one TM MSR bit is set.  Inside the
> TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T
> means Transactional (bit 34)
> 
> If no bits are set, you get no TM[] output.
> 
> Include rework of printbits() to handle this case.
> 

Just a small nit, the above commit message can be formatted better.
Michael Ellerman Nov. 16, 2015, 9:27 a.m. UTC | #2
On Fri, 2015-11-13 at 15:57 +1100, Michael Neuling wrote:

> Print the MSR TM bits in oops messages.  This appends them to the end
> like this:
>  MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>
> 
> You get the TM[] only if at least one TM MSR bit is set.  Inside the
> TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T
> means Transactional (bit 34)

Can you duplicate this into a comment in printtmbits() or on the bit
definitions, so that I don't have to look up the commit to find the
explanation.

> +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> +static struct regbit msr_tm_bits[] = {
> +	{MSR_TS_T,	"T"},
> +	{MSR_TS_S,	"S"},
> +	{MSR_TM,	"E"},
> +	{0,		NULL}
> +};
> +static void printtmbits(unsigned long val)

I realise you followed the lead here with the naming, but can you call it
print_tm_bits() please. MY EYES!

> +{
> +	if (val & (MSR_TM | MSR_TS_S | MSR_TS_T)) {
> +		printk(",TM[");
> +		printbits(val, msr_tm_bits, "");
> +		printk("]");

I suspect all these individual printks are going to behave badly if we have
multiple cpus crashing simultaneously. But I won't make you fix that here. We
should look at it sometime though.

cheers
Anton Blanchard Nov. 16, 2015, 10:07 p.m. UTC | #3
Hi,

> > +{
> > +	if (val & (MSR_TM | MSR_TS_S | MSR_TS_T)) {
> > +		printk(",TM[");
> > +		printbits(val, msr_tm_bits, "");
> > +		printk("]");
> 
> I suspect all these individual printks are going to behave badly if
> we have multiple cpus crashing simultaneously. But I won't make you
> fix that here. We should look at it sometime though.

We really need to serialise the entire oops. I had a go at fixing this
but ran out of steam:

https://lkml.org/lkml/2015/2/23/735

Anton
Michael Neuling Nov. 17, 2015, 10:01 a.m. UTC | #4
On Mon, 2015-11-16 at 20:27 +1100, Michael Ellerman wrote:
> On Fri, 2015-11-13 at 15:57 +1100, Michael Neuling wrote:
> 
> > Print the MSR TM bits in oops messages.  This appends them to the
> > end
> > like this:
> >  MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>
> > 
> > You get the TM[] only if at least one TM MSR bit is set.  Inside
> > the
> > TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T
> > means Transactional (bit 34)
> 
> Can you duplicate this into a comment in printtmbits() or on the bit
> definitions, so that I don't have to look up the commit to find the
> explanation.

Ok.

> > +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> > +static struct regbit msr_tm_bits[] = {
> > +	{MSR_TS_T,	"T"},
> > +	{MSR_TS_S,	"S"},
> > +	{MSR_TM,	"E"},
> > +	{0,		NULL}
> > +};
> > +static void printtmbits(unsigned long val)
> 
> I realise you followed the lead here with the naming, but can you
> call it
> print_tm_bits() please. MY EYES!

Ok, I've change the rest too -> print_msr_bits(), print_tm_bits(),
print_bits()

> 
> > +{
> > +	if (val & (MSR_TM | MSR_TS_S | MSR_TS_T)) {
> > +		printk(",TM[");
> > +		printbits(val, msr_tm_bits, "");
> > +		printk("]");
> 
> I suspect all these individual printks are going to behave badly if
> we have
> multiple cpus crashing simultaneously. But I won't make you fix that
> here. We
> should look at it sometime though.

Seems anton failed at this one a while back, and since I'm mortal I
might skip this one :-)

Mikey
diff mbox

Patch

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 75b6676..5fbe5d8 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -934,10 +934,12 @@  static void show_instructions(struct pt_regs *regs)
 	printk("\n");
 }
 
-static struct regbit {
+struct regbit {
 	unsigned long bit;
 	const char *name;
-} msr_bits[] = {
+};
+
+static struct regbit msr_bits[] = {
 #if defined(CONFIG_PPC64) && !defined(CONFIG_BOOKE)
 	{MSR_SF,	"SF"},
 	{MSR_HV,	"HV"},
@@ -967,16 +969,41 @@  static struct regbit {
 	{0,		NULL}
 };
 
-static void printbits(unsigned long val, struct regbit *bits)
+static void printbits(unsigned long val, struct regbit *bits, const char *sep)
 {
-	const char *sep = "";
+	const char *s = "";
 
-	printk("<");
 	for (; bits->bit; ++bits)
 		if (val & bits->bit) {
-			printk("%s%s", sep, bits->name);
-			sep = ",";
+			printk("%s%s", s, bits->name);
+			s = sep;
 		}
+}
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+static struct regbit msr_tm_bits[] = {
+	{MSR_TS_T,	"T"},
+	{MSR_TS_S,	"S"},
+	{MSR_TM,	"E"},
+	{0,		NULL}
+};
+static void printtmbits(unsigned long val)
+{
+	if (val & (MSR_TM | MSR_TS_S | MSR_TS_T)) {
+		printk(",TM[");
+		printbits(val, msr_tm_bits, "");
+		printk("]");
+	}
+}
+#else
+static void printtmbits(unsigned long val) {}
+#endif
+
+static void printmsrbits(unsigned long val)
+{
+	printk("<");
+	printbits(val, msr_bits, ",");
+	printtmbits(val);
 	printk(">");
 }
 
@@ -1001,7 +1028,7 @@  void show_regs(struct pt_regs * regs)
 	printk("REGS: %p TRAP: %04lx   %s  (%s)\n",
 	       regs, regs->trap, print_tainted(), init_utsname()->release);
 	printk("MSR: "REG" ", regs->msr);
-	printbits(regs->msr, msr_bits);
+	printmsrbits(regs->msr);
 	printk("  CR: %08lx  XER: %08lx\n", regs->ccr, regs->xer);
 	trap = TRAP(regs);
 	if ((regs->trap != 0xc00) && cpu_has_feature(CPU_FTR_CFAR))