linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Chartre <alexandre.chartre@oracle.com>
To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org,
	peterz@infradead.org, x86@kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: pbonzini@redhat.com, konrad.wilk@oracle.com,
	jan.setjeeilers@oracle.com, liran.alon@oracle.com,
	junaids@google.com, graf@amazon.de, rppt@linux.vnet.ibm.com,
	kuzuno@gmail.com, mgross@linux.intel.com,
	alexandre.chartre@oracle.com
Subject: [RFC v4][PATCH part-3 13/14] asidrv/asicmd: Add options to manage ASI page faults
Date: Mon,  4 May 2020 17:02:34 +0200	[thread overview]
Message-ID: <20200504150235.12171-14-alexandre.chartre@oracle.com> (raw)
In-Reply-To: <20200504150235.12171-1-alexandre.chartre@oracle.com>

Add options to the asicmd CLI to list and clear ASI page faults. Also
add an option to enable/disable displaying stack trace on ASI page
fault.

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
 drivers/staging/asi/asicmd.c | 68 ++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/asi/asicmd.c b/drivers/staging/asi/asicmd.c
index 849fa09423e6..4d7bb9df0fcc 100644
--- a/drivers/staging/asi/asicmd.c
+++ b/drivers/staging/asi/asicmd.c
@@ -52,6 +52,10 @@ static void usage(void)
 	printf("\n");
 	printf("Commands:\n");
 	printf("  all      - run all tests\n");
+	printf("  fault    - list ASI faults\n");
+	printf("  fltclr   - clear ASI faults\n");
+	printf("  stkon    - show stack on ASI fault\n");
+	printf("  stkoff   - do not show stack on ASI fault\n");
 	printf("\n");
 	printf("Tests:\n");
 	for (i = 0; i < TEST_LIST_SIZE; i++)
@@ -91,10 +95,45 @@ static void asidrv_run_test(int fd, struct asidrv_test *test)
 		printf("TEST OK\n");
 }
 
+static int asidrv_fault_list(int fd)
+{
+	struct asidrv_fault_list *flist;
+	int i, rv;
+
+	flist = malloc(sizeof(*flist) +
+		       sizeof(struct asidrv_fault) * 10);
+	if (!flist) {
+		perror("malloc flist");
+		return -1;
+	}
+
+	flist->length = 10;
+	rv = ioctl(fd, ASIDRV_IOCTL_LIST_FAULT, flist);
+	if (rv < 0) {
+		perror("ioctl list fault");
+		return -1;
+	}
+
+	if (!flist->length) {
+		printf("ASI has no fault\n");
+		return 0;
+	}
+
+	printf("%-18s  %5s  %s\n", "ADDRESS", "COUNT", "SYMBOL");
+	for (i = 0; i < flist->length && i < 10; i++) {
+		printf("%#18llx  %5u  %s\n",
+		       flist->fault[i].addr,
+		       flist->fault[i].count,
+		       flist->fault[i].symbol);
+	}
+
+	return 0;
+}
+
 int main(int argc, char *argv[])
 {
 	bool run_all, run;
-	int i, j, fd;
+	int i, j, fd, err;
 	char *test;
 
 	if (argc <= 1) {
@@ -111,10 +150,33 @@ int main(int argc, char *argv[])
 	for (i = 1; i < argc; i++) {
 		test = argv[i];
 
-		if (!strcmp(test, "all"))
+		if (!strcmp(test, "fault")) {
+			asidrv_fault_list(fd);
+			continue;
+
+		} else if (!strcmp(test, "fltclr")) {
+			err = ioctl(fd, ASIDRV_IOCTL_CLEAR_FAULT);
+			if (err)
+				perror("ioctl clear fault");
+			continue;
+
+		} else if (!strcmp(test, "stkon")) {
+			err = ioctl(fd, ASIDRV_IOCTL_LOG_FAULT_STACK, true);
+			if (err)
+				perror("ioctl log fault stack");
+			continue;
+
+		} else if (!strcmp(test, "stkoff")) {
+			err = ioctl(fd, ASIDRV_IOCTL_LOG_FAULT_STACK, false);
+			if (err)
+				perror("ioctl log fault sstack");
+			continue;
+
+		} else if (!strcmp(test, "all")) {
 			run_all = true;
-		else
+		} else {
 			run_all = false;
+		}
 
 		run = false;
 		for (j = 0; j < TEST_LIST_SIZE; j++) {
-- 
2.18.2



  parent reply	other threads:[~2020-05-04 15:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 15:02 [RFC v4][PATCH part-3 00/14] ASI - Part III (ASI Test Driver and CLI) Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 01/14] mm/asi: Define the test ASI type Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 02/14] asidrv: Introduce the ASI driver Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 03/14] asidrv: Introduce the ASIDRV_IOCTL_RUN_SEQUENCE ioctl Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 04/14] asidrv: Sequence to test ASI access to mapped/unmapped memory Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 05/14] asidrv: Sequence to test interrupt on ASI Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 06/14] asidrv: Sequence to test NMI " Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 07/14] asidrv: Sequence to test interrupt+NMI " Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 08/14] asidrv: Sequence to test scheduling in/out with ASI Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 09/14] asidrv: Add ioctls to manage ASI page faults Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 10/14] asidrv: Add ioctls to manage ASI mapped VA ranges Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 11/14] asidrv/asicmd: Introduce the asicmd command Alexandre Chartre
2020-05-04 15:02 ` [RFC v4][PATCH part-3 12/14] asidrv/asicmd: Add more test sequences for testing ASI Alexandre Chartre
2020-05-04 15:02 ` Alexandre Chartre [this message]
2020-05-04 15:02 ` [RFC v4][PATCH part-3 14/14] asidrv/asicmd: Add options to manage ASI mapped VA ranges Alexandre Chartre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200504150235.12171-14-alexandre.chartre@oracle.com \
    --to=alexandre.chartre@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=graf@amazon.de \
    --cc=hpa@zytor.com \
    --cc=jan.setjeeilers@oracle.com \
    --cc=junaids@google.com \
    --cc=konrad.wilk@oracle.com \
    --cc=kuzuno@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liran.alon@oracle.com \
    --cc=luto@kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rppt@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox