perf annotate: Add more x86 mov instruction cases
Namhyung Kim
maintainerPATCH 1/1 perf annotate: Add more x86 mov instruction cases
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/perf/arch/x86/annotate/instructions.c +6 -3
@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, }, + { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, }, { .name = "movupd", .ops = &mov_ops, }, { .name = "movups", .ops = &mov_ops, }, - { .name = "movzbl", .ops = &mov_ops, }, - { .name = "movzwl", .ops = &mov_ops, }, + { .name = "movzb", .ops = &mov_ops, }, + { .name = "movzw", .ops = &mov_ops, }, + { .name = "movzl", .ops = &mov_ops, }, { .name = "mulsd", .ops = &mov_ops, }, { .name = "mulss", .ops = &mov_ops, }, { .name = "nop", .ops = &nop_ops, },
Signature · 1 line
2.42.0.283.g2d96d420d3-goog
Ian Rogers
reviewerQuoted 16 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)tools/perf/arch/x86/annotate/instructions.c +0
-0
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c +3
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, }, + { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },
In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
Thanks,
Ian
Quoted 13 lines
tools/perf/arch/x86/annotate/instructions.c +3
-3{ .name = "movupd", .ops = &mov_ops, }, { .name = "movups", .ops = &mov_ops, }, - { .name = "movzbl", .ops = &mov_ops, }, - { .name = "movzwl", .ops = &mov_ops, }, + { .name = "movzb", .ops = &mov_ops, }, + { .name = "movzw", .ops = &mov_ops, }, + { .name = "movzl", .ops = &mov_ops, }, { .name = "mulsd", .ops = &mov_ops, }, { .name = "mulss", .ops = &mov_ops, }, { .name = "nop", .ops = &nop_ops, }, --2.42.0.283.g2d96d420d3-goog
Namhyung Kim
maintainerHi Ian,
Quoted 24 lines · Ian Rogers
Quoted 22 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)tools/perf/arch/x86/annotate/instructions.c +1
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, },
Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 2 lines
tools/perf/arch/x86/annotate/instructions.c +2
-0+ { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
I don't know but in terms of instruction parsing, they are the same "MOVE" with two operands. I'm not aware of anything in perf with the operands of these instructions. So I guess it'd be fine to add these instructions even if they have different underlying behaviors.
Thanks,
Namhyung
From: Namhyung Kim
Quoted 39 lines
Sent: 09 September 2023 00:56
Hi Ian,
Quoted 8 lines · Ian Rogers
Quoted 6 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/tools/perf/arch/x86/annotate/instructions.cQuoted 10 lines
Quoted 10 lines
index
5f4ac4fc7fcf..5cdf457f5cbe100644tools/perf/arch/x86/annotate/instructions.c +1
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, },Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 2 lines
tools/perf/arch/x86/annotate/instructions.c +2
-0+ { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
Quoted 4 lines
I don't know but in terms of instruction parsing, they are the same "MOVE" with two operands. I'm not aware of anything in perf with the operands of these instructions. So I guess it'd be fine to add these instructions even if they have different underlying behaviors.
I'm pretty sure that 'rep movs[bwlq]' (aka while (cx--) *di++ = *si++) is likely to be missing the memory argument parameters. There is also 'fun and games' with one variant - iirc 'rep movsd' what has been used for 64bit, but got hijacked by one of the SIMD sets.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Namhyung Kim
maintainerQuoted 46 lines · David Laight
From: Namhyung Kim
Quoted 39 lines
Sent: 09 September 2023 00:56
Hi Ian,
Quoted 8 lines · Ian Rogers
Quoted 6 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/tools/perf/arch/x86/annotate/instructions.cQuoted 10 lines
Quoted 10 lines
index
5f4ac4fc7fcf..5cdf457f5cbe100644tools/perf/arch/x86/annotate/instructions.c +1
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, },Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 2 lines
tools/perf/arch/x86/annotate/instructions.c +2
-0+ { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
Quoted 4 lines
I don't know but in terms of instruction parsing, they are the same "MOVE" with two operands. I'm not aware of anything in perf with the operands of these instructions. So I guess it'd be fine to add these instructions even if they have different underlying behaviors.
Quoted 4 lines
I'm pretty sure that 'rep movs[bwlq]' (aka while (cx--) *di++ = *si++) is likely to be missing the memory argument parameters. There is also 'fun and games' with one variant - iirc 'rep movsd' what has been used for 64bit, but got hijacked by one of the SIMD sets.
It seems perf annotate don't process the rep prefix yet. So I think there should be no functional change now.
Thanks,
Namhyung
Quoted 48 lines · Namhyung Kim
Quoted 46 lines · David Laight
From: Namhyung Kim
Quoted 43 lines
Sent: 09 September 2023 00:56
Hi Ian,
Quoted 8 lines · Ian Rogers
Quoted 6 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/tools/perf/arch/x86/annotate/instructions.cQuoted 10 lines
Quoted 10 lines
index
5f4ac4fc7fcf..5cdf457f5cbe100644tools/perf/arch/x86/annotate/instructions.c +1
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, },Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 2 lines
tools/perf/arch/x86/annotate/instructions.c +2
-0+ { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
I don't know but in terms of instruction parsing, they are the same "MOVE" with two operands. I'm not aware of anything in perf with the operands of these instructions. So I guess it'd be fine to add these instructions even if they have different underlying behaviors.
Quoted 7 lines
Quoted 4 lines
I'm pretty sure that 'rep movs[bwlq]' (aka while (cx--) *di++ = *si++) is likely to be missing the memory argument parameters. There is also 'fun and games' with one variant - iirc 'rep movsd' what has been used for 64bit, but got hijacked by one of the SIMD sets.
It seems perf annotate don't process the rep prefix yet. So I think there should be no functional change now.
Reading the code, I also think it should be okay. Doing:
``` $ objdump -d /usr/lib/x86_64-linux-gnu/libc.so.6 |grep rep 2650a: f3 ab rep stos %eax,%es:(%rdi) 33b76: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi) ... ```
The mov parsing logic doesn't appear to care about src and dest, and the formatting above matches other mov cases.
Thanks,
Ian
Quoted 2 lines
Thanks,
Namhyung
Quoted 65 lines · Ian Rogers
Quoted 48 lines · Namhyung Kim
Quoted 46 lines · David Laight
From: Namhyung Kim
Quoted 43 lines
Sent: 09 September 2023 00:56
Hi Ian,
Quoted 8 lines · Ian Rogers
Quoted 6 lines · Namhyung Kim
Instructions with sign- and zero- extention like movsbl and movzwq were not handled properly. As it can check different size suffix (-b, -w, -l or -q) we can omit that and add the common parts even though some combinations are not possible.
Quoted 6 lines
Review
Quoted 6 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/arch/x86/annotate/instructions.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/tools/perf/arch/x86/annotate/instructions.cQuoted 10 lines
Quoted 10 lines
index
5f4ac4fc7fcf..5cdf457f5cbe100644tools/perf/arch/x86/annotate/instructions.c +1
-1@@ -74,12 +74,15 @@ static struct ins x86__instructions[] = { { .name = "movdqa", .ops = &mov_ops, }, { .name = "movdqu", .ops = &mov_ops, }, { .name = "movsd", .ops = &mov_ops, }, - { .name = "movslq", .ops = &mov_ops, }, { .name = "movss", .ops = &mov_ops, }, + { .name = "movsb", .ops = &mov_ops, },Quoted 8 lines
tools/perf/arch/x86/annotate/instructions.c static struct ins x86__instructions[] = { · line 80
Quoted 2 lines
tools/perf/arch/x86/annotate/instructions.c +2
-0+ { .name = "movsw", .ops = &mov_ops, }, + { .name = "movsl", .ops = &mov_ops, },In Intel's manual some of these names are "Move Data From String to String" operations, movsb and movsw in particular. These instructions can be used to make simple memcpy loops. Could it be the past omission was deliberate due to the different way the addressing works in the instructions?
I don't know but in terms of instruction parsing, they are the same "MOVE" with two operands. I'm not aware of anything in perf with the operands of these instructions. So I guess it'd be fine to add these instructions even if they have different underlying behaviors.
Quoted 7 lines
Quoted 4 lines
I'm pretty sure that 'rep movs[bwlq]' (aka while (cx--) *di++ = *si++) is likely to be missing the memory argument parameters. There is also 'fun and games' with one variant - iirc 'rep movsd' what has been used for 64bit, but got hijacked by one of the SIMD sets.
It seems perf annotate don't process the rep prefix yet. So I think there should be no functional change now.
Reading the code, I also think it should be okay. Doing:
``` $ objdump -d /usr/lib/x86_64-linux-gnu/libc.so.6 |grep rep 2650a: f3 ab rep stos %eax,%es:(%rdi) 33b76: f3 48 a5 rep movsq %ds:(%rsi),%es:(%rdi) ... ```
Quoted 4 lines
The mov parsing logic doesn't appear to care about src and dest, and the formatting above matches other mov cases.
Reviewed-by Ian Rogers <[email protected]>
Applied to perf-tools-next, thanks!
Namhyung