selftests/powerpc: Transactional Memory
cover selftests/powerpc: Transactional Memory
This is reliant on the following patch series:
- selftests/powerpc by Michael Ellerman
- selftests/powerpc by Michael Neuling
- powerpc/tm by Michael Neuling
Rashmica Gupta (3):
selftests/powerpc: Standardise TM calls selftests/powerpc: Add test for forking inside transaction selftests/powerpc: Add in check for TM
tools/testing/selftests/powerpc/tm/.gitignore | 1 + tools/testing/selftests/powerpc/tm/Makefile | 2 +- tools/testing/selftests/powerpc/tm/tm-fork.c | 41 ++++++++++++++++++++++ .../testing/selftests/powerpc/tm/tm-resched-dscr.c | 18 +++++----- .../testing/selftests/powerpc/tm/tm-signal-stack.c | 4 +-- 5 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/powerpc/tm/tm-fork.c
Signature · 1 line
2.5.0
PATCH 1/3 selftests/powerpc: Standardise TM calls
Currently tbegin, tend etc are written as opcodes or asm instructions. So standardise these to asm instructions.
--- tools/testing/selftests/powerpc/tm/tm-resched-dscr.c | 16 ++++++---------- tools/testing/selftests/powerpc/tm/tm-signal-stack.c | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-)
tools/testing/selftests/powerpc/tm/tm-resched-dscr.c +6 -10
@@ -29,12 +29,8 @@#include <asm/tm.h> #include "utils.h" +#include "tm.h" -#define TBEGIN ".long 0x7C00051D ;" -#define TEND ".long 0x7C00055D ;" -#define TCHECK ".long 0x7C00059C ;" -#define TSUSPEND ".long 0x7C0005DD ;" -#define TRESUME ".long 0x7C2005DD ;"#define SPRN_TEXASR 0x82#define SPRN_DSCR 0x03
@@ -52,13 +48,13 @@ int test_body(void)"mtspr %[sprn_dscr], 3;" /* start and suspend a transaction */ -TBEGIN +"tbegin.;" "beq 1f;" -TSUSPEND +"tsuspend.;" /* hard loop until the transaction becomes doomed */ "2: ;" -TCHECK +"tcheck 0;" "bc 4, 0, 2b;" /* record DSCR and TEXASR */
@@ -67,8 +63,8 @@ int test_body(void)"mfspr 3, %[sprn_texasr];" "std 3, %[texasr];" -TRESUME -TEND +"tresume.;" +"tend.;" "li %[rv], 0;" "1: ;" : [rv]"=r"(rv), [dscr2]"=m"(dscr2), [texasr]"=m"(texasr)
tools/testing/selftests/powerpc/tm/tm-signal-stack.c +2 -2
@@ -60,9 +60,9 @@ int tm_signal_stack()exit (1 ); asmvolatile ("li 1, 0 ;" /* stack ptr == NULL */ "1:" -".long 0x7C00051D ;" /* tbegin */ +"tbegin.;" "beq 1b ;" /* retry forever */ -".long 0x7C0005DD ; ;" /* tsuspend */ +"tsuspend.;" "ld 2, 0(1) ;" /* trigger segv" */ : : :"memory" );
Signature · 1 line
2.5.0
Re: [PATCH 1/3] selftests/powerpc: Standardise TM calls
Quoted 2 lines · Rashmica Gupta
Currently tbegin, tend etc are written as opcodes or asm instructions. So standardise these to asm instructions.
I think the asm instructions can be used with only newer versions of GCC. But not sure, does it work with the older gcc as well ?
Michael Ellerman
reviewerRe: [PATCH 1/3] selftests/powerpc: Standardise TM calls
Quoted 6 lines · Anshuman Khandual
Quoted 2 lines · Rashmica Gupta
Currently tbegin, tend etc are written as opcodes or asm instructions. So standardise these to asm instructions.
I think the asm instructions can be used with only newer versions of GCC. But not sure, does it work with the older gcc as well ?
No they don't work with all versions of GCC.
The HTM instructions were added in 4.9 AFAICS, but also backported to 4.8. That seems old enough to me.
Also we have another test (tm-syscall) which is already using the tbegin instruction, and no one has complained, so I don't think anyone is trying to build the selftests with really old compilers.
cheers
Re: [PATCH 1/3] selftests/powerpc: Standardise TM calls
Quoted 7 lines · Michael Ellerman
Quoted 6 lines · Anshuman Khandual
Quoted 6 lines · Rashmica Gupta
Quoted 2 lines
Quoted 2 lines
Currently tbegin, tend etc are written as opcodes or asm instructions. So standardise these to asm instructions.
I think the asm instructions can be used with only newer versions of GCC. But not sure, does it work with the older gcc as well ?
Quoted 8 lines
No they don't work with all versions of GCC.
The HTM instructions were added in 4.9 AFAICS, but also backported to 4.8. That seems old enough to me.
Also we have another test (tm-syscall) which is already using the tbegin instruction, and no one has complained, so I don't think anyone is trying to build the selftests with really old compilers.
Its only a concern if you try to build these self tests on some older distro. But then some other self tests dont build there because of lack of newer compiler options. Its generic problem not something specific to this test.
PATCH 2/3 selftests/powerpc: Add test for forking inside transaction
In reply to Rashmica GuptaThis test does a fork syscall inside a transaction. Basic sniff test to see if we can enter the kernel during a transaction.
--- tools/testing/selftests/powerpc/tm/.gitignore | 1 + tools/testing/selftests/powerpc/tm/Makefile | 2 +- tools/testing/selftests/powerpc/tm/tm-fork.c | 41 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/tm/tm-fork.c
tools/testing/selftests/powerpc/tm/.gitignore +1 -0
@@ -2,3 +2,4 @@ tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack +tm-fork
tools/testing/selftests/powerpc/tm/Makefile +1 -1
@@ -1,4 +1,4 @@ -TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack +TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack tm-fork all: $(TEST_PROGS)
tools/testing/selftests/powerpc/tm/tm-fork.c new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
Quoted 4 lines · Rashmica Gupta
tools/testing/selftests/powerpc/tm/tm-fork.c new file +4
-0+int test_fork (void ) +{ +SKIP_IF (!have_htm ()); +
tools/testing/selftests/powerpc/tm/tm-fork.c line 33
Quoted 10 lines
tools/testing/selftests/powerpc/tm/tm-fork.c new file +10
-0+ asm __volatile__( +"tbegin.;" +"blt 1f; " +"li 0, 2;" /* fork syscall */ +"sc ;" +"tend.;" +"1: ;" + : : :"memory" ,"r0" ); +/* If we reach here, we've passed. Otherwise we've probably crashed +* the kernel */
The transaction inside the parent process will abort. What is expected inside the child process ? Why should the kernel crash ?
Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
As far as I'm aware, the kernel used to crash when forking inside a transaction (see powerpc/tm: Fix crash when forking inside a transaction). So this is to check that the transaction aborts rather than your whole kernel crashing.
Quoted 19 lines · Anshuman Khandual
Quoted 4 lines · Rashmica Gupta
tools/testing/selftests/powerpc/tm/tm-fork.c new file +4
-0+int test_fork (void ) +{ +SKIP_IF (!have_htm ()); +tools/testing/selftests/powerpc/tm/tm-fork.c line 33
Quoted 10 lines
tools/testing/selftests/powerpc/tm/tm-fork.c new file +10
-0+ asm __volatile__( +"tbegin.;" +"blt 1f; " +"li 0, 2;" /* fork syscall */ +"sc ;" +"tend.;" +"1: ;" + : : :"memory" ,"r0" ); +/* If we reach here, we've passed. Otherwise we've probably crashed +* the kernel */ The transaction inside the parent process will abort. What is expected inside the child process ? Why should the kernel crash ?
Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
In reply to Rashmica GuptaQuoted 3 lines · Rashmica Gupta
This test does a fork syscall inside a transaction. Basic sniff test to see
if we can enter the kernel during a transaction.
Can you add this description to the top of the test case as well?
Mikey
Quoted 82 lines
=20
Signed-off-by Rashmica Gupta <[email protected]>--- tools/testing/selftests/powerpc/tm/.gitignore | 1 + tools/testing/selftests/powerpc/tm/Makefile | 2 +- tools/testing/selftests/powerpc/tm/tm-fork.c | 41 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/tm/tm-fork.c=20
tools/testing/selftests/powerpc/tm/.gitignore +1
-0@@ -2,3 +2,4 @@ tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack +tm-forktools/testing/selftests/powerpc/tm/Makefile +1
-3@@ -1,4 +1,4 @@ -TEST_PROGS :=3D tm-resched-dscr tm-syscall tm-signal-msr-resv tm -signal-stack +TEST_PROGS :=3D tm-resched-dscr tm-syscall tm-signal-msr-resv tm -signal-stack tm-fork=20
all: $(TEST_PROGS)
=20tools/testing/selftests/powerpc/tm/tm-fork.c new file +32
-0@@ -0,0 +1,41 @@ +/* +* Copyright 2015, Michael Neuling, IBM Corp. +* Licensed under GPLv2. +* +* Edited: Rashmica Gupta, Nov 2015 +* +* Fork inside a transaction +*/ + +#include <errno.h> +#include <inttypes.h> +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "utils.h" +#include "tm.h" + +int test_fork (void ) +{ +SKIP_IF (!have_htm ()); + + asm __volatile__( +"tbegin.;" +"blt 1f; " +"li 0, 2;" /* fork syscall */ +"sc ;" +"tend.;" +"1: ;" + : : :"memory" ,"r0" ); +/* If we reach here, we've passed. Otherwise we've probably crashed
tools/testing/selftests/powerpc/tm/tm-fork.c new file +9
-0+* the kernel */ + +return 0 ; +} + +int main (int argc,char *argv[]) +{ +return test_harness (test_fork,"tm_fork" ); +}
PATCH 3/3 selftests/powerpc: Add in check for TM
In reply to Rashmica GuptaThe resched-dscr test does not currently check for TM, so add in check.
--- tools/testing/selftests/powerpc/tm/tm-resched-dscr.c | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/powerpc/tm/tm-resched-dscr.c +2 -0
@@ -38,6 +38,8 @@ int test_body(void) {uint64_t rv, dscr1 =1 , dscr2, texasr; +SKIP_IF (!have_htm ()); +printf ("Check DSCR TM context switch: " );fflush (stdout);for (;;) {
Signature · 1 line
2.5.0
Quoted 4 lines · Rashmica Gupta
This is reliant on the following patch series:
- selftests/powerpc by Michael Ellerman
- selftests/powerpc by Michael Neuling
- powerpc/tm by Michael Neuling
Could you provide the full titles of the patch series? (Links to patchwork.ozlabs.org are good too.)
Andrew
Signature · 3 lines
Andrew Donnellan Software Engineer, OzLabs [email protected] Australia Development Lab, Canberra +61 2 6201 8874 (work) IBM Australia Limited