LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
@ 2026-09-07  5:14 Athira Rajeev
  2026-11-28 10:40 ` Tejas
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Athira Rajeev @ 2026-09-07  5:14 UTC (permalink / raw)
  To: acme, jolsa, adrian.hunter, maddy, irogers, namhyung
  Cc: linux-perf-users, linuxppc-dev, atrajeev, hbathini, tejas05,
	tshah, venkat88, narnalli, vpuliyal

Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
emits these as two lines: the first carries both the raw bytes and the
mnemonic, while the second carries only the raw bytes of the second word
with no mnemonic:

  1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
  10209010:  20 8e e0 3b

disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
portion of the line.  disasm_line__parse() returns -1 when the name
string is empty, which causes disasm_line__new() to return NULL, which
causes symbol__parse_objdump_line() to return -1, which immediately
breaks the objdump output parsing loop in symbol__disassemble_objdump().

The result is that annotation of any function containing a prefixed
instruction stops at the continuation word and all subsequent
instructions in the function are lost.

Fix this by treating an empty mnemonic as a valid case in
disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
set the instruction name to an empty heap-allocated string instead,
allowing parsing to continue to the next line.

Reported-by: Narendra Nalli <narnalli@in.ibm.com>
Reported-by: Vijay Puliyala <vpuliyal@in.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
---
 tools/perf/util/disasm.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index e263a2a8715d..8dca703a5c74 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
 	if (name_raw_insn[0] == '\0')
 		return -1;
 
-	if (disasm)
-		ret = disasm_line__parse(name, namep, rawp);
-	else
+	if (disasm) {
+		/*
+		 * Power10 prefixed instructions are 8 bytes and objdump emits
+		 * the second word on its own line with raw bytes but no
+		 * mnemonic, e.g.:
+		 *   1020900c:  0b 00 10 06  pla  r31,757280
+		 *   10209010:  20 8e e0 3b
+		 *
+		 * Treat a missing mnemonic as an empty instruction name rather
+		 * than a parse failure, so that parsing continues past it.
+		 */
+		if (name[0] != '\0')
+			ret = disasm_line__parse(name, namep, rawp);
+		else
+			*namep = strdup("");
+	} else {
 		*namep = "";
+	}
 
 	tmp_raw_insn = strndup(name_raw_insn, 11);
 	if (tmp_raw_insn == NULL)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
@ 2026-11-28 10:40 ` Tejas
  2026-11-28 11:41 ` Tejas
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Tejas @ 2026-11-28 10:40 UTC (permalink / raw)
  To: Athira Rajeev, acme, jolsa, adrian.hunter, maddy, irogers,
	namhyung
  Cc: linux-perf-users, linuxppc-dev, hbathini, tshah, venkat88,
	narnalli, vpuliyal

[-- Attachment #1: Type: text/plain, Size: 3892 bytes --]


On 07/09/26 10:44 am, Athira Rajeev wrote:

> Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
> emits these as two lines: the first carries both the raw bytes and the
> mnemonic, while the second carries only the raw bytes of the second word
> with no mnemonic:
>
>    1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
>    10209010:  20 8e e0 3b
>
> disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
> portion of the line.  disasm_line__parse() returns -1 when the name
> string is empty, which causes disasm_line__new() to return NULL, which
> causes symbol__parse_objdump_line() to return -1, which immediately
> breaks the objdump output parsing loop in symbol__disassemble_objdump().
>
> The result is that annotation of any function containing a prefixed
> instruction stops at the continuation word and all subsequent
> instructions in the function are lost.
>
> Fix this by treating an empty mnemonic as a valid case in
> disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
> set the instruction name to an empty heap-allocated string instead,
> allowing parsing to continue to the next line.
>
> Reported-by: Narendra Nalli<narnalli@in.ibm.com>
> Reported-by: Vijay Puliyala<vpuliyal@in.ibm.com>
> Signed-off-by: Athira Rajeev<atrajeev@linux.ibm.com>
> ---
>   tools/perf/util/disasm.c | 20 +++++++++++++++++---
>   1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
> index e263a2a8715d..8dca703a5c74 100644
> --- a/tools/perf/util/disasm.c
> +++ b/tools/perf/util/disasm.c
> @@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
>   	if (name_raw_insn[0] == '\0')
>   		return -1;
>   
> -	if (disasm)
> -		ret = disasm_line__parse(name, namep, rawp);
> -	else
> +	if (disasm) {
> +		/*
> +		 * Power10 prefixed instructions are 8 bytes and objdump emits
> +		 * the second word on its own line with raw bytes but no
> +		 * mnemonic, e.g.:
> +		 *   1020900c:  0b 00 10 06  pla  r31,757280
> +		 *   10209010:  20 8e e0 3b
> +		 *
> +		 * Treat a missing mnemonic as an empty instruction name rather
> +		 * than a parse failure, so that parsing continues past it.
> +		 */
> +		if (name[0] != '\0')
> +			ret = disasm_line__parse(name, namep, rawp);
> +		else
> +			*namep = strdup("");
> +	} else {
>   		*namep = "";
> +	}
>   
>   	tmp_raw_insn = strndup(name_raw_insn, 11);
>   	if (tmp_raw_insn == NULL)


Hi Athira, Setup: - gcc 11.5.0 - Base: torvalds/linux master at 
7cd8495c0f16 - perf built with libLLVM on. The default disassembler 
order puts LLVM first, so I set annotate.disassemblers = objdump in a 
private perfconfig file to make perf use objdump. "perf annotate -v" 
printed "Disassembled with objdump". Test: A small loop built with -O2 
-mcpu=power10 -mpcrel -mprefixed, which contains prefixed instructions 
(pli at the start of main, pla in the loop preamble). Recorded with 
"perf record -e cpu-clock", then "perf annotate --stdio main". Results: 
- Without the patch, the output stops after the first prefixed 
instruction (11 lines). The last line is: 10000440: 68 59 00 06 pli 
r8,1500000000 and everything after it is lost, including the "blr" at 
the end of main. - With the patch, the output has 32 lines. The 
continuation words appear as raw-byte lines with no mnemonic (10000444 
and 10000454), and the function is shown through to "blr" at 10000490. 
There is no "(null)" in the output. - I also ran "perf annotate" under 
valgrind on both builds. The error counts were identical (same 103 
contexts), and I saw no invalid read, write or free tied to the new 
code. I tested only this patch, on its own on top of master. I did not 
test the rest of the build-id series. Tested-by: Tejas Manhas 
<tejas05@linux.ibm.com> Thanks, Tejas Manhas

[-- Attachment #2: Type: text/html, Size: 5027 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
  2026-11-28 10:40 ` Tejas
@ 2026-11-28 11:41 ` Tejas
  2026-11-28 12:38 ` Tejas
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Tejas @ 2026-11-28 11:41 UTC (permalink / raw)
  To: Athira Rajeev, acme, jolsa, adrian.hunter, maddy, irogers,
	namhyung
  Cc: linux-perf-users, linuxppc-dev, hbathini, tshah, venkat88,
	narnalli, vpuliyal

[-- Attachment #1: Type: text/plain, Size: 3805 bytes --]


     

On 07/09/26 10:44 am, Athira Rajeev wrote:

       

Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
emits these as two lines: the first carries both the raw bytes and the
mnemonic, while the second carries only the raw bytes of the second word
with no mnemonic:

   1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
   10209010:  20 8e e0 3b

disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
portion of the line.  disasm_line__parse() returns -1 when the name
string is empty, which causes disasm_line__new() to return NULL, which
causes symbol__parse_objdump_line() to return -1, which immediately
breaks the objdump output parsing loop in symbol__disassemble_objdump().

The result is that annotation of any function containing a prefixed
instruction stops at the continuation word and all subsequent
instructions in the function are lost.

Fix this by treating an empty mnemonic as a valid case in
disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
set the instruction name to an empty heap-allocated string instead,
allowing parsing to continue to the next line.

Reported-by: Narendra Nalli<narnalli@in.ibm.com>
Reported-by: Vijay Puliyala<vpuliyal@in.ibm.com>
Signed-off-by: Athira Rajeev<atrajeev@linux.ibm.com>
---
  tools/perf/util/disasm.c | 20 +++++++++++++++++---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index e263a2a8715d..8dca703a5c74 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
  	if (name_raw_insn[0] == '\0')
  		return -1;
  
-	if (disasm)
-		ret = disasm_line__parse(name, namep, rawp);
-	else
+	if (disasm) {
+		/*
+		 * Power10 prefixed instructions are 8 bytes and objdump emits
+		 * the second word on its own line with raw bytes but no
+		 * mnemonic, e.g.:
+		 *   1020900c:  0b 00 10 06  pla  r31,757280
+		 *   10209010:  20 8e e0 3b
+		 *
+		 * Treat a missing mnemonic as an empty instruction name rather
+		 * than a parse failure, so that parsing continues past it.
+		 */
+		if (name[0] != '\0')
+			ret = disasm_line__parse(name, namep, rawp);
+		else
+			*namep = strdup("");
+	} else {
  		*namep = "";
+	}
  
  	tmp_raw_insn = strndup(name_raw_insn, 11);
  	if (tmp_raw_insn == NULL)


     


     

Hi Athira, Setup: - gcc 11.5.0 - Base: torvalds/linux master at 
7cd8495c0f16 - perf built with libLLVM on. The default disassembler 
order puts LLVM first, so I set annotate.disassemblers = objdump in a 
private perfconfig file to make perf use objdump. "perf annotate -v" 
printed "Disassembled with objdump". Test: A small loop built with -O2 
-mcpu=power10 -mpcrel -mprefixed, which contains prefixed instructions 
(pli at the start of main, pla in the loop preamble). Recorded with 
"perf record -e cpu-clock", then "perf annotate --stdio main". Results: 
- Without the patch, the output stops after the first prefixed 
instruction (11 lines). The last line is: 10000440: 68 59 00 06 pli 
r8,1500000000 and everything after it is lost, including the "blr" at 
the end of main. - With the patch, the output has 32 lines. The 
continuation words appear as raw-byte lines with no mnemonic (10000444 
and 10000454), and the function is shown through to "blr" at 10000490. 
There is no "(null)" in the output. - I also ran "perf annotate" under 
valgrind on both builds. The error counts were identical (same 103 
contexts), and I saw no invalid read, write or free tied to the new 
code. I tested only this patch, on its own on top of master. I did not 
test the rest of the build-id series. Tested-by: Tejas Manhas 
<tejas05@linux.ibm.com> Thanks, Tejas Manhas

[-- Attachment #2: Type: text/html, Size: 5121 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
  2026-11-28 10:40 ` Tejas
  2026-11-28 11:41 ` Tejas
@ 2026-11-28 12:38 ` Tejas
  2026-11-28 12:42 ` Bradley Morgan
  2026-11-28 12:43 ` Tejas
  4 siblings, 0 replies; 8+ messages in thread
From: Tejas @ 2026-11-28 12:38 UTC (permalink / raw)
  To: Athira Rajeev, acme, jolsa, adrian.hunter, maddy, irogers,
	namhyung
  Cc: linux-perf-users, linuxppc-dev, hbathini, tshah, venkat88,
	narnalli, vpuliyal

[-- Attachment #1: Type: text/plain, Size: 3861 bytes --]


     

On 07/09/26 10:44 am, Athira Rajeev wrote:

       

Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
emits these as two lines: the first carries both the raw bytes and the
mnemonic, while the second carries only the raw bytes of the second word
with no mnemonic:

   1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
   10209010:  20 8e e0 3b

disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
portion of the line.  disasm_line__parse() returns -1 when the name
string is empty, which causes disasm_line__new() to return NULL, which
causes symbol__parse_objdump_line() to return -1, which immediately
breaks the objdump output parsing loop in symbol__disassemble_objdump().

The result is that annotation of any function containing a prefixed
instruction stops at the continuation word and all subsequent
instructions in the function are lost.

Fix this by treating an empty mnemonic as a valid case in
disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
set the instruction name to an empty heap-allocated string instead,
allowing parsing to continue to the next line.

Reported-by: Narendra Nalli<narnalli@in.ibm.com>
Reported-by: Vijay Puliyala<vpuliyal@in.ibm.com>
Signed-off-by: Athira Rajeev<atrajeev@linux.ibm.com>
---
  tools/perf/util/disasm.c | 20 +++++++++++++++++---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index e263a2a8715d..8dca703a5c74 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
  	if (name_raw_insn[0] == '\0')
  		return -1;
  
-	if (disasm)
-		ret = disasm_line__parse(name, namep, rawp);
-	else
+	if (disasm) {
+		/*
+		 * Power10 prefixed instructions are 8 bytes and objdump emits
+		 * the second word on its own line with raw bytes but no
+		 * mnemonic, e.g.:
+		 *   1020900c:  0b 00 10 06  pla  r31,757280
+		 *   10209010:  20 8e e0 3b
+		 *
+		 * Treat a missing mnemonic as an empty instruction name rather
+		 * than a parse failure, so that parsing continues past it.
+		 */
+		if (name[0] != '\0')
+			ret = disasm_line__parse(name, namep, rawp);
+		else
+			*namep = strdup("");
+	} else {
  		*namep = "";
+	}
  
  	tmp_raw_insn = strndup(name_raw_insn, 11);
  	if (tmp_raw_insn == NULL)


     


Hi Athira,

Setup:
   - ppc64le, gcc 11.5.0
   - Base: torvalds/linux master at 7cd8495c0f16
   - perf built with libLLVM on. The default disassembler order puts
     LLVM first, so I set annotate.disassemblers = objdump in a private
     perfconfig file. "perf annotate -v" printed "Disassembled with
     objdump".

Test:
   A small loop built with -O2 -mcpu=power10 -mpcrel -mprefixed, which
   contains prefixed instructions (pli at the start of main, pla in the
   loop preamble). Recorded with "perf record -e cpu-clock", then
   "perf annotate --stdio main".

Results:
   - Without the patch, the output stops after the first prefixed
     instruction (11 lines). The last line is:
       10000440:  68 59 00 06  pli  r8,1500000000
     and everything after it is lost, including the "blr" at the end
     of main.
   - With the patch, the output has 32 lines. The continuation words
     appear as raw-byte lines with no mnemonic (10000444 and 10000454),
     and the function is shown through to "blr" at 10000490. There is
     no "(null)" in the output.
   - Under valgrind, both builds report the same error totals
     (8290 errors in 103 contexts).
   [- A -mcpu=power9 program, with no prefixed instructions, produces
     identical "perf annotate" output with and without the patch.]

I tested only this patch, on its own on top of master.

Tested-by: Tejas Manhas<tejas05@linux.ibm.com>

Thanks,
Tejas Manhas

[-- Attachment #2: Type: text/html, Size: 4564 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
                   ` (2 preceding siblings ...)
  2026-11-28 12:38 ` Tejas
@ 2026-11-28 12:42 ` Bradley Morgan
  2026-11-29 23:21   ` Namhyung Kim
  2026-11-28 12:43 ` Tejas
  4 siblings, 1 reply; 8+ messages in thread
From: Bradley Morgan @ 2026-11-28 12:42 UTC (permalink / raw)
  To: atrajeev
  Cc: acme, adrian.hunter, hbathini, irogers, jolsa, linux-perf-users,
	linuxppc-dev, maddy, namhyung, narnalli, tejas05, tshah, venkat88,
	vpuliyal

On 7 September 2026 06:14:29 BST, Athira Rajeev <atrajeev@linux.ibm.com>
wrote:
>Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
>emits these as two lines: the first carries both the raw bytes and the
>mnemonic, while the second carries only the raw bytes of the second word
>with no mnemonic:
>
>  1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
>  10209010:  20 8e e0 3b
>
>disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
>portion of the line.  disasm_line__parse() returns -1 when the name
>string is empty, which causes disasm_line__new() to return NULL, which
>causes symbol__parse_objdump_line() to return -1, which immediately
>breaks the objdump output parsing loop in symbol__disassemble_objdump().
>
>The result is that annotation of any function containing a prefixed
>instruction stops at the continuation word and all subsequent
>instructions in the function are lost.
>
>Fix this by treating an empty mnemonic as a valid case in
>disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
>set the instruction name to an empty heap-allocated string instead,
>allowing parsing to continue to the next line.
>
>Reported-by: Narendra Nalli <narnalli@in.ibm.com>
>Reported-by: Vijay Puliyala <vpuliyal@in.ibm.com>

yes, thanks

Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>


Tested-by: Bradley Morgan <bradley.morgan@linux.dev> # Power10


>Signed-off-by: Athira Rajeev <atrajeev@linux.ibm.com>
>---
> tools/perf/util/disasm.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
>diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
>index e263a2a8715d..8dca703a5c74 100644
>--- a/tools/perf/util/disasm.c
>+++ b/tools/perf/util/disasm.c
>@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
> 	if (name_raw_insn[0] == '\0')
> 		return -1;
> 
>-	if (disasm)
>-		ret = disasm_line__parse(name, namep, rawp);
>-	else
>+	if (disasm) {
>+		/*
>+		 * Power10 prefixed instructions are 8 bytes and objdump emits
>+		 * the second word on its own line with raw bytes but no
>+		 * mnemonic, e.g.:
>+		 *   1020900c:  0b 00 10 06  pla  r31,757280
>+		 *   10209010:  20 8e e0 3b
>+		 *
>+		 * Treat a missing mnemonic as an empty instruction name rather
>+		 * than a parse failure, so that parsing continues past it.
>+		 */
>+		if (name[0] != '\0')
>+			ret = disasm_line__parse(name, namep, rawp);
>+		else
>+			*namep = strdup("");
>+	} else {
> 		*namep = "";
>+	}
> 
> 	tmp_raw_insn = strndup(name_raw_insn, 11);
> 	if (tmp_raw_insn == NULL)
>

--- Thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
                   ` (3 preceding siblings ...)
  2026-11-28 12:42 ` Bradley Morgan
@ 2026-11-28 12:43 ` Tejas
  2026-11-28 12:47   ` Bradley Morgan
  4 siblings, 1 reply; 8+ messages in thread
From: Tejas @ 2026-11-28 12:43 UTC (permalink / raw)
  To: Athira Rajeev, acme, jolsa, adrian.hunter, maddy, irogers,
	namhyung
  Cc: linux-perf-users, linuxppc-dev, hbathini, tshah, venkat88,
	narnalli, vpuliyal

[-- Attachment #1: Type: text/plain, Size: 3874 bytes --]

On 07/09/26 10:44 am, Athira Rajeev wrote:

Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
emits these as two lines: the first carries both the raw bytes and the
mnemonic, while the second carries only the raw bytes of the second word
with no mnemonic:

   1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
   10209010:  20 8e e0 3b

disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
portion of the line.  disasm_line__parse() returns -1 when the name
string is empty, which causes disasm_line__new() to return NULL, which
causes symbol__parse_objdump_line() to return -1, which immediately
breaks the objdump output parsing loop in symbol__disassemble_objdump().

The result is that annotation of any function containing a prefixed
instruction stops at the continuation word and all subsequent
instructions in the function are lost.

Fix this by treating an empty mnemonic as a valid case in
disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
set the instruction name to an empty heap-allocated string instead,
allowing parsing to continue to the next line.

Reported-by: Narendra Nalli<narnalli@in.ibm.com>
Reported-by: Vijay Puliyala<vpuliyal@in.ibm.com>
Signed-off-by: Athira Rajeev<atrajeev@linux.ibm.com>
---
  tools/perf/util/disasm.c | 20 +++++++++++++++++---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index e263a2a8715d..8dca703a5c74 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
  	if (name_raw_insn[0] == '\0')
  		return -1;
  
-	if (disasm)
-		ret = disasm_line__parse(name, namep, rawp);
-	else
+	if (disasm) {
+		/*
+		 * Power10 prefixed instructions are 8 bytes and objdump emits
+		 * the second word on its own line with raw bytes but no
+		 * mnemonic, e.g.:
+		 *   1020900c:  0b 00 10 06  pla  r31,757280
+		 *   10209010:  20 8e e0 3b
+		 *
+		 * Treat a missing mnemonic as an empty instruction name rather
+		 * than a parse failure, so that parsing continues past it.
+		 */
+		if (name[0] != '\0')
+			ret = disasm_line__parse(name, namep, rawp);
+		else
+			*namep = strdup("");
+	} else {
  		*namep = "";
+	}
  
  	tmp_raw_insn = strndup(name_raw_insn, 11);
  	if (tmp_raw_insn == NULL)

Hi Athira,

Setup:
   - ppc64le, gcc 11.5.0
   - Base: torvalds/linux master at 7cd8495c0f16
   - perf built with libLLVM on. The default disassembler order puts
     LLVM first, so I set annotate.disassemblers = objdump in a private
     perfconfig file. "perf annotate -v" printed "Disassembled with
     objdump".

Test:
   A small loop built with -O2 -mcpu=power10 -mpcrel -mprefixed, which
   contains prefixed instructions (pli at the start of main, pla in the
   loop preamble). Recorded with "perf record -e cpu-clock", then
   "perf annotate --stdio main".

Results:
   - Without the patch, the output stops after the first prefixed
     instruction (11 lines). The last line is:
       10000440:  68 59 00 06  pli  r8,1500000000
     and everything after it is lost, including the "blr" at the end
     of main.
   - With the patch, the output has 32 lines. The continuation words
     appear as raw-byte lines with no mnemonic (10000444 and 10000454),
     and the function is shown through to "blr" at 10000490. There is
     no "(null)" in the output.
   - Under valgrind, both builds report the same error totals
     (8290 errors in 103 contexts).
   [- A -mcpu=power9 program, with no prefixed instructions, produces
     identical "perf annotate" output with and without the patch.]

I tested only this patch, on its own on top of master.

Tested-by: Tejas Manhas<tejas05@linux.ibm.com>

Thanks,
Tejas Manhas

[-- Attachment #2: Type: text/html, Size: 4659 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-11-28 12:43 ` Tejas
@ 2026-11-28 12:47   ` Bradley Morgan
  0 siblings, 0 replies; 8+ messages in thread
From: Bradley Morgan @ 2026-11-28 12:47 UTC (permalink / raw)
  To: tejas05
  Cc: acme, adrian.hunter, atrajeev, hbathini, irogers, jolsa,
	linux-perf-users, linuxppc-dev, maddy, namhyung, narnalli, tshah,
	venkat88, vpuliyal

On 28 November 2026 12:43:57 GMT, Tejas <tejas05@linux.ibm.com> wrote:
>On 07/09/26 10:44 am, Athira Rajeev wrote:
>
>Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
>emits these as two lines: the first carries both the raw bytes and the
>mnemonic, while the second carries only the raw bytes of the second word
>with no mnemonic:
>
>  1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
>  10209010:  20 8e e0 3b
>
>disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
>portion of the line.  disasm_line__parse() returns -1 when the name
>string is empty, which causes disasm_line__new() to return NULL, which
>causes symbol__parse_objdump_line() to return -1, which immediately
>breaks the objdump output parsing loop in symbol__disassemble_objdump().
>
>The result is that annotation of any function containing a prefixed
>instruction stops at the continuation word and all subsequent
>instructions in the function are lost.
>
>Fix this by treating an empty mnemonic as a valid case in
>disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
>set the instruction name to an empty heap-allocated string instead,
>allowing parsing to continue to the next line.
>
>Reported-by: Narendra Nalli<narnalli@in.ibm.com>
>Reported-by: Vijay Puliyala<vpuliyal@in.ibm.com>
>Signed-off-by: Athira Rajeev<atrajeev@linux.ibm.com>
>---
> tools/perf/util/disasm.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
>diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
>index e263a2a8715d..8dca703a5c74 100644
>--- a/tools/perf/util/disasm.c
>+++ b/tools/perf/util/disasm.c
>@@ -884,10 +884,24 @@ static int disasm_line__parse_powerpc(struct disasm_line *dl, struct annotate_ar
> 	if (name_raw_insn[0] == '\0')
> 		return -1;
> -	if (disasm)
>-		ret = disasm_line__parse(name, namep, rawp);
>-	else
>+	if (disasm) {
>+		/*
>+		 * Power10 prefixed instructions are 8 bytes and objdump emits
>+		 * the second word on its own line with raw bytes but no
>+		 * mnemonic, e.g.:
>+		 *   1020900c:  0b 00 10 06  pla  r31,757280
>+		 *   10209010:  20 8e e0 3b
>+		 *
>+		 * Treat a missing mnemonic as an empty instruction name rather
>+		 * than a parse failure, so that parsing continues past it.
>+		 */
>+		if (name[0] != '\0')
>+			ret = disasm_line__parse(name, namep, rawp);
>+		else
>+			*namep = strdup("");
>+	} else {
> 		*namep = "";
>+	}
>  	tmp_raw_insn = strndup(name_raw_insn, 11);
> 	if (tmp_raw_insn == NULL)
>
>Hi Athira,
>
>Setup:
>  - ppc64le, gcc 11.5.0
>  - Base: torvalds/linux master at 7cd8495c0f16
>  - perf built with libLLVM on. The default disassembler order puts
>    LLVM first, so I set annotate.disassemblers = objdump in a private
>    perfconfig file. "perf annotate -v" printed "Disassembled with
>    objdump".
>
>Test:
>  A small loop built with -O2 -mcpu=power10 -mpcrel -mprefixed, which
>  contains prefixed instructions (pli at the start of main, pla in the
>  loop preamble). Recorded with "perf record -e cpu-clock", then
>  "perf annotate --stdio main".
>
>Results:
>  - Without the patch, the output stops after the first prefixed
>    instruction (11 lines). The last line is:
>      10000440:  68 59 00 06  pli  r8,1500000000
>    and everything after it is lost, including the "blr" at the end
>    of main.
>  - With the patch, the output has 32 lines. The continuation words
>    appear as raw-byte lines with no mnemonic (10000444 and 10000454),
>    and the function is shown through to "blr" at 10000490. There is
>    no "(null)" in the output.
>  - Under valgrind, both builds report the same error totals
>    (8290 errors in 103 contexts).
>  [- A -mcpu=power9 program, with no prefixed instructions, produces
>    identical "perf annotate" output with and without the patch.]
>
>I tested only this patch, on its own on top of master.
>
>Tested-by: Tejas Manhas<tejas05@linux.ibm.com>

You've sent 5 messages, what?

>
>Thanks,
>Tejas Manhas
>

--- Thanks!


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines
  2026-11-28 12:42 ` Bradley Morgan
@ 2026-11-29 23:21   ` Namhyung Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Namhyung Kim @ 2026-11-29 23:21 UTC (permalink / raw)
  To: Bradley Morgan
  Cc: atrajeev, acme, adrian.hunter, hbathini, irogers, jolsa,
	linux-perf-users, linuxppc-dev, maddy, narnalli, tejas05, tshah,
	venkat88, vpuliyal

On Sat, Nov 28, 2026 at 12:42:52PM +0000, Bradley Morgan wrote:
> On 7 September 2026 06:14:29 BST, Athira Rajeev <atrajeev@linux.ibm.com>
> wrote:
> >Power10 introduces prefixed instructions that are 8 bytes wide.  objdump
> >emits these as two lines: the first carries both the raw bytes and the
> >mnemonic, while the second carries only the raw bytes of the second word
> >with no mnemonic:
> >
> >  1020900c:  0b 00 10 06  pla  r31,757280  # 102c1e2c <cctki_vi_ML_CCZ4>
> >  10209010:  20 8e e0 3b
> >
> >disasm_line__parse_powerpc() calls disasm_line__parse() on the mnemonic
> >portion of the line.  disasm_line__parse() returns -1 when the name
> >string is empty, which causes disasm_line__new() to return NULL, which
> >causes symbol__parse_objdump_line() to return -1, which immediately
> >breaks the objdump output parsing loop in symbol__disassemble_objdump().
> >
> >The result is that annotation of any function containing a prefixed
> >instruction stops at the continuation word and all subsequent
> >instructions in the function are lost.
> >
> >Fix this by treating an empty mnemonic as a valid case in
> >disasm_line__parse_powerpc(): skip the call to disasm_line__parse() and
> >set the instruction name to an empty heap-allocated string instead,
> >allowing parsing to continue to the next line.
> >
> >Reported-by: Narendra Nalli <narnalli@in.ibm.com>
> >Reported-by: Vijay Puliyala <vpuliyal@in.ibm.com>
> 
> yes, thanks
> 
> Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
> 
> 
> Tested-by: Bradley Morgan <bradley.morgan@linux.dev> # Power10

Thanks!

Athira, I assume we would send v2 with the new tags as well as fixes for
issues found by Sashiko.

Thanks,
Namhyung



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-29 23:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-07  5:14 [PATCH] perf disasm powerpc: handle Power10 prefixed instruction continuation lines Athira Rajeev
2026-11-28 10:40 ` Tejas
2026-11-28 11:41 ` Tejas
2026-11-28 12:38 ` Tejas
2026-11-28 12:42 ` Bradley Morgan
2026-11-29 23:21   ` Namhyung Kim
2026-11-28 12:43 ` Tejas
2026-11-28 12:47   ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox