* [PATCH V2 10/12] selftests, powerpc: Add test for DSCR inheritence across fork & exec
From: Anshuman Khandual @ 2015-01-13 10:22 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel; +Cc: mikey, shuahkh, anton
In-Reply-To: <1421144560-15901-1-git-send-email-khandual@linux.vnet.ibm.com>
This patch adds a test case to verify that the changed DSCR value
inside any process would be inherited to it's child across the fork
and exec system call.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
.../powerpc/dscr/dscr_inherit_exec_test.c | 118 +++++++++++++++++++++
2 files changed, 119 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 81239e2..4e84309 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -1,5 +1,5 @@
PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
- dscr_inherit_test
+ dscr_inherit_test dscr_inherit_exec_test
CFLAGS := $(CFLAGS) -lpthread
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
new file mode 100644
index 0000000..5ff3849
--- /dev/null
+++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
@@ -0,0 +1,118 @@
+/*
+ * POWER Data Stream Control Register (DSCR) fork exec test
+ *
+ * This testcase modifies the DSCR using mtspr, forks & execs and
+ * verifies that the child is using the changed DSCR using mfspr.
+ *
+ * When using the privilege state SPR, the instructions such as
+ * mfspr or mtspr are priviledged and the kernel emulates them
+ * for us. Instructions using problem state SPR can be exuecuted
+ * directly without any emulation if the HW supports them. Else
+ * they also get emulated by the kernel.
+ *
+ * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
+ * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include "dscr.h"
+
+static char prog[LEN_MAX];
+
+static void do_exec(unsigned long parent_dscr)
+{
+ unsigned long cur_dscr, cur_dscr_usr;
+
+ cur_dscr = get_dscr();
+ cur_dscr_usr = get_dscr_usr();
+
+ if (cur_dscr != parent_dscr) {
+ fprintf(stderr, "Parent DSCR %ld was not inherited "
+ "over exec (kernel value)\n", parent_dscr);
+ exit(1);
+ }
+
+ if (cur_dscr_usr != parent_dscr) {
+ fprintf(stderr, "Parent DSCR %ld was not inherited "
+ "over exec (user value)\n", parent_dscr);
+ exit(1);
+ }
+ exit(0);
+}
+
+int test_body(void)
+{
+ unsigned long i, dscr = 0;
+ pid_t pid;
+
+ for (i = 0; i < COUNT; i++) {
+ dscr++;
+ if (dscr > DSCR_MAX)
+ dscr = 0;
+
+ if (dscr == get_default_dscr())
+ continue;
+
+ if (i % 2 == 0)
+ set_dscr_usr(dscr);
+ else
+ set_dscr(dscr);
+
+ /*
+ * XXX: Force a context switch out so that DSCR
+ * current value is copied into the thread struct
+ * which is required for the child to inherit the
+ * changed value.
+ */
+ sleep(1);
+
+ pid = fork();
+ if (pid == -1) {
+ perror("fork() failed\n");
+ exit(1);
+ } else if (pid) {
+ int status;
+
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid() failed\n");
+ exit(1);
+ }
+
+ if (!WIFEXITED(status)) {
+ fprintf(stderr, "Child didn't exit cleanly\n");
+ exit(1);
+ }
+
+ if (WEXITSTATUS(status) != 0) {
+ fprintf(stderr, "Child didn't exit cleanly\n");
+ return 1;
+ }
+ } else {
+ char dscr_str[16];
+
+ sprintf(dscr_str, "%ld", dscr);
+ execlp(prog, prog, "exec", dscr_str, NULL);
+ exit(1);
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc == 3 && !strcmp(argv[1], "exec")) {
+ unsigned long parent_dscr;
+
+ parent_dscr = atoi(argv[2]);
+ do_exec(parent_dscr);
+ } else if (argc != 1) {
+ fprintf(stderr, "Usage: %s\n", argv[0]);
+ exit(1);
+ }
+
+ strncpy(prog, argv[0], strlen(argv[0]));
+ return test_harness(test_body, "dscr_inherit_exec_test");
+}
--
1.9.3
^ permalink raw reply related
* [PATCH V2 11/12] selftests, powerpc: Add test for all DSCR sysfs interfaces
From: Anshuman Khandual @ 2015-01-13 10:22 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel; +Cc: mikey, shuahkh, anton
In-Reply-To: <1421144560-15901-1-git-send-email-khandual@linux.vnet.ibm.com>
This test continuously updates the system wide DSCR default value
in the sysfs interface and makes sure that the same is reflected
across all the sysfs interfaces for each individual CPUs present
on the system.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
tools/testing/selftests/powerpc/dscr/Makefile | 3 +-
.../selftests/powerpc/dscr/dscr_sysfs_test.c | 89 ++++++++++++++++++++++
2 files changed, 91 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index 4e84309..fada526 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -1,5 +1,6 @@
PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
- dscr_inherit_test dscr_inherit_exec_test
+ dscr_inherit_test dscr_inherit_exec_test \
+ dscr_sysfs_test
CFLAGS := $(CFLAGS) -lpthread
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
new file mode 100644
index 0000000..3d11439
--- /dev/null
+++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
@@ -0,0 +1,89 @@
+/*
+ * POWER Data Stream Control Register (DSCR) sysfs interface test
+ *
+ * This test updates to system wide DSCR default through the sysfs interface
+ * and then verifies that all the CPU specific DSCR defaults are updated as
+ * well verified from their sysfs interfaces.
+ *
+ * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include "dscr.h"
+
+static int check_cpu_dscr_default(char *file, unsigned long val)
+{
+ char buf[10];
+ int fd, rc;
+
+ fd = open(file, O_RDWR);
+ if (fd == -1) {
+ perror("open() failed\n");
+ return 1;
+ }
+
+ rc = read(fd, buf, sizeof(buf));
+ if (rc == -1) {
+ perror("read() failed\n");
+ return 1;
+ }
+ close(fd);
+
+ buf[rc] = '\0';
+ if (strtol(buf, NULL, 16) != val) {
+ printf("DSCR match failed: %ld (system) %ld (cpu)\n",
+ val, strtol(buf, NULL, 16));
+ return 1;
+ }
+ return 0;
+}
+
+static int check_all_cpu_dscr_defaults(unsigned long val)
+{
+ DIR *sysfs;
+ struct dirent *dp;
+ char file[LEN_MAX];
+
+ sysfs = opendir(CPU_PATH);
+ if (!sysfs) {
+ perror("opendir() failed\n");
+ return 1;
+ }
+
+ while ((dp = readdir(sysfs))) {
+ if (!(dp->d_type & DT_DIR))
+ continue;
+ if (!strcmp(dp->d_name, "cpuidle"))
+ continue;
+ if (!strstr(dp->d_name, "cpu"))
+ continue;
+
+ sprintf(file, "%s%s/dscr", CPU_PATH, dp->d_name);
+ if (check_cpu_dscr_default(file, val))
+ return 1;
+ }
+ closedir(sysfs);
+ return 0;
+}
+
+int test_body(void)
+{
+ int i, j;
+
+ for (i = 0; i < COUNT; i++) {
+ for (j = 0; j < DSCR_MAX; j++) {
+ set_default_dscr(j);
+ if (check_all_cpu_dscr_defaults(j))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ return test_harness(test_body, "dscr_sysfs_test");
+}
--
1.9.3
^ permalink raw reply related
* [PATCH V2 12/12] selftests, powerpc: Add thread based stress test for DSCR sysfs interfaces
From: Anshuman Khandual @ 2015-01-13 10:22 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel; +Cc: mikey, shuahkh, anton
In-Reply-To: <1421144560-15901-1-git-send-email-khandual@linux.vnet.ibm.com>
This patch adds a test to update the system wide DSCR value repeatedly
and then verifies that any thread on any given CPU on the system must
be able to see the same DSCR value whether its is being read through
the problem state based SPR or the privilege state based SPR.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
.../powerpc/dscr/dscr_sysfs_thread_test.c | 114 +++++++++++++++++++++
2 files changed, 115 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
index fada526..834ef88 100644
--- a/tools/testing/selftests/powerpc/dscr/Makefile
+++ b/tools/testing/selftests/powerpc/dscr/Makefile
@@ -1,6 +1,6 @@
PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
dscr_inherit_test dscr_inherit_exec_test \
- dscr_sysfs_test
+ dscr_sysfs_test dscr_sysfs_thread_test
CFLAGS := $(CFLAGS) -lpthread
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
new file mode 100644
index 0000000..95a4304
--- /dev/null
+++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
@@ -0,0 +1,114 @@
+/*
+ * POWER Data Stream Control Register (DSCR) sysfs thread test
+ *
+ * This test updates the system wide DSCR default value through
+ * sysfs interface which should then update all the CPU specific
+ * DSCR default values which must also be then visible to threads
+ * executing on individual CPUs on the system.
+ *
+ * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#define _GNU_SOURCE
+#include "dscr.h"
+
+static pthread_mutex_t lock; /* Pthread lock */
+static cpu_set_t cpuset; /* Thread cpu set */
+static int target; /* Thread target cpu */
+static unsigned long *result; /* Thread exit status array */
+
+static void *test_thread_dscr(void *in)
+{
+ unsigned long cur_dscr, cur_dscr_usr;
+ unsigned long val = (unsigned long)in;
+
+ pthread_mutex_lock(&lock);
+ target++;
+ if (target == sysconf(_SC_NPROCESSORS_ONLN))
+ target = 0;
+ CPU_ZERO(&cpuset);
+ CPU_SET(target, &cpuset);
+
+ if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
+ perror("sched_settarget_cpu() failed\n");
+ pthread_mutex_unlock(&lock);
+ result[target] = 1;
+ pthread_exit(&result[target]);
+ }
+ pthread_mutex_unlock(&lock);
+
+ cur_dscr = get_dscr();
+ cur_dscr_usr = get_dscr_usr();
+
+ if (val != cur_dscr) {
+ printf("[cpu %d] Kernel DSCR should be %ld but is %ld\n",
+ sched_getcpu(), val, cur_dscr);
+ result[target] = 1;
+ pthread_exit(&result[target]);
+ }
+
+ if (val != cur_dscr_usr) {
+ printf("[cpu %d] User DSCR should be %ld but is %ld\n",
+ sched_getcpu(), val, cur_dscr_usr);
+ result[target] = 1;
+ pthread_exit(&result[target]);
+ }
+ result[target] = 0;
+ pthread_exit(&result[target]);
+}
+
+static int check_cpu_dscr_thread(unsigned long val)
+{
+ pthread_t threads[sysconf(_SC_NPROCESSORS_ONLN)];
+ unsigned long *status[sysconf(_SC_NPROCESSORS_ONLN)];
+ unsigned long i;
+
+ for (i = 0; i < sysconf(_SC_NPROCESSORS_ONLN); i++) {
+ if (pthread_create(&threads[i], NULL,
+ test_thread_dscr, (void *)val)) {
+ perror("pthread_create() failed\n");
+ return 1;
+ }
+ }
+
+ for (i = 0; i < sysconf(_SC_NPROCESSORS_ONLN); i++) {
+ if (pthread_join(threads[i], (void **)&(status[i]))) {
+ perror("pthread_join() failed\n");
+ return 1;
+ }
+
+ if (*status[i]) {
+ printf(" %ldth thread join failed with %ld\n",
+ i, *status[i]);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int test_body(void)
+{
+ int i, j;
+
+ result = malloc(sizeof(unsigned long) * sysconf(_SC_NPROCESSORS_ONLN));
+ pthread_mutex_init(&lock, NULL);
+ target = 0;
+ for (i = 0; i < COUNT; i++) {
+ for (j = 0; j < DSCR_MAX; j++) {
+ set_default_dscr(j);
+ if (check_cpu_dscr_thread(j))
+ return 1;
+ }
+ }
+ free(result);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ return test_harness(test_body, "dscr_sysfs_thread_test");
+}
--
1.9.3
^ permalink raw reply related
* Re: [PATCH V2 06/12] selftests, powerpc: Add test for system wide DSCR default
From: Shuah Khan @ 2015-01-13 15:22 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-7-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test case for the system wide DSCR default
> value, which when changed through it's sysfs interface must
> be visible to all threads reading DSCR either through the
> privilege state SPR or the problem state SPR. The DSCR value
> change should be immediate as well.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/Makefile | 2 +-
> tools/testing/selftests/powerpc/dscr/Makefile | 17 +++
> tools/testing/selftests/powerpc/dscr/dscr.h | 120 ++++++++++++++++++++
> .../selftests/powerpc/dscr/dscr_default_test.c | 121 +++++++++++++++++++++
> 4 files changed, 259 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/Makefile
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr.h
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_default_test.c
>
> diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
> index f6ff90a..1318883 100644
> --- a/tools/testing/selftests/powerpc/Makefile
> +++ b/tools/testing/selftests/powerpc/Makefile
> @@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
>
> export CC CFLAGS
>
> -TARGETS = pmu copyloops mm tm primitives
> +TARGETS = pmu copyloops mm tm primitives dscr
>
> endif
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> new file mode 100644
> index 0000000..0aa90ab
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -0,0 +1,17 @@
> +PROGS := dscr_default_test
> +
> +CFLAGS := $(CFLAGS) -lpthread
> +
> +all: $(PROGS)
> +
> +$(PROGS): ../harness.c
> +
> +run_tests: all
> + @-for PROG in $(PROGS); do \
> + ./$$PROG; \
> + done;
> +
> +clean:
> + rm -f $(PROGS) *.o
> +
> +.PHONY: all run_tests clean
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr.h b/tools/testing/selftests/powerpc/dscr/dscr.h
> new file mode 100644
> index 0000000..2e6535b
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr.h
> @@ -0,0 +1,120 @@
> +/*
> + * POWER Data Stream Control Register (DSCR)
> + *
> + * This header file contains helper functions and macros
> + * required for all the DSCR related test cases.
> + *
> + * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#ifndef _SELFTESTS_POWERPC_DSCR_DSCR_H
> +#define _SELFTESTS_POWERPC_DSCR_DSCR_H
> +
> +#include <unistd.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <dirent.h>
> +#include <pthread.h>
> +#include <sched.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/wait.h>
> +
> +#include "utils.h"
> +
> +#define SPRN_DSCR 0x11 /* Privilege state SPR */
> +#define SPRN_DSCR_USR 0x03 /* Problem state SPR */
> +#define THREADS 100 /* Max threads */
> +#define COUNT 100 /* Max iterations */
> +#define DSCR_MAX 16 /* Max DSCR value */
> +#define LEN_MAX 100 /* Max name length */
> +
> +#define DSCR_DEFAULT "/sys/devices/system/cpu/dscr_default"
> +#define CPU_PATH "/sys/devices/system/cpu/"
> +
> +#define rmb() asm volatile("lwsync":::"memory")
> +#define wmb() asm volatile("lwsync":::"memory")
> +
> +#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
> +
> +/* Prilvilege state DSCR access */
> +inline unsigned long get_dscr(void)
> +{
> + unsigned long ret;
> +
> + asm volatile("mfspr %0,%1" : "=r" (ret): "i" (SPRN_DSCR));
> +
> + return ret;
> +}
> +
> +inline void set_dscr(unsigned long val)
> +{
> + asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));
> +}
> +
> +/* Problem state DSCR access */
> +inline unsigned long get_dscr_usr(void)
> +{
> + unsigned long ret;
> +
> + asm volatile("mfspr %0,%1" : "=r" (ret): "i" (SPRN_DSCR_USR));
> +
> + return ret;
> +}
> +
> +inline void set_dscr_usr(unsigned long val)
> +{
> + asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR_USR));
> +}
> +
> +/* Default DSCR access */
> +unsigned long get_default_dscr(void)
> +{
> + int fd = -1;
> + char buf[16];
> + unsigned long val;
> +
> + if (fd == -1) {
> + fd = open(DSCR_DEFAULT, O_RDONLY);
> + if (fd == -1) {
> + perror("open() failed\n");
> + exit(1);
> + }
> + }
> + memset(buf, 0, sizeof(buf));
> + lseek(fd, 0, SEEK_SET);
> + read(fd, buf, sizeof(buf));
> + sscanf(buf, "%lx", &val);
> + close(fd);
> + return val;
> +}
> +
> +void set_default_dscr(unsigned long val)
> +{
> + int fd = -1;
> + char buf[16];
> +
> + if (fd == -1) {
> + fd = open(DSCR_DEFAULT, O_RDWR);
> + if (fd == -1) {
> + perror("open() failed\n");
> + exit(1);
> + }
> + }
> + sprintf(buf, "%lx\n", val);
> + write(fd, buf, strlen(buf));
> + close(fd);
> +}
> +
> +double uniform_deviate(int seed)
> +{
> + return seed * (1.0 / (RAND_MAX + 1.0));
> +}
> +#endif /* _SELFTESTS_POWERPC_DSCR_DSCR_H */
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_default_test.c b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c
> new file mode 100644
> index 0000000..fd8b7b9
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_default_test.c
> @@ -0,0 +1,121 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) default test
> + *
> + * This test modifies the system wide default DSCR through
> + * it's sysfs interface and then verifies that all threads
> + * see the correct changed DSCR value immediately.
> + *
> + * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +static unsigned long dscr; /* System DSCR default */
> +static unsigned long sequence;
> +static unsigned long result[THREADS];
> +
> +static void *do_test(void *in)
> +{
> + unsigned long thread = (unsigned long)in;
> + unsigned long i;
> +
> + for (i = 0; i < COUNT; i++) {
> + unsigned long d, cur_dscr, cur_dscr_usr;
> + unsigned long s1, s2;
> +
> + s1 = ACCESS_ONCE(sequence);
> + if (s1 & 1)
> + continue;
> + rmb();
> +
> + d = dscr;
> + cur_dscr = get_dscr();
> + cur_dscr_usr = get_dscr_usr();
> +
> + rmb();
> + s2 = sequence;
> +
> + if (s1 != s2)
> + continue;
> +
> + if (cur_dscr != d) {
> + fprintf(stderr, "thread %ld kernel DSCR should be %ld "
> + "but is %ld\n", thread, d, cur_dscr);
> + result[thread] = 1;
> + pthread_exit(&result[thread]);
> + }
> +
> + if (cur_dscr_usr != d) {
> + fprintf(stderr, "thread %ld user DSCR should be %ld "
> + "but is %ld\n", thread, d, cur_dscr_usr);
> + result[thread] = 1;
> + pthread_exit(&result[thread]);
> + }
> + }
> + result[thread] = 0;
> + pthread_exit(&result[thread]);
> +}
> +
> +int test_body(void)
> +{
> + pthread_t threads[THREADS];
> + unsigned long i, *status[THREADS];
> +
> + /* Initial DSCR default */
> + dscr = 1;
> + set_default_dscr(dscr);
> +
> + /* Spawn all testing threads */
> + for (i = 0; i < THREADS; i++) {
> + if (pthread_create(&threads[i], NULL, do_test, (void *)i)) {
> + perror("pthread_create() failed\n");
> + exit(1);
> + }
> + }
> +
> + srand(getpid());
> +
> + /* Keep changing the DSCR default */
> + for (i = 0; i < COUNT; i++) {
> + double ret = uniform_deviate(rand());
> +
> + if (ret < 0.0001) {
> + sequence++;
> + wmb();
> +
> + dscr++;
> + if (dscr > DSCR_MAX)
> + dscr = 0;
> +
> + set_default_dscr(dscr);
> +
> + wmb();
> + sequence++;
> + }
> + }
> +
> + /* Individual testing thread exit status */
> + for (i = 0; i < THREADS; i++) {
> + if (pthread_join(threads[i], (void **)&(status[i]))) {
> + perror("pthread_join() failed\n");
> + exit(1);
> + }
> +
> + if (*status[i]) {
> + printf("%ldth thread failed to join with %ld status\n",
> + i, *status[i]);
> + return 1;
> + }
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_default_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 07/12] selftests, powerpc: Add test for explicitly changing DSCR value
From: Shuah Khan @ 2015-01-13 15:23 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-8-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test which modifies the DSCR using mtspr instruction
> and verifies the change using mfspr instruction. It uses both the
> privilege state SPR as well as the problem state SPR for the purpose.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
> .../selftests/powerpc/dscr/dscr_explicit_test.c | 72 ++++++++++++++++++++++
> 2 files changed, 73 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 0aa90ab..aede453 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,4 +1,4 @@
> -PROGS := dscr_default_test
> +PROGS := dscr_default_test dscr_explicit_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c b/tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c
> new file mode 100644
> index 0000000..5c0b7c1
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_explicit_test.c
> @@ -0,0 +1,72 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) explicit test
> + *
> + * This test modifies the DSCR value using mtspr instruction and
> + * verifies the change with mfspr instruction. It uses both the
> + * privilege state SPR and the problem state SPR for this purpose.
> + *
> + * When using the privilege state SPR, the instructions such as
> + * mfspr or mtspr are priviledged and the kernel emulates them
> + * for us. Instructions using problem state SPR can be exuecuted
> + * directly without any emulation if the HW supports them. Else
> + * they also get emulated by the kernel.
> + *
> + * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +int test_body(void)
> +{
> + unsigned long i, dscr = 0;
> +
> + srand(getpid());
> + set_dscr(dscr);
> +
> + for (i = 0; i < COUNT; i++) {
> + unsigned long cur_dscr, cur_dscr_usr;
> + double ret = uniform_deviate(rand());
> +
> + if (ret < 0.001) {
> + dscr++;
> + if (dscr > DSCR_MAX)
> + dscr = 0;
> +
> + set_dscr(dscr);
> + }
> +
> + cur_dscr = get_dscr();
> + if (cur_dscr != dscr) {
> + fprintf(stderr, "Kernel DSCR should be %ld but "
> + "is %ld\n", dscr, cur_dscr);
> + return 1;
> + }
> +
> + ret = uniform_deviate(rand());
> + if (ret < 0.001) {
> + dscr++;
> + if (dscr > DSCR_MAX)
> + dscr = 0;
> +
> + set_dscr_usr(dscr);
> + }
> +
> + cur_dscr_usr = get_dscr_usr();
> + if (cur_dscr_usr != dscr) {
> + fprintf(stderr, "User DSCR should be %ld but "
> + "is %ld\n", dscr, cur_dscr_usr);
> + return 1;
> + }
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_explicit_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 08/12] selftests, powerpc: Add test for DSCR SPR numbers
From: Shuah Khan @ 2015-01-13 15:23 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-9-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test which verifies that the DSCR privilege and
> problem state SPR read & write accesses while making sure that the
> results are always the same irrespective of which SPR number is
> being used.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
> .../selftests/powerpc/dscr/dscr_user_test.c | 62 ++++++++++++++++++++++
> 2 files changed, 63 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_user_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index aede453..ae865d8 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,4 +1,4 @@
> -PROGS := dscr_default_test dscr_explicit_test
> +PROGS := dscr_default_test dscr_explicit_test dscr_user_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_user_test.c b/tools/testing/selftests/powerpc/dscr/dscr_user_test.c
> new file mode 100644
> index 0000000..f25d68e
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_user_test.c
> @@ -0,0 +1,62 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) SPR test
> + *
> + * This test modifies the DSCR value through both the SPR number
> + * based mtspr instruction and then makes sure that the same is
> + * reflected through mfspr instruction using either of the SPR
> + * numbers.
> + *
> + * When using the privilege state SPR, the instructions such as
> + * mfspr or mtspr are priviledged and the kernel emulates them
> + * for us. Instructions using problem state SPR can be exuecuted
> + * directly without any emulation if the HW supports them. Else
> + * they also get emulated by the kernel.
> + *
> + * Copyright (C) 2013 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +static int check_dscr(char *str)
> +{
> + unsigned long cur_dscr, cur_dscr_usr;
> +
> + cur_dscr = get_dscr();
> + cur_dscr_usr = get_dscr_usr();
> + if (cur_dscr != cur_dscr_usr) {
> + printf("%s set, kernel get %lx != user get %lx\n",
> + str, cur_dscr, cur_dscr_usr);
> + return 1;
> + }
> + return 0;
> +}
> +
> +int test_body(void)
> +{
> + int i;
> +
> + check_dscr("");
> +
> + for (i = 0; i < COUNT; i++) {
> + set_dscr(i);
> + if (check_dscr("kernel"))
> + return 1;
> + }
> +
> + for (i = 0; i < COUNT; i++) {
> + set_dscr_usr(i);
> + if (check_dscr("user"))
> + return 1;
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_user_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 09/12] selftests, powerpc: Add test for DSCR value inheritence across fork
From: Shuah Khan @ 2015-01-13 15:24 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-10-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test to verify that the changed DSCR value inside
> any process would be inherited to it's child process across the fork
> system call.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 3 +-
> .../selftests/powerpc/dscr/dscr_inherit_test.c | 96 ++++++++++++++++++++++
> 2 files changed, 98 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index ae865d8..81239e2 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,4 +1,5 @@
> -PROGS := dscr_default_test dscr_explicit_test dscr_user_test
> +PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
> + dscr_inherit_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
> new file mode 100644
> index 0000000..f1add77
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
> @@ -0,0 +1,96 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) fork test
> + *
> + * This testcase modifies the DSCR using mtspr, forks and then
> + * verifies that the child process has the correct changed DSCR
> + * value using mfspr.
> + *
> + * When using the privilege state SPR, the instructions such as
> + * mfspr or mtspr are priviledged and the kernel emulates them
> + * for us. Instructions using problem state SPR can be exuecuted
> + * directly without any emulation if the HW supports them. Else
> + * they also get emulated by the kernel.
> + *
> + * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +int test_body(void)
> +{
> + unsigned long i, dscr = 0;
> + pid_t pid;
> +
> + srand(getpid());
> + set_dscr(dscr);
> +
> + for (i = 0; i < COUNT; i++) {
> + unsigned long cur_dscr, cur_dscr_usr;
> +
> + dscr++;
> + if (dscr > DSCR_MAX)
> + dscr = 0;
> +
> + if (i % 2 == 0)
> + set_dscr_usr(dscr);
> + else
> + set_dscr(dscr);
> +
> + /*
> + * XXX: Force a context switch out so that DSCR
> + * current value is copied into the thread struct
> + * which is required for the child to inherit the
> + * changed value.
> + */
> + sleep(1);
> +
> + pid = fork();
> + if (pid == -1) {
> + perror("fork() failed\n");
> + exit(1);
> + } else if (pid) {
> + int status;
> +
> + if (waitpid(pid, &status, 0) == -1) {
> + perror("waitpid() failed\n");
> + exit(1);
> + }
> +
> + if (!WIFEXITED(status)) {
> + fprintf(stderr, "Child didn't exit cleanly\n");
> + exit(1);
> + }
> +
> + if (WEXITSTATUS(status) != 0) {
> + fprintf(stderr, "Child didn't exit cleanly\n");
> + return 1;
> + }
> + } else {
> + cur_dscr = get_dscr();
> + if (cur_dscr != dscr) {
> + fprintf(stderr, "Kernel DSCR should be %ld "
> + "but is %ld\n", dscr, cur_dscr);
> + exit(1);
> + }
> +
> + cur_dscr_usr = get_dscr_usr();
> + if (cur_dscr_usr != dscr) {
> + fprintf(stderr, "User DSCR should be %ld "
> + "but is %ld\n", dscr, cur_dscr_usr);
> + exit(1);
> + }
> + exit(0);
> + }
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_inherit_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 10/12] selftests, powerpc: Add test for DSCR inheritence across fork & exec
From: Shuah Khan @ 2015-01-13 15:24 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-11-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test case to verify that the changed DSCR value
> inside any process would be inherited to it's child across the fork
> and exec system call.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
> .../powerpc/dscr/dscr_inherit_exec_test.c | 118 +++++++++++++++++++++
> 2 files changed, 119 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 81239e2..4e84309 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,5 +1,5 @@
> PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
> - dscr_inherit_test
> + dscr_inherit_test dscr_inherit_exec_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
> new file mode 100644
> index 0000000..5ff3849
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
> @@ -0,0 +1,118 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) fork exec test
> + *
> + * This testcase modifies the DSCR using mtspr, forks & execs and
> + * verifies that the child is using the changed DSCR using mfspr.
> + *
> + * When using the privilege state SPR, the instructions such as
> + * mfspr or mtspr are priviledged and the kernel emulates them
> + * for us. Instructions using problem state SPR can be exuecuted
> + * directly without any emulation if the HW supports them. Else
> + * they also get emulated by the kernel.
> + *
> + * Copyright (C) 2012 Anton Blanchard <anton@au.ibm.com>, IBM
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +static char prog[LEN_MAX];
> +
> +static void do_exec(unsigned long parent_dscr)
> +{
> + unsigned long cur_dscr, cur_dscr_usr;
> +
> + cur_dscr = get_dscr();
> + cur_dscr_usr = get_dscr_usr();
> +
> + if (cur_dscr != parent_dscr) {
> + fprintf(stderr, "Parent DSCR %ld was not inherited "
> + "over exec (kernel value)\n", parent_dscr);
> + exit(1);
> + }
> +
> + if (cur_dscr_usr != parent_dscr) {
> + fprintf(stderr, "Parent DSCR %ld was not inherited "
> + "over exec (user value)\n", parent_dscr);
> + exit(1);
> + }
> + exit(0);
> +}
> +
> +int test_body(void)
> +{
> + unsigned long i, dscr = 0;
> + pid_t pid;
> +
> + for (i = 0; i < COUNT; i++) {
> + dscr++;
> + if (dscr > DSCR_MAX)
> + dscr = 0;
> +
> + if (dscr == get_default_dscr())
> + continue;
> +
> + if (i % 2 == 0)
> + set_dscr_usr(dscr);
> + else
> + set_dscr(dscr);
> +
> + /*
> + * XXX: Force a context switch out so that DSCR
> + * current value is copied into the thread struct
> + * which is required for the child to inherit the
> + * changed value.
> + */
> + sleep(1);
> +
> + pid = fork();
> + if (pid == -1) {
> + perror("fork() failed\n");
> + exit(1);
> + } else if (pid) {
> + int status;
> +
> + if (waitpid(pid, &status, 0) == -1) {
> + perror("waitpid() failed\n");
> + exit(1);
> + }
> +
> + if (!WIFEXITED(status)) {
> + fprintf(stderr, "Child didn't exit cleanly\n");
> + exit(1);
> + }
> +
> + if (WEXITSTATUS(status) != 0) {
> + fprintf(stderr, "Child didn't exit cleanly\n");
> + return 1;
> + }
> + } else {
> + char dscr_str[16];
> +
> + sprintf(dscr_str, "%ld", dscr);
> + execlp(prog, prog, "exec", dscr_str, NULL);
> + exit(1);
> + }
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + if (argc == 3 && !strcmp(argv[1], "exec")) {
> + unsigned long parent_dscr;
> +
> + parent_dscr = atoi(argv[2]);
> + do_exec(parent_dscr);
> + } else if (argc != 1) {
> + fprintf(stderr, "Usage: %s\n", argv[0]);
> + exit(1);
> + }
> +
> + strncpy(prog, argv[0], strlen(argv[0]));
> + return test_harness(test_body, "dscr_inherit_exec_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 11/12] selftests, powerpc: Add test for all DSCR sysfs interfaces
From: Shuah Khan @ 2015-01-13 15:24 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-12-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This test continuously updates the system wide DSCR default value
> in the sysfs interface and makes sure that the same is reflected
> across all the sysfs interfaces for each individual CPUs present
> on the system.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 3 +-
> .../selftests/powerpc/dscr/dscr_sysfs_test.c | 89 ++++++++++++++++++++++
> 2 files changed, 91 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 4e84309..fada526 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,5 +1,6 @@
> PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
> - dscr_inherit_test dscr_inherit_exec_test
> + dscr_inherit_test dscr_inherit_exec_test \
> + dscr_sysfs_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
> new file mode 100644
> index 0000000..3d11439
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_test.c
> @@ -0,0 +1,89 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) sysfs interface test
> + *
> + * This test updates to system wide DSCR default through the sysfs interface
> + * and then verifies that all the CPU specific DSCR defaults are updated as
> + * well verified from their sysfs interfaces.
> + *
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#include "dscr.h"
> +
> +static int check_cpu_dscr_default(char *file, unsigned long val)
> +{
> + char buf[10];
> + int fd, rc;
> +
> + fd = open(file, O_RDWR);
> + if (fd == -1) {
> + perror("open() failed\n");
> + return 1;
> + }
> +
> + rc = read(fd, buf, sizeof(buf));
> + if (rc == -1) {
> + perror("read() failed\n");
> + return 1;
> + }
> + close(fd);
> +
> + buf[rc] = '\0';
> + if (strtol(buf, NULL, 16) != val) {
> + printf("DSCR match failed: %ld (system) %ld (cpu)\n",
> + val, strtol(buf, NULL, 16));
> + return 1;
> + }
> + return 0;
> +}
> +
> +static int check_all_cpu_dscr_defaults(unsigned long val)
> +{
> + DIR *sysfs;
> + struct dirent *dp;
> + char file[LEN_MAX];
> +
> + sysfs = opendir(CPU_PATH);
> + if (!sysfs) {
> + perror("opendir() failed\n");
> + return 1;
> + }
> +
> + while ((dp = readdir(sysfs))) {
> + if (!(dp->d_type & DT_DIR))
> + continue;
> + if (!strcmp(dp->d_name, "cpuidle"))
> + continue;
> + if (!strstr(dp->d_name, "cpu"))
> + continue;
> +
> + sprintf(file, "%s%s/dscr", CPU_PATH, dp->d_name);
> + if (check_cpu_dscr_default(file, val))
> + return 1;
> + }
> + closedir(sysfs);
> + return 0;
> +}
> +
> +int test_body(void)
> +{
> + int i, j;
> +
> + for (i = 0; i < COUNT; i++) {
> + for (j = 0; j < DSCR_MAX; j++) {
> + set_default_dscr(j);
> + if (check_all_cpu_dscr_defaults(j))
> + return 1;
> + }
> + }
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_sysfs_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V2 12/12] selftests, powerpc: Add thread based stress test for DSCR sysfs interfaces
From: Shuah Khan @ 2015-01-13 15:24 UTC (permalink / raw)
To: Anshuman Khandual, linuxppc-dev, linux-kernel; +Cc: mikey, anton
In-Reply-To: <1421144560-15901-13-git-send-email-khandual@linux.vnet.ibm.com>
On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> This patch adds a test to update the system wide DSCR value repeatedly
> and then verifies that any thread on any given CPU on the system must
> be able to see the same DSCR value whether its is being read through
> the problem state based SPR or the privilege state based SPR.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> tools/testing/selftests/powerpc/dscr/Makefile | 2 +-
> .../powerpc/dscr/dscr_sysfs_thread_test.c | 114 +++++++++++++++++++++
> 2 files changed, 115 insertions(+), 1 deletion(-)
> create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
>
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index fada526..834ef88 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -1,6 +1,6 @@
> PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
> dscr_inherit_test dscr_inherit_exec_test \
> - dscr_sysfs_test
> + dscr_sysfs_test dscr_sysfs_thread_test
>
> CFLAGS := $(CFLAGS) -lpthread
>
> diff --git a/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
> new file mode 100644
> index 0000000..95a4304
> --- /dev/null
> +++ b/tools/testing/selftests/powerpc/dscr/dscr_sysfs_thread_test.c
> @@ -0,0 +1,114 @@
> +/*
> + * POWER Data Stream Control Register (DSCR) sysfs thread test
> + *
> + * This test updates the system wide DSCR default value through
> + * sysfs interface which should then update all the CPU specific
> + * DSCR default values which must also be then visible to threads
> + * executing on individual CPUs on the system.
> + *
> + * Copyright (C) 2015 Anshuman Khandual <khandual@linux.vnet.ibm.com>, IBM
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + */
> +#define _GNU_SOURCE
> +#include "dscr.h"
> +
> +static pthread_mutex_t lock; /* Pthread lock */
> +static cpu_set_t cpuset; /* Thread cpu set */
> +static int target; /* Thread target cpu */
> +static unsigned long *result; /* Thread exit status array */
> +
> +static void *test_thread_dscr(void *in)
> +{
> + unsigned long cur_dscr, cur_dscr_usr;
> + unsigned long val = (unsigned long)in;
> +
> + pthread_mutex_lock(&lock);
> + target++;
> + if (target == sysconf(_SC_NPROCESSORS_ONLN))
> + target = 0;
> + CPU_ZERO(&cpuset);
> + CPU_SET(target, &cpuset);
> +
> + if (sched_setaffinity(0, sizeof(cpuset), &cpuset)) {
> + perror("sched_settarget_cpu() failed\n");
> + pthread_mutex_unlock(&lock);
> + result[target] = 1;
> + pthread_exit(&result[target]);
> + }
> + pthread_mutex_unlock(&lock);
> +
> + cur_dscr = get_dscr();
> + cur_dscr_usr = get_dscr_usr();
> +
> + if (val != cur_dscr) {
> + printf("[cpu %d] Kernel DSCR should be %ld but is %ld\n",
> + sched_getcpu(), val, cur_dscr);
> + result[target] = 1;
> + pthread_exit(&result[target]);
> + }
> +
> + if (val != cur_dscr_usr) {
> + printf("[cpu %d] User DSCR should be %ld but is %ld\n",
> + sched_getcpu(), val, cur_dscr_usr);
> + result[target] = 1;
> + pthread_exit(&result[target]);
> + }
> + result[target] = 0;
> + pthread_exit(&result[target]);
> +}
> +
> +static int check_cpu_dscr_thread(unsigned long val)
> +{
> + pthread_t threads[sysconf(_SC_NPROCESSORS_ONLN)];
> + unsigned long *status[sysconf(_SC_NPROCESSORS_ONLN)];
> + unsigned long i;
> +
> + for (i = 0; i < sysconf(_SC_NPROCESSORS_ONLN); i++) {
> + if (pthread_create(&threads[i], NULL,
> + test_thread_dscr, (void *)val)) {
> + perror("pthread_create() failed\n");
> + return 1;
> + }
> + }
> +
> + for (i = 0; i < sysconf(_SC_NPROCESSORS_ONLN); i++) {
> + if (pthread_join(threads[i], (void **)&(status[i]))) {
> + perror("pthread_join() failed\n");
> + return 1;
> + }
> +
> + if (*status[i]) {
> + printf(" %ldth thread join failed with %ld\n",
> + i, *status[i]);
> + return 1;
> + }
> + }
> + return 0;
> +}
> +
> +int test_body(void)
> +{
> + int i, j;
> +
> + result = malloc(sizeof(unsigned long) * sysconf(_SC_NPROCESSORS_ONLN));
> + pthread_mutex_init(&lock, NULL);
> + target = 0;
> + for (i = 0; i < COUNT; i++) {
> + for (j = 0; j < DSCR_MAX; j++) {
> + set_default_dscr(j);
> + if (check_cpu_dscr_thread(j))
> + return 1;
> + }
> + }
> + free(result);
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + return test_harness(test_body, "dscr_sysfs_thread_test");
> +}
>
Could you please add a .gitignore for powerpc targets as we
discussed earlier. It can be separate patch.
Also, I would like to see the test results reports using
kselftest.h - it can be separate patch in the interest of
getting tests in.
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
Please take this through powerpc maintainer git.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH V10 00/17] Enable SRIOV on Power8
From: Bjorn Helgaas @ 2015-01-13 18:05 UTC (permalink / raw)
To: Wei Yang; +Cc: linux-pci, benh, linuxppc-dev, gwshan
In-Reply-To: <20141222060522.GA12285@richard>
On Mon, Dec 22, 2014 at 02:05:22PM +0800, Wei Yang wrote:
> Bjorn,
>
> This patch set is tested on 3.19-rc1 and with the offset/stride update patch.
>
> I see your comment on the MEM64 issue, so if that is reverted, this
> patch set will not work. While I think we can work in parallel, I sent it here
> for more comment and to see whether I understand your previous comments
> correctly.
>
> I will work with Yinghai to find a way to fix the bug 85491, hope linux kernel
> could handle both cases.
OK. The autobuilder found some minor issues, so I'll look for a v11
posting that fixes those. Please pick up the changelogs from my
pci/virtualization branch because I rewrapped them so they fit in 80
columns when shown by "git log".
Bjorn
^ permalink raw reply
* Re: [PATCH 3/6] powerpc/ps3: Write highmem info to repository
From: Geoff Levand @ 2015-01-13 18:33 UTC (permalink / raw)
To: Michael Ellerman
Cc: cbe-oss-dev, Andre Heider, Hector Martin, Nathan Whitehorn,
linuxppc-dev
In-Reply-To: <1421118298.26626.2.camel@ellerman.id.au>
Hi Michael,
On Tue, 2015-01-13 at 14:04 +1100, Michael Ellerman wrote:
> On Tue, 2015-01-13 at 01:00 +0000, Geoff Levand wrote:
> > Add calls to the ps3_mm_set_repository_highmem() routine when the ps3
> > r1 highmem region is either created or destroyed.
>
> What does this actually do? ie. from a user perspective.
It will allow a kexec based bootloader (petitboot for example) to
pre-allocate a highmem region and store things like an initrd or other
large data needed to boot an OS. With some PS3 configurations the boot
memory region is not large enough to fit all the boot data.
There was ongoing discussion about this on the ML. Here are two
relevant posts:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2012-April/097691.html
https://lists.ozlabs.org/pipermail/linuxppc-dev/2012-April/097695.html
Here is the very first post which outlines the motivation, etc.:
https://lists.ozlabs.org/pipermail/cbe-oss-dev/2011-August/007420.html
-Geoff
^ permalink raw reply
* Re: [PATCH V2 06/12] selftests, powerpc: Add test for system wide DSCR default
From: Michael Ellerman @ 2015-01-13 23:44 UTC (permalink / raw)
To: Shuah Khan; +Cc: mikey, linux-kernel, anton, linuxppc-dev, Anshuman Khandual
In-Reply-To: <54B5384F.9010805@osg.samsung.com>
On Tue, 2015-01-13 at 08:22 -0700, Shuah Khan wrote:
> On 01/13/2015 03:22 AM, Anshuman Khandual wrote:
> > This patch adds a test case for the system wide DSCR default
> > value, which when changed through it's sysfs interface must
> > be visible to all threads reading DSCR either through the
> > privilege state SPR or the problem state SPR. The DSCR value
> > change should be immediate as well.
> >
> > Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> > ---
> > tools/testing/selftests/powerpc/Makefile | 2 +-
> > tools/testing/selftests/powerpc/dscr/Makefile | 17 +++
> > tools/testing/selftests/powerpc/dscr/dscr.h | 120 ++++++++++++++++++++
> > .../selftests/powerpc/dscr/dscr_default_test.c | 121 +++++++++++++++++++++
> > 4 files changed, 259 insertions(+), 1 deletion(-)
> > create mode 100644 tools/testing/selftests/powerpc/dscr/Makefile
> > create mode 100644 tools/testing/selftests/powerpc/dscr/dscr.h
> > create mode 100644 tools/testing/selftests/powerpc/dscr/dscr_default_test.c
>
> Could you please add a .gitignore for powerpc targets as we
> discussed earlier. It can be separate patch.
I can do that.
> Also, I would like to see the test results reports using
> kselftest.h - it can be separate patch in the interest of
> getting tests in.
Sorry but kselftest.h doesn't do anything useful for us.
We have existing test reporting that uses the subunit protocol.
I'm happy to convert that to TAP, or some other well defined output format, but
not to something ad-hoc like kselftest.h currently provides.
cheers
^ permalink raw reply
* [PATCH] selftests/powerpc: Add .gitignore for powerpc selftests
From: Michael Ellerman @ 2015-01-13 23:49 UTC (permalink / raw)
To: linuxppc-dev; +Cc: linux-kernel, shuahkh
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
.../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++
tools/testing/selftests/powerpc/mm/.gitignore | 1 +
tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++
tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++
.../selftests/powerpc/primitives/.gitignore | 1 +
tools/testing/selftests/powerpc/tm/.gitignore | 1 +
6 files changed, 32 insertions(+)
create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore
create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore
create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore
create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore
create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
diff --git a/tools/testing/selftests/powerpc/copyloops/.gitignore b/tools/testing/selftests/powerpc/copyloops/.gitignore
new file mode 100644
index 000000000000..25a192f62c4d
--- /dev/null
+++ b/tools/testing/selftests/powerpc/copyloops/.gitignore
@@ -0,0 +1,4 @@
+copyuser_64
+copyuser_power7
+memcpy_64
+memcpy_power7
diff --git a/tools/testing/selftests/powerpc/mm/.gitignore b/tools/testing/selftests/powerpc/mm/.gitignore
new file mode 100644
index 000000000000..156f4e89c2f1
--- /dev/null
+++ b/tools/testing/selftests/powerpc/mm/.gitignore
@@ -0,0 +1 @@
+hugetlb_vs_thp_test
diff --git a/tools/testing/selftests/powerpc/pmu/.gitignore b/tools/testing/selftests/powerpc/pmu/.gitignore
new file mode 100644
index 000000000000..e748f336eed3
--- /dev/null
+++ b/tools/testing/selftests/powerpc/pmu/.gitignore
@@ -0,0 +1,3 @@
+count_instructions
+l3_bank_test
+per_event_excludes
diff --git a/tools/testing/selftests/powerpc/pmu/ebb/.gitignore b/tools/testing/selftests/powerpc/pmu/ebb/.gitignore
new file mode 100644
index 000000000000..5967ff34c167
--- /dev/null
+++ b/tools/testing/selftests/powerpc/pmu/ebb/.gitignore
@@ -0,0 +1,22 @@
+back_to_back_ebbs_test
+close_clears_pmcc_test
+cpu_event_pinned_vs_ebb_test
+cpu_event_vs_ebb_test
+cycles_test
+cycles_with_freeze_test
+cycles_with_mmcr2_test
+ebb_on_child_test
+ebb_on_willing_child_test
+ebb_vs_cpu_event_test
+event_attributes_test
+fork_cleanup_test
+instruction_count_test
+lost_exception_test
+multi_counter_test
+multi_ebb_procs_test
+no_handler_test
+pmae_handling_test
+pmc56_overflow_test
+reg_access_test
+task_event_pinned_vs_ebb_test
+task_event_vs_ebb_test
diff --git a/tools/testing/selftests/powerpc/primitives/.gitignore b/tools/testing/selftests/powerpc/primitives/.gitignore
new file mode 100644
index 000000000000..4cc4e31bed1d
--- /dev/null
+++ b/tools/testing/selftests/powerpc/primitives/.gitignore
@@ -0,0 +1 @@
+load_unaligned_zeropad
diff --git a/tools/testing/selftests/powerpc/tm/.gitignore b/tools/testing/selftests/powerpc/tm/.gitignore
new file mode 100644
index 000000000000..33d02cc54a3e
--- /dev/null
+++ b/tools/testing/selftests/powerpc/tm/.gitignore
@@ -0,0 +1 @@
+tm-resched-dscr
--
2.1.0
^ permalink raw reply related
* Re: [PATCH] selftests/powerpc: Add .gitignore for powerpc selftests
From: Shuah Khan @ 2015-01-14 0:16 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: linux-kernel
In-Reply-To: <1421192997-17003-1-git-send-email-mpe@ellerman.id.au>
Please add a commit log.
On 01/13/2015 04:49 PM, Michael Ellerman wrote:
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
> .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++
> tools/testing/selftests/powerpc/mm/.gitignore | 1 +
> tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++
> tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++
> .../selftests/powerpc/primitives/.gitignore | 1 +
> tools/testing/selftests/powerpc/tm/.gitignore | 1 +
> 6 files changed, 32 insertions(+)
> create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore
> create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore
> create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore
> create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore
> create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
> create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
Please create a single .gitignore for all targets right under
tools/testing/selftests/powerpc instead of multiple .gitignore
files.
thanks,
-- Shuah
--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978
^ permalink raw reply
* Re: [PATCH] selftests/powerpc: Add .gitignore for powerpc selftests
From: Michael Ellerman @ 2015-01-14 2:15 UTC (permalink / raw)
To: Shuah Khan; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <54B5B561.40406@osg.samsung.com>
On Tue, 2015-01-13 at 17:16 -0700, Shuah Khan wrote:
> Please add a commit log.
What does it need to say?
> On 01/13/2015 04:49 PM, Michael Ellerman wrote:
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> > ---
> > .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++
> > tools/testing/selftests/powerpc/mm/.gitignore | 1 +
> > tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++
> > tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++
> > .../selftests/powerpc/primitives/.gitignore | 1 +
> > tools/testing/selftests/powerpc/tm/.gitignore | 1 +
> > 6 files changed, 32 insertions(+)
> > create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore
> > create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore
> > create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore
> > create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore
> > create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
> > create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
>
> Please create a single .gitignore for all targets right under
> tools/testing/selftests/powerpc instead of multiple .gitignore
> files.
Why? Having separate files makes it less likely we'll get merge conflicts
between different test subdirectores, it also makes it more likely someone
adding a test will notice they need to update the .gitignore in the same
directory.
cheers
^ permalink raw reply
* [PATCH] powerpc: Remove old compile time disabled syscall tracing code
From: Michael Ellerman @ 2015-01-14 3:47 UTC (permalink / raw)
To: linuxppc-dev
We have code to do syscall tracing which is disabled at compile time by
default. It's not been touched since the dawn of time (ie. v2.6.12).
There are now better ways to do syscall tracing, ie. using the
raw_syscall, or syscall tracepoints.
For the specific case of tracing syscalls at boot on a system that
doesn't get to userspace, you can boot with:
trace_event=syscalls tp_printk=on
Which will trace syscalls from boot, and echo all output to the console.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/kernel/entry_32.S | 77 ------------------------------------------
arch/powerpc/kernel/entry_64.S | 13 -------
arch/powerpc/kernel/syscalls.c | 14 --------
3 files changed, 104 deletions(-)
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 10a093579191..cb8ef68a1ae5 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -33,9 +33,6 @@
#include <asm/ftrace.h>
#include <asm/ptrace.h>
-#undef SHOW_SYSCALLS
-#undef SHOW_SYSCALLS_TASK
-
/*
* MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE.
*/
@@ -307,9 +304,6 @@ _GLOBAL(DoSyscall)
lwz r11,_CCR(r1) /* Clear SO bit in CR */
rlwinm r11,r11,0,4,2
stw r11,_CCR(r1)
-#ifdef SHOW_SYSCALLS
- bl do_show_syscall
-#endif /* SHOW_SYSCALLS */
#ifdef CONFIG_TRACE_IRQFLAGS
/* Return from syscalls can (and generally will) hard enable
* interrupts. You aren't supposed to call a syscall with
@@ -352,9 +346,6 @@ syscall_dotrace_cont:
blrl /* Call handler */
.globl ret_from_syscall
ret_from_syscall:
-#ifdef SHOW_SYSCALLS
- bl do_show_syscall_exit
-#endif
mr r6,r3
CURRENT_THREAD_INFO(r12, r1)
/* disable interrupts so current_thread_info()->flags can't change */
@@ -523,74 +514,6 @@ syscall_exit_work:
bl do_syscall_trace_leave
b ret_from_except_full
-#ifdef SHOW_SYSCALLS
-do_show_syscall:
-#ifdef SHOW_SYSCALLS_TASK
- lis r11,show_syscalls_task@ha
- lwz r11,show_syscalls_task@l(r11)
- cmp 0,r2,r11
- bnelr
-#endif
- stw r31,GPR31(r1)
- mflr r31
- lis r3,7f@ha
- addi r3,r3,7f@l
- lwz r4,GPR0(r1)
- lwz r5,GPR3(r1)
- lwz r6,GPR4(r1)
- lwz r7,GPR5(r1)
- lwz r8,GPR6(r1)
- lwz r9,GPR7(r1)
- bl printk
- lis r3,77f@ha
- addi r3,r3,77f@l
- lwz r4,GPR8(r1)
- mr r5,r2
- bl printk
- lwz r0,GPR0(r1)
- lwz r3,GPR3(r1)
- lwz r4,GPR4(r1)
- lwz r5,GPR5(r1)
- lwz r6,GPR6(r1)
- lwz r7,GPR7(r1)
- lwz r8,GPR8(r1)
- mtlr r31
- lwz r31,GPR31(r1)
- blr
-
-do_show_syscall_exit:
-#ifdef SHOW_SYSCALLS_TASK
- lis r11,show_syscalls_task@ha
- lwz r11,show_syscalls_task@l(r11)
- cmp 0,r2,r11
- bnelr
-#endif
- stw r31,GPR31(r1)
- mflr r31
- stw r3,RESULT(r1) /* Save result */
- mr r4,r3
- lis r3,79f@ha
- addi r3,r3,79f@l
- bl printk
- lwz r3,RESULT(r1)
- mtlr r31
- lwz r31,GPR31(r1)
- blr
-
-7: .string "syscall %d(%x, %x, %x, %x, %x, "
-77: .string "%x), current=%p\n"
-79: .string " -> %x\n"
- .align 2,0
-
-#ifdef SHOW_SYSCALLS_TASK
- .data
- .globl show_syscalls_task
-show_syscalls_task:
- .long -1
- .text
-#endif
-#endif /* SHOW_SYSCALLS */
-
/*
* The fork/clone functions need to copy the full register set into
* the child process. Therefore we need to save all the nonvolatile
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 194e46dcf08d..c6dcb560c295 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -49,8 +49,6 @@ exception_marker:
.section ".text"
.align 7
-#undef SHOW_SYSCALLS
-
.globl system_call_common
system_call_common:
andi. r10,r12,MSR_PR
@@ -142,13 +140,6 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
li r10,1
std r10,SOFTE(r1)
-#ifdef SHOW_SYSCALLS
- bl do_show_syscall
- REST_GPR(0,r1)
- REST_4GPRS(3,r1)
- REST_2GPRS(7,r1)
- addi r9,r1,STACK_FRAME_OVERHEAD
-#endif
CURRENT_THREAD_INFO(r11, r1)
ld r10,TI_FLAGS(r11)
andi. r11,r10,_TIF_SYSCALL_T_OR_A
@@ -180,10 +171,6 @@ system_call: /* label this so stack traces look sane */
syscall_exit:
std r3,RESULT(r1)
-#ifdef SHOW_SYSCALLS
- bl do_show_syscall_exit
- ld r3,RESULT(r1)
-#endif
CURRENT_THREAD_INFO(r12, r1)
ld r8,_MSR(r1)
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index cd9be9aa016d..b2702e87db0d 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -121,17 +121,3 @@ long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
(u64)len_high << 32 | len_low, advice);
}
-
-void do_show_syscall(unsigned long r3, unsigned long r4, unsigned long r5,
- unsigned long r6, unsigned long r7, unsigned long r8,
- struct pt_regs *regs)
-{
- printk("syscall %ld(%lx, %lx, %lx, %lx, %lx, %lx) regs=%p current=%p"
- " cpu=%d\n", regs->gpr[0], r3, r4, r5, r6, r7, r8, regs,
- current, smp_processor_id());
-}
-
-void do_show_syscall_exit(unsigned long r3)
-{
- printk(" -> %lx, current=%p cpu=%d\n", r3, current, smp_processor_id());
-}
--
2.1.0
^ permalink raw reply related
* Re: [PATCH] selftests/powerpc: Add .gitignore for powerpc selftests
From: Anshuman Khandual @ 2015-01-14 3:50 UTC (permalink / raw)
To: Michael Ellerman, Shuah Khan; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1421201759.10748.8.camel@ellerman.id.au>
On 01/14/2015 07:45 AM, Michael Ellerman wrote:
> On Tue, 2015-01-13 at 17:16 -0700, Shuah Khan wrote:
>> Please add a commit log.
>
> What does it need to say?
>
>> On 01/13/2015 04:49 PM, Michael Ellerman wrote:
>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>> ---
>>> .../testing/selftests/powerpc/copyloops/.gitignore | 4 ++++
>>> tools/testing/selftests/powerpc/mm/.gitignore | 1 +
>>> tools/testing/selftests/powerpc/pmu/.gitignore | 3 +++
>>> tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 ++++++++++++++++++++++
>>> .../selftests/powerpc/primitives/.gitignore | 1 +
>>> tools/testing/selftests/powerpc/tm/.gitignore | 1 +
>>> 6 files changed, 32 insertions(+)
>>> create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore
>>> create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore
>>> create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore
>>> create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore
>>> create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
>>> create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
>>
>> Please create a single .gitignore for all targets right under
>> tools/testing/selftests/powerpc instead of multiple .gitignore
>> files.
>
> Why? Having separate files makes it less likely we'll get merge conflicts
> between different test subdirectores, it also makes it more likely someone
> adding a test will notice they need to update the .gitignore in the same
> directory.
Hey Michael,
I had already posted a similar patch in this regard along with the ptrace
patches last month. Thats why I mentioned in the cover letter that
gitignore updates for all these tests will come from that patch series
instead of from this one.
https://lkml.org/lkml/2014/12/2/80
Regards
Anshuman
^ permalink raw reply
* Re: offlining cpus breakage
From: Shreyas B Prabhu @ 2015-01-14 4:20 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev@lists.ozlabs.org
Cc: preeti U Murthy, Paul Mackerras
In-Reply-To: <54ACFE6D.3070308@ozlabs.ru>
Hi,
On Wednesday 07 January 2015 03:07 PM, Alexey Kardashevskiy wrote:
> Hi!
>
> "ppc64_cpu --smt=off" produces multiple error on the latest upstream kernel
> (sha1 bdec419):
>
> NMI watchdog: BUG: soft lockup - CPU#20 stuck for 23s! [swapper/20:0]
>
> or
>
> INFO: rcu_sched detected stalls on CPUs/tasks: { 2 7 8 9 10 11 12 13 14 15
> 16 17 18 19 20 21 22 23 2
> 4 25 26 27 28 29 30 31} (detected by 6, t=2102 jiffies, g=1617, c=1616,
> q=1441)
>
> and many others, all about lockups
>
> I did bisecting and found out that reverting these helps:
>
> 77b54e9f213f76a23736940cf94bcd765fc00f40 powernv/powerpc: Add winkle
> support for offline cpus
> 7cba160ad789a3ad7e68b92bf20eaad6ed171f80 powernv/cpuidle: Redesign idle
> states management
> 8eb8ac89a364305d05ad16be983b7890eb462cc3 powerpc/powernv: Enable Offline
> CPUs to enter deep idle states
>
> btw reverting just two of them produces a compile error.
>
> It is pseries_le_defconfig, POWER8 machine:
> timebase : 512000000
> platform : PowerNV
> model : palmetto
> machine : PowerNV palmetto
> firmware : OPAL v3
>
>
> Please help to fix it. Thanks.
>
>
Upon investigation, we figured that the cpu is stuck in cpu_idle_poll
loop in kernel/sched/idle.c leading us to believe the bug is in timer
offload framework which fastsleep uses. Preeti and I are working on a
fix. We'll post it out as soon as possible.
Thanks,
Shreyas
^ permalink raw reply
* Re: [PATCH v3 1/3] powerpc/nvram: move generic code for nvram and pstore
From: Michael Ellerman @ 2015-01-14 4:31 UTC (permalink / raw)
To: Hari Bathini; +Cc: linuxppc-dev, Mahesh J Salgaonkar
In-Reply-To: <20141224115825.25731.65673.stgit@localhost.localdomain>
On Wed, 2014-12-24 at 17:28 +0530, Hari Bathini wrote:
> With minor checks, we can move most of the code for nvram
> under pseries to a common place to be re-used by other
> powerpc platforms like powernv. This patch moves such
> common code to arch/powerpc/kernel/nvram_64.c file.
As I said in my reply to the previous version:
... you need to keep in mind that it is very common for us to build kernels
with both POWERNV=y and PSERIES=y.
So you need to make sure you're only using CONFIG_PPC_PSERIES to protect things
that are optional on pseries. Not things that we *shouldn't* be doing on
powernv.
Please explain in your commit message how you have dealt with that.
Also, you broke the build for every config that doesn't have
CONFIG_PPC_PSERIES, all 95 of them. This is pasemi_defconfig for example:
LD arch/powerpc/mm/built-in.o
arch/powerpc/mm/init_64.o: In function `clobbering_unread_rtas_event':
init_64.c:(.opd+0x48): multiple definition of `clobbering_unread_rtas_event'
arch/powerpc/mm/mem.o:mem.c:(.opd+0x90): first defined here
arch/powerpc/mm/init_64.o: In function `.clobbering_unread_rtas_event':
init_64.c:(.text+0x80): multiple definition of `.clobbering_unread_rtas_event'
arch/powerpc/mm/mem.o:mem.c:(.text+0x2c0): first defined here
CC arch/powerpc/kernel/udbg.o
/home/kisskb/slave/src/scripts/Makefile.build:336: recipe for target 'arch/powerpc/mm/built-in.o' failed
make[2]: *** [arch/powerpc/mm/built-in.o] Error 1
/home/kisskb/slave/src/Makefile:938: recipe for target 'arch/powerpc/mm' failed
make[1]: *** [arch/powerpc/mm] Error 2
make[1]: *** Waiting for unfinished jobs....
cheers
^ permalink raw reply
* Re: [PATCH v3 2/3] pstore: Add pstore type id for firmware partition
From: Michael Ellerman @ 2015-01-14 4:31 UTC (permalink / raw)
To: Hari Bathini; +Cc: linuxppc-dev, Mahesh J Salgaonkar
In-Reply-To: <20141224115842.25731.94235.stgit@localhost.localdomain>
On Wed, 2014-12-24 at 17:28 +0530, Hari Bathini wrote:
> This patch adds a pstore type id to be used for opal specific
> nvram partitions.
This needs to be CC'ed to the pstore maintainers, and at the very least get an
ACK from them.
They also might ask why we need another powerpc specific pstore type, we
already have 3 of the 7 that exist.
cheers
^ permalink raw reply
* Re: [V6,1/9] elf: Add new powerpc specifc core note sections
From: Anshuman Khandual @ 2015-01-14 4:44 UTC (permalink / raw)
To: Edjunior Barbosa Machado, Michael Ellerman, linux-kernel,
linuxppc-dev
Cc: mikey, james.hogan, avagin, Paul.Clothier, davem, peterz, palves,
Ulrich Weigand, shuahkh, oleg, dhowells, kirjanov, davej, akpm,
sukadev, tglx, sam.bobroff
In-Reply-To: <54A50094.5070902@linux.vnet.ibm.com>
On 01/01/2015 01:38 PM, Anshuman Khandual wrote:
>> > Also, we've noticed that the 'misc' regset contains registers from different ISA
>> > versions (dscr and ppr appear in ISA 2.05, tar is from 2.07). I'm not sure if
>> > there is a way to detect presence/validity of such registers, but perhaps it
>> > might be a good idea to separate registers from different ISAs in different
>> > regsets.
> Thats right, will use feature CPU_FTR_ARCH_207S (which checks whether we are v2.07
> compliant) to detect whether TAR register is available or not.
>
Need to correct something here. Run time detection of the presence of TAR register
through the feature bit CPU_FTR_ARCH_207S as I had mentioned before is not required.
Right now we take care of the compile time availability of the individual registers
the same way it is present on the thread struct. In the systems which do not have the
TAR register, thread.tar is always going to be 0 which is exactly the same value we
would get by excluding tar register copy after the run time detection of the feature.
^ permalink raw reply
* [PATCH V7 1/8] elf: Add new powerpc specifc core note sections
From: Anshuman Khandual @ 2015-01-14 7:08 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: shuahkh, mikey, james.hogan, avagin, Paul.Clothier, peterz,
palves, oleg, davem, dhowells, kirjanov, davej, akpm, sukadev,
tglx, sam.bobroff
In-Reply-To: <1421219330-19984-1-git-send-email-khandual@linux.vnet.ibm.com>
This patch adds four new ELF core note sections for powerpc
transactional memory and one new ELF core note section for
powerpc general miscellaneous debug registers. These addition
of new ELF core note sections extends the existing ELF ABI
without affecting it in any manner.
Acked-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
include/uapi/linux/elf.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
index 71e1d0e..0fd9983 100644
--- a/include/uapi/linux/elf.h
+++ b/include/uapi/linux/elf.h
@@ -379,6 +379,11 @@ typedef struct elf64_shdr {
#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
+#define NT_PPC_TM_SPR 0x103 /* PowerPC TM special registers */
+#define NT_PPC_TM_CGPR 0x104 /* PowerpC TM checkpointed GPR */
+#define NT_PPC_TM_CFPR 0x105 /* PowerPC TM checkpointed FPR */
+#define NT_PPC_TM_CVMX 0x106 /* PowerPC TM checkpointed VMX */
+#define NT_PPC_MISC 0x107 /* PowerPC miscellaneous registers */
#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
--
1.9.3
^ permalink raw reply related
* [PATCH V7 0/8] Add new powerpc specific ELF core notes
From: Anshuman Khandual @ 2015-01-14 7:08 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: shuahkh, mikey, james.hogan, avagin, Paul.Clothier, peterz,
palves, oleg, davem, dhowells, kirjanov, davej, akpm, sukadev,
tglx, sam.bobroff
This patch series adds five new ELF core note sections which can be
used with existing ptrace request PTRACE_GETREGSET-SETREGSET for accessing
various transactional memory and miscellaneous debug register sets on powerpc
platform.
Previous versions:
==================
RFC: https://lkml.org/lkml/2014/4/1/292
V1: https://lkml.org/lkml/2014/4/2/43
V2: https://lkml.org/lkml/2014/5/5/88
V3: https://lkml.org/lkml/2014/5/23/486
V4: https://lkml.org/lkml/2014/11/11/6
V5: https://lkml.org/lkml/2014/11/25/134
V6: https://lkml.org/lkml/2014/12/2/98
Changes in V7:
--------------
- Fixed a config directive in the MISC code
- Merged the two gitignore patches into a single one
Changes in V6:
--------------
- Added two git ignore patches for powerpc selftests
- Re-formatted all in-code function definitions in kernel-doc format
Changes in V5:
--------------
- Changed flush_tmregs_to_thread, so not to take into account self tracing
- Dropped the 3rd patch in the series which had merged two functions
- Fixed one build problem for the misc debug register patch
- Accommodated almost all the review comments from Suka on the 6th patch
- Minor changes to the self test program
- Changed commit messages for some of the patches
Changes in V4:
--------------
- Added one test program into the powerpc selftest bucket in this regard
- Split the 2nd patch in the previous series into four different patches
- Accommodated most of the review comments on the previous patch series
- Added a patch to merge functions __switch_to_tm and tm_reclaim_task
Changes in V3:
--------------
- Added two new error paths in every TM related get/set functions when regset
support is not present on the system (ENODEV) or when the process does not
have any transaction active (ENODATA) in the context
- Installed the active hooks for all the newly added regset core note types
Changes in V2:
--------------
- Removed all the power specific ptrace requests corresponding to new NT_PPC_*
elf core note types. Now all the register sets can be accessed from ptrace
through PTRACE_GETREGSET/PTRACE_SETREGSET using the individual NT_PPC* core
note type instead
- Fixed couple of attribute values for REGSET_TM_CGPR register set
- Renamed flush_tmreg_to_thread as flush_tmregs_to_thread
- Fixed 32 bit checkpointed GPR support
- Changed commit messages accordingly
Test Result
-----------
The patch series has been verified both in 32 bit and 64 bit compiled test
program. Test result for the selftest test (64 bit compiled) can be found
here.
test: tm_ptrace
tags: git_version:v3.19-rc4-54-g10a9c5d
===Testing TM based PTRACE Interface===
Testing TM specific SPR:
TFHAR: 10001098
TEXASR: de0000018c000001
TFIAR: c000000000041a78
TM ORIG_MSR: 800000050000f032
TM CH DSCR: a (PASSED)
TM CH TAR: 14 (PASSED)
TM CH PPR: 8000000000000 (PASSED)
Testing TM checkpointed GPR:
TM CH NIP: 10001098
TM CH LINK: 10000ea0
TM CH CCR: 24000422
TM CH GPR[0]: 0 (PASSED)
TM CH GPR[1]: 1 (PASSED)
TM CH GPR[2]: 2 (PASSED)
TM CH GPR[3]: 3 (PASSED)
TM CH GPR[4]: 4 (PASSED)
TM CH GPR[5]: 5 (PASSED)
TM CH GPR[6]: 6 (PASSED)
TM CH GPR[7]: 7 (PASSED)
TM CH GPR[8]: 8 (PASSED)
TM CH GPR[9]: 9 (PASSED)
TM CH GPR[10]: a (PASSED)
TM CH GPR[11]: b (PASSED)
TM CH GPR[12]: c (PASSED)
TM CH GPR[13]: d (PASSED)
TM CH GPR[14]: e (PASSED)
TM CH GPR[15]: f (PASSED)
TM CH GPR[16]: 0 (PASSED)
TM CH GPR[17]: 1 (PASSED)
TM CH GPR[18]: 2 (PASSED)
TM CH GPR[19]: 3 (PASSED)
TM CH GPR[20]: 4 (PASSED)
TM CH GPR[21]: 5 (PASSED)
TM CH GPR[22]: 6 (PASSED)
TM CH GPR[23]: 7 (PASSED)
TM CH GPR[24]: 8 (PASSED)
TM CH GPR[25]: 9 (PASSED)
TM CH GPR[26]: a (PASSED)
TM CH GPR[27]: b (PASSED)
TM CH GPR[28]: c (PASSED)
TM CH GPR[29]: d (PASSED)
TM CH GPR[30]: e (PASSED)
TM CH GPR[31]: f (PASSED)
Testing TM checkpointed FPR:
TM CH FPSCR: 0
TM CH FPR[0]: 0 (PASSED)
TM CH FPR[1]: 1 (PASSED)
TM CH FPR[2]: 2 (PASSED)
TM CH FPR[3]: 3 (PASSED)
TM CH FPR[4]: 4 (PASSED)
TM CH FPR[5]: 5 (PASSED)
TM CH FPR[6]: 6 (PASSED)
TM CH FPR[7]: 7 (PASSED)
TM CH FPR[8]: 8 (PASSED)
TM CH FPR[9]: 9 (PASSED)
TM CH FPR[10]: a (PASSED)
TM CH FPR[11]: b (PASSED)
TM CH FPR[12]: c (PASSED)
TM CH FPR[13]: d (PASSED)
TM CH FPR[14]: e (PASSED)
TM CH FPR[15]: f (PASSED)
TM CH FPR[16]: 0 (PASSED)
TM CH FPR[17]: 1 (PASSED)
TM CH FPR[18]: 2 (PASSED)
TM CH FPR[19]: 3 (PASSED)
TM CH FPR[20]: 4 (PASSED)
TM CH FPR[21]: 5 (PASSED)
TM CH FPR[22]: 6 (PASSED)
TM CH FPR[23]: 7 (PASSED)
TM CH FPR[24]: 8 (PASSED)
TM CH FPR[25]: 9 (PASSED)
TM CH FPR[26]: a (PASSED)
TM CH FPR[27]: b (PASSED)
TM CH FPR[28]: c (PASSED)
TM CH FPR[29]: d (PASSED)
TM CH FPR[30]: e (PASSED)
TM CH FPR[31]: f (PASSED)
Testing TM running GPR:
TM RN NIP: 100011b0
TM RN LINK: 10000ea0
TM RN CCR: 4000422
TM RN GPR[0]: f (PASSED)
TM RN GPR[1]: e (PASSED)
TM RN GPR[2]: d (PASSED)
TM RN GPR[3]: c (PASSED)
TM RN GPR[4]: b (PASSED)
TM RN GPR[5]: a (PASSED)
TM RN GPR[6]: 9 (PASSED)
TM RN GPR[7]: 8 (PASSED)
TM RN GPR[8]: 7 (PASSED)
TM RN GPR[9]: 6 (PASSED)
TM RN GPR[10]: 5 (PASSED)
TM RN GPR[11]: 4 (PASSED)
TM RN GPR[12]: 3 (PASSED)
TM RN GPR[13]: 2 (PASSED)
TM RN GPR[14]: 1 (PASSED)
TM RN GPR[15]: 0 (PASSED)
TM RN GPR[16]: f (PASSED)
TM RN GPR[17]: e (PASSED)
TM RN GPR[18]: d (PASSED)
TM RN GPR[19]: c (PASSED)
TM RN GPR[20]: b (PASSED)
TM RN GPR[21]: a (PASSED)
TM RN GPR[22]: 9 (PASSED)
TM RN GPR[23]: 8 (PASSED)
TM RN GPR[24]: 7 (PASSED)
TM RN GPR[25]: 6 (PASSED)
TM RN GPR[26]: 5 (PASSED)
TM RN GPR[27]: 4 (PASSED)
TM RN GPR[28]: 3 (PASSED)
TM RN GPR[29]: 2 (PASSED)
TM RN GPR[30]: 1 (PASSED)
TM RN GPR[31]: 0 (PASSED)
Testing TM running FPR:
TM RN FPSCR: 0
TM RN FPR[0]: f (PASSED)
TM RN FPR[1]: e (PASSED)
TM RN FPR[2]: d (PASSED)
TM RN FPR[3]: c (PASSED)
TM RN FPR[4]: b (PASSED)
TM RN FPR[5]: a (PASSED)
TM RN FPR[6]: 9 (PASSED)
TM RN FPR[7]: 8 (PASSED)
TM RN FPR[8]: 7 (PASSED)
TM RN FPR[9]: 6 (PASSED)
TM RN FPR[10]: 5 (PASSED)
TM RN FPR[11]: 4 (PASSED)
TM RN FPR[12]: 3 (PASSED)
TM RN FPR[13]: 2 (PASSED)
TM RN FPR[14]: 1 (PASSED)
TM RN FPR[15]: 0 (PASSED)
TM RN FPR[16]: f (PASSED)
TM RN FPR[17]: e (PASSED)
TM RN FPR[18]: d (PASSED)
TM RN FPR[19]: c (PASSED)
TM RN FPR[20]: b (PASSED)
TM RN FPR[21]: a (PASSED)
TM RN FPR[22]: 9 (PASSED)
TM RN FPR[23]: 8 (PASSED)
TM RN FPR[24]: 7 (PASSED)
TM RN FPR[25]: 6 (PASSED)
TM RN FPR[26]: 5 (PASSED)
TM RN FPR[27]: 4 (PASSED)
TM RN FPR[28]: 3 (PASSED)
TM RN FPR[29]: 2 (PASSED)
TM RN FPR[30]: 1 (PASSED)
TM RN FPR[31]: 0 (PASSED)
Testing TM running MISC debug registers:
TM RN DSCR: 32 (PASSED)
TM RN TAR: 3c (PASSED)
TM RN PPR: 4000000000000 (PASSED)
success: tm_ptrace
Anshuman Khandual (8):
elf: Add new powerpc specifc core note sections
powerpc, process: Add the function flush_tmregs_to_thread
powerpc, ptrace: Enable fpr_(get/set) for transactional memory
powerpc, ptrace: Enable vr_(get/set) for transactional memory
powerpc, ptrace: Enable support for transactional memory register sets
powerpc, ptrace: Enable support for miscellaneous debug registers
selftests, powerpc: Add test case for TM related ptrace interface
selftests: Make GIT ignore all binaries in powerpc test suite
arch/powerpc/include/asm/switch_to.h | 8 +
arch/powerpc/include/uapi/asm/elf.h | 3 +
arch/powerpc/kernel/process.c | 20 +
arch/powerpc/kernel/ptrace.c | 1044 +++++++++++++++++++-
include/uapi/linux/elf.h | 5 +
.../testing/selftests/powerpc/copyloops/.gitignore | 4 +
tools/testing/selftests/powerpc/mm/.gitignore | 1 +
tools/testing/selftests/powerpc/pmu/.gitignore | 3 +
tools/testing/selftests/powerpc/pmu/ebb/.gitignore | 22 +
.../selftests/powerpc/primitives/.gitignore | 1 +
tools/testing/selftests/powerpc/tm/.gitignore | 2 +
tools/testing/selftests/powerpc/tm/Makefile | 2 +-
tools/testing/selftests/powerpc/tm/tm-ptrace.c | 542 ++++++++++
13 files changed, 1632 insertions(+), 25 deletions(-)
create mode 100644 tools/testing/selftests/powerpc/copyloops/.gitignore
create mode 100644 tools/testing/selftests/powerpc/mm/.gitignore
create mode 100644 tools/testing/selftests/powerpc/pmu/.gitignore
create mode 100644 tools/testing/selftests/powerpc/pmu/ebb/.gitignore
create mode 100644 tools/testing/selftests/powerpc/primitives/.gitignore
create mode 100644 tools/testing/selftests/powerpc/tm/.gitignore
create mode 100644 tools/testing/selftests/powerpc/tm/tm-ptrace.c
--
1.9.3
^ permalink raw reply
* [PATCH V7 2/8] powerpc, process: Add the function flush_tmregs_to_thread
From: Anshuman Khandual @ 2015-01-14 7:08 UTC (permalink / raw)
To: linux-kernel, linuxppc-dev
Cc: shuahkh, mikey, james.hogan, avagin, Paul.Clothier, peterz,
palves, oleg, davem, dhowells, kirjanov, davej, akpm, sukadev,
tglx, sam.bobroff
In-Reply-To: <1421219330-19984-1-git-send-email-khandual@linux.vnet.ibm.com>
This patch creates a function flush_tmregs_to_thread which
will then be used by subsequent patches in this series. The
function checks for self tracing ptrace interface attempts
while in the TM context and logs appropriate warning message.
Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
---
arch/powerpc/include/asm/switch_to.h | 8 ++++++++
arch/powerpc/kernel/process.c | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 58abeda..23752a9 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -82,6 +82,14 @@ static inline void flush_spe_to_thread(struct task_struct *t)
}
#endif
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+extern void flush_tmregs_to_thread(struct task_struct *);
+#else
+static inline void flush_tmregs_to_thread(struct task_struct *t)
+{
+}
+#endif
+
static inline void clear_task_ebb(struct task_struct *t)
{
#ifdef CONFIG_PPC_BOOK3S_64
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b4cc7be..a6f7ca5 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -745,6 +745,26 @@ void restore_tm_state(struct pt_regs *regs)
#define __switch_to_tm(prev)
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+void flush_tmregs_to_thread(struct task_struct *tsk)
+{
+ /*
+ * Process self tracing is not yet supported through
+ * ptrace interface. Ptrace generic code should have
+ * prevented this from happening in the first place.
+ * Warn once here with the message, if some how it
+ * is attempted.
+ */
+ WARN_ONCE(tsk == current,
+ "Not expecting ptrace on self: TM regs may be incorrect\n");
+
+ /*
+ * If task is not current, it should have been flushed
+ * already to it's thread_struct during __switch_to().
+ */
+}
+#endif
+
struct task_struct *__switch_to(struct task_struct *prev,
struct task_struct *new)
{
--
1.9.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox