linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: alison.schofield@intel.com
To: Dan Williams <dan.j.williams@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ben Widawsky <bwidawsk@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>, linux-cxl@vger.kernel.org
Subject: [PATCH v5 04/12] cxl/memdev: Trace inject and clear poison as cxl_poison events
Date: Sun, 26 Mar 2023 22:03:10 -0700	[thread overview]
Message-ID: <9074fc4d2ac3fb1aa1c4db7ea55fba85c4f3864a.1679892337.git.alison.schofield@intel.com> (raw)
In-Reply-To: <cover.1679892337.git.alison.schofield@intel.com>

From: Alison Schofield <alison.schofield@intel.com>

The cxl_poison trace event allows users to view the history of poison
list reads. With the addition of inject and clear poison capabilities,
users will expect similar tracing.

Add trace types 'Inject' and 'Clear' to the cxl_poison trace_event and
trace successful operations only.

If the driver finds that the DPA being injected or cleared of poison
is mapped in a region, that region info is included in the cxl_poison
trace event. Region reconfigurations can make this extra info useless
if the debug operations are not carefully managed.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 drivers/cxl/core/core.h   |  2 ++
 drivers/cxl/core/memdev.c | 16 ++++++++++++++++
 drivers/cxl/core/trace.h  |  8 +++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
index 57bd22e01a0b..5b673eca8f12 100644
--- a/drivers/cxl/core/core.h
+++ b/drivers/cxl/core/core.h
@@ -71,6 +71,8 @@ void cxl_mbox_init(void);
 
 enum cxl_poison_trace_type {
 	CXL_POISON_TRACE_LIST,
+	CXL_POISON_TRACE_INJECT,
+	CXL_POISON_TRACE_CLEAR,
 };
 
 struct cxl_trigger_poison_context {
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index a83619c31f61..71ebe3795616 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -6,6 +6,7 @@
 #include <linux/idr.h>
 #include <linux/pci.h>
 #include <cxlmem.h>
+#include "trace.h"
 #include "core.h"
 
 static DECLARE_RWSEM(cxl_memdev_rwsem);
@@ -285,6 +286,7 @@ int cxl_inject_poison(struct device *dev, u64 dpa)
 {
 	struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
 	struct cxl_mbox_inject_poison inject;
+	struct cxl_poison_record record;
 	struct cxl_mbox_cmd mbox_cmd;
 	struct cxl_region *cxlr;
 	int rc;
@@ -313,6 +315,13 @@ int cxl_inject_poison(struct device *dev, u64 dpa)
 	if (cxlr)
 		dev_warn_once(dev, "poison inject dpa:0x%llx region: %s\n",
 			      dpa, dev_name(&cxlr->dev));
+
+	record = (struct cxl_poison_record) {
+		.address = cpu_to_le64(dpa),
+		.length = cpu_to_le32(1),
+	};
+	trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_INJECT);
+
 out:
 	up_read(&cxl_dpa_rwsem);
 
@@ -324,6 +333,7 @@ int cxl_clear_poison(struct device *dev, u64 dpa)
 {
 	struct cxl_memdev *cxlmd = to_cxl_memdev(dev);
 	struct cxl_mbox_clear_poison clear;
+	struct cxl_poison_record record;
 	struct cxl_mbox_cmd mbox_cmd;
 	struct cxl_region *cxlr;
 	int rc;
@@ -363,6 +373,12 @@ int cxl_clear_poison(struct device *dev, u64 dpa)
 	if (cxlr)
 		dev_warn_once(dev, "poison clear dpa:0x%llx region: %s\n",
 			      dpa, dev_name(&cxlr->dev));
+
+	record = (struct cxl_poison_record) {
+		.address = cpu_to_le64(dpa),
+		.length = cpu_to_le32(1),
+	};
+	trace_cxl_poison(cxlmd, cxlr, &record, 0, 0, CXL_POISON_TRACE_CLEAR);
 out:
 	up_read(&cxl_dpa_rwsem);
 
diff --git a/drivers/cxl/core/trace.h b/drivers/cxl/core/trace.h
index 65d81d27cb85..5e5e29995d3e 100644
--- a/drivers/cxl/core/trace.h
+++ b/drivers/cxl/core/trace.h
@@ -602,9 +602,11 @@ TRACE_EVENT(cxl_memory_module,
 	)
 );
 
-#define show_poison_trace_type(type)		   \
-	__print_symbolic(type,			   \
-	{ CXL_POISON_TRACE_LIST,	"List"	})
+#define show_poison_trace_type(type)			\
+	__print_symbolic(type,				\
+	{ CXL_POISON_TRACE_LIST,	"List"   },	\
+	{ CXL_POISON_TRACE_INJECT,	"Inject" },	\
+	{ CXL_POISON_TRACE_CLEAR,	"Clear"  })
 
 #define __show_poison_source(source)                          \
 	__print_symbolic(source,                              \
-- 
2.37.3


  parent reply	other threads:[~2023-03-27  5:03 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27  5:03 [PATCH v5 0/12] cxl: CXL Inject & Clear Poison alison.schofield
2023-03-27  5:03 ` [PATCH v5 01/12] cxl/memdev: Add support for the Inject Poison mailbox command alison.schofield
2023-03-30 18:47   ` Jonathan Cameron
2023-03-31 18:11   ` Dave Jiang
2023-03-31 18:52     ` Alison Schofield
2023-03-27  5:03 ` [PATCH v5 02/12] cxl/memdev: Add support for the Clear " alison.schofield
2023-03-30 18:50   ` Jonathan Cameron
2023-03-30 20:12     ` Alison Schofield
2023-04-03 14:08       ` Jonathan Cameron
2023-03-31 18:40   ` Dave Jiang
2023-03-31 19:55     ` Alison Schofield
2023-03-31 21:18       ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 03/12] cxl/memdev: Warn of poison inject or clear to a mapped region alison.schofield
2023-03-30 18:55   ` Jonathan Cameron
2023-04-11 17:43     ` Alison Schofield
2023-04-13 17:07       ` Jonathan Cameron
2023-03-27  5:03 ` alison.schofield [this message]
2023-03-30 19:03   ` [PATCH v5 04/12] cxl/memdev: Trace inject and clear poison as cxl_poison events Jonathan Cameron
2023-03-31 18:53   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 05/12] cxl/mem: Add debugfs attributes for poison inject and clear alison.schofield
2023-03-30 18:58   ` Jonathan Cameron
2023-03-27  5:03 ` [PATCH v5 06/12] cxl/memdev: Make inject and clear poison cmds kernel exclusive alison.schofield
2023-03-31 19:10   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 07/12] cxl/mbox: Block inject and clear poison opcodes in raw mode alison.schofield
2023-03-31 19:10   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 08/12] tools/testing/cxl: Mock the Inject Poison mailbox command alison.schofield
2023-03-31 19:13   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 09/12] tools/testing/cxl: Mock the Clear " alison.schofield
2023-03-31 19:15   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 10/12] tools/testing/cxl: Use injected poison for get poison list alison.schofield
2023-03-31 19:16   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 11/12] tools/testing/cxl: Add a sysfs attr to test poison inject limits alison.schofield
2023-03-31 19:18   ` Dave Jiang
2023-03-27  5:03 ` [PATCH v5 12/12] tools/testing/cxl: Require CONFIG_DEBUG_FS alison.schofield
2023-03-31 19:20   ` Dave Jiang

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=9074fc4d2ac3fb1aa1c4db7ea55fba85c4f3864a.1679892337.git.alison.schofield@intel.com \
    --to=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).