* [PATCH 0/3] selftests/powerpc: Transactional Memory
@ 2015-12-01 5:08 Rashmica Gupta
2015-12-01 5:08 ` [PATCH 1/3] selftests/powerpc: Standardise TM calls Rashmica Gupta
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Rashmica Gupta @ 2015-12-01 5:08 UTC (permalink / raw)
To: linuxppc-dev
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
--
2.5.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] selftests/powerpc: Standardise TM calls
2015-12-01 5:08 [PATCH 0/3] selftests/powerpc: Transactional Memory Rashmica Gupta
@ 2015-12-01 5:08 ` Rashmica Gupta
2015-12-01 8:08 ` Anshuman Khandual
2015-12-01 5:08 ` [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction Rashmica Gupta
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Rashmica Gupta @ 2015-12-01 5:08 UTC (permalink / raw)
To: linuxppc-dev
Currently tbegin, tend etc are written as opcodes or asm instructions. So
standardise these to asm instructions.
Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
---
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(-)
diff --git a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
index 42d4c8caad81..88c46481e59b 100644
--- a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
+++ b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
@@ -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)
diff --git a/tools/testing/selftests/powerpc/tm/tm-signal-stack.c b/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
index 82c29cb222dc..8ffd5cee7271 100644
--- a/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
+++ b/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
@@ -60,9 +60,9 @@ int tm_signal_stack()
exit(1);
asm volatile("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");
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
2015-12-01 5:08 [PATCH 0/3] selftests/powerpc: Transactional Memory Rashmica Gupta
2015-12-01 5:08 ` [PATCH 1/3] selftests/powerpc: Standardise TM calls Rashmica Gupta
@ 2015-12-01 5:08 ` Rashmica Gupta
2015-12-01 8:11 ` Anshuman Khandual
2015-12-02 5:27 ` Michael Neuling
2015-12-01 5:08 ` [PATCH 3/3] selftests/powerpc: Add in check for TM Rashmica Gupta
2015-12-01 5:18 ` [PATCH 0/3] selftests/powerpc: Transactional Memory Andrew Donnellan
3 siblings, 2 replies; 11+ messages in thread
From: Rashmica Gupta @ 2015-12-01 5:08 UTC (permalink / raw)
To: linuxppc-dev
This test does a fork syscall inside a transaction. Basic sniff test to see
if we can enter the kernel during a transaction.
Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
---
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
diff --git a/tools/testing/selftests/powerpc/tm/.gitignore b/tools/testing/selftests/powerpc/tm/.gitignore
index e6668217ccd0..d0c7c97e9b13 100644
--- a/tools/testing/selftests/powerpc/tm/.gitignore
+++ b/tools/testing/selftests/powerpc/tm/.gitignore
@@ -2,3 +2,4 @@ tm-resched-dscr
tm-syscall
tm-signal-msr-resv
tm-signal-stack
+tm-fork
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 578572a3700a..f7d4727662aa 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -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)
diff --git a/tools/testing/selftests/powerpc/tm/tm-fork.c b/tools/testing/selftests/powerpc/tm/tm-fork.c
new file mode 100644
index 000000000000..f571a48a59a0
--- /dev/null
+++ b/tools/testing/selftests/powerpc/tm/tm-fork.c
@@ -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
+ * the kernel */
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ return test_harness(test_fork, "tm_fork");
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] selftests/powerpc: Add in check for TM
2015-12-01 5:08 [PATCH 0/3] selftests/powerpc: Transactional Memory Rashmica Gupta
2015-12-01 5:08 ` [PATCH 1/3] selftests/powerpc: Standardise TM calls Rashmica Gupta
2015-12-01 5:08 ` [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction Rashmica Gupta
@ 2015-12-01 5:08 ` Rashmica Gupta
2015-12-01 5:18 ` [PATCH 0/3] selftests/powerpc: Transactional Memory Andrew Donnellan
3 siblings, 0 replies; 11+ messages in thread
From: Rashmica Gupta @ 2015-12-01 5:08 UTC (permalink / raw)
To: linuxppc-dev
The resched-dscr test does not currently check for TM, so add in check.
Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
---
tools/testing/selftests/powerpc/tm/tm-resched-dscr.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
index 88c46481e59b..8243558aac6c 100644
--- a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
+++ b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
@@ -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 (;;) {
--
2.5.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 0/3] selftests/powerpc: Transactional Memory
2015-12-01 5:08 [PATCH 0/3] selftests/powerpc: Transactional Memory Rashmica Gupta
` (2 preceding siblings ...)
2015-12-01 5:08 ` [PATCH 3/3] selftests/powerpc: Add in check for TM Rashmica Gupta
@ 2015-12-01 5:18 ` Andrew Donnellan
3 siblings, 0 replies; 11+ messages in thread
From: Andrew Donnellan @ 2015-12-01 5:18 UTC (permalink / raw)
To: Rashmica Gupta, linuxppc-dev
On 01/12/15 16:08, Rashmica Gupta wrote:
> 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
--
Andrew Donnellan Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com Australia Development Lab, Canberra
+61 2 6201 8874 (work) IBM Australia Limited
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] selftests/powerpc: Standardise TM calls
2015-12-01 5:08 ` [PATCH 1/3] selftests/powerpc: Standardise TM calls Rashmica Gupta
@ 2015-12-01 8:08 ` Anshuman Khandual
2015-12-02 3:40 ` Michael Ellerman
0 siblings, 1 reply; 11+ messages in thread
From: Anshuman Khandual @ 2015-12-01 8:08 UTC (permalink / raw)
To: Rashmica Gupta, linuxppc-dev
On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
> 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 ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
2015-12-01 5:08 ` [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction Rashmica Gupta
@ 2015-12-01 8:11 ` Anshuman Khandual
2015-12-01 23:31 ` Rashmica
2015-12-02 5:27 ` Michael Neuling
1 sibling, 1 reply; 11+ messages in thread
From: Anshuman Khandual @ 2015-12-01 8:11 UTC (permalink / raw)
To: Rashmica Gupta, linuxppc-dev
On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
> +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
> + * the kernel */
The transaction inside the parent process will abort. What
is expected inside the child process ? Why should the kernel
crash ?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
2015-12-01 8:11 ` Anshuman Khandual
@ 2015-12-01 23:31 ` Rashmica
0 siblings, 0 replies; 11+ messages in thread
From: Rashmica @ 2015-12-01 23:31 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev
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.
On 01/12/15 19:11, Anshuman Khandual wrote:
> On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
>> +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
>> + * the kernel */
> The transaction inside the parent process will abort. What
> is expected inside the child process ? Why should the kernel
> crash ?
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] selftests/powerpc: Standardise TM calls
2015-12-01 8:08 ` Anshuman Khandual
@ 2015-12-02 3:40 ` Michael Ellerman
2015-12-02 4:41 ` Anshuman Khandual
0 siblings, 1 reply; 11+ messages in thread
From: Michael Ellerman @ 2015-12-02 3:40 UTC (permalink / raw)
To: Anshuman Khandual, Rashmica Gupta, linuxppc-dev
On Tue, 2015-12-01 at 13:38 +0530, Anshuman Khandual wrote:
> On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
> > 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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] selftests/powerpc: Standardise TM calls
2015-12-02 3:40 ` Michael Ellerman
@ 2015-12-02 4:41 ` Anshuman Khandual
0 siblings, 0 replies; 11+ messages in thread
From: Anshuman Khandual @ 2015-12-02 4:41 UTC (permalink / raw)
To: Michael Ellerman, Rashmica Gupta, linuxppc-dev
On 12/02/2015 09:10 AM, Michael Ellerman wrote:
> On Tue, 2015-12-01 at 13:38 +0530, Anshuman Khandual wrote:
>> > On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
>>> > > 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.
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction
2015-12-01 5:08 ` [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction Rashmica Gupta
2015-12-01 8:11 ` Anshuman Khandual
@ 2015-12-02 5:27 ` Michael Neuling
1 sibling, 0 replies; 11+ messages in thread
From: Michael Neuling @ 2015-12-02 5:27 UTC (permalink / raw)
To: Rashmica Gupta, linuxppc-dev
On Tue, 2015-12-01 at 16:08 +1100, Rashmica Gupta wrote:
> 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
>=20
> Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
> ---
> 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
> diff --git a/tools/testing/selftests/powerpc/tm/.gitignore
> b/tools/testing/selftests/powerpc/tm/.gitignore
> index e6668217ccd0..d0c7c97e9b13 100644
> --- a/tools/testing/selftests/powerpc/tm/.gitignore
> +++ b/tools/testing/selftests/powerpc/tm/.gitignore
> @@ -2,3 +2,4 @@ tm-resched-dscr
> tm-syscall
> tm-signal-msr-resv
> tm-signal-stack
> +tm-fork
> diff --git a/tools/testing/selftests/powerpc/tm/Makefile
> b/tools/testing/selftests/powerpc/tm/Makefile
> index 578572a3700a..f7d4727662aa 100644
> --- a/tools/testing/selftests/powerpc/tm/Makefile
> +++ b/tools/testing/selftests/powerpc/tm/Makefile
> @@ -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)
> =20
> diff --git a/tools/testing/selftests/powerpc/tm/tm-fork.c
> b/tools/testing/selftests/powerpc/tm/tm-fork.c
> new file mode 100644
> index 000000000000..f571a48a59a0
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/tm/tm-fork.c
> @@ -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
> + * the kernel */
> +
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_fork, "tm_fork");
> +}
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-12-02 5:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 5:08 [PATCH 0/3] selftests/powerpc: Transactional Memory Rashmica Gupta
2015-12-01 5:08 ` [PATCH 1/3] selftests/powerpc: Standardise TM calls Rashmica Gupta
2015-12-01 8:08 ` Anshuman Khandual
2015-12-02 3:40 ` Michael Ellerman
2015-12-02 4:41 ` Anshuman Khandual
2015-12-01 5:08 ` [PATCH 2/3] selftests/powerpc: Add test for forking inside transaction Rashmica Gupta
2015-12-01 8:11 ` Anshuman Khandual
2015-12-01 23:31 ` Rashmica
2015-12-02 5:27 ` Michael Neuling
2015-12-01 5:08 ` [PATCH 3/3] selftests/powerpc: Add in check for TM Rashmica Gupta
2015-12-01 5:18 ` [PATCH 0/3] selftests/powerpc: Transactional Memory Andrew Donnellan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).