From: Anisa Su <anisa.su887@gmail.com>
To: linux-cxl@vger.kernel.org
Cc: benjamin.cheatham@amd.com, icheng@nvidia.com, dave@stgolabs.net,
dave.jiang@intel.com, alison.schofield@intel.com,
jic23@kernel.org, Anisa Su <anisa.su@samsung.com>
Subject: [PATCH v2 3/4] cxl/events: Bound the per-log Get Event Records loop
Date: Mon, 31 Aug 2026 17:26:56 -0700 [thread overview]
Message-ID: <20260901002912.958-4-anisa.su@samsung.com> (raw)
In-Reply-To: <20260901002912.958-1-anisa.su@samsung.com>
cxl_mem_get_records_log() re-queries a log until the device reports it
empty. A misbehaving device that never stops reporting records keeps the
event thread stuck in this loop, and there is no cond_resched() to let anything
else on the CPU run.
Cap the passes at 128 and reschedule between them. Each pass gets up to
a full mailbox payload of records from the log, so the cap is a generous
upper bound. Report hitting the cap as an error and let the caller give
up on the log.
Fixes: 6ebe28f9ec72 ("cxl/mem: Read, trace, and clear events on driver load")
Signed-off-by: Anisa Su <anisa.su@samsung.com>
---
drivers/cxl/core/mbox.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 02b8c33a74b6..5e49589727d5 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1071,6 +1071,8 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
return cxl_event_retry_rc(&mbox_cmd, rc);
}
+#define CXL_EVENT_LOG_MAX_PASSES 128
+
static int cxl_mem_get_records_log(struct cxl_memdev_state *mds,
enum cxl_event_log_type type, bool *got_records)
{
@@ -1079,6 +1081,7 @@ static int cxl_mem_get_records_log(struct cxl_memdev_state *mds,
struct device *dev = mds->cxlds.dev;
struct cxl_get_event_payload *payload;
u8 log_type = type;
+ int passes = 0;
u16 nr_rec;
int rc = 0;
@@ -1134,6 +1137,15 @@ static int cxl_mem_get_records_log(struct cxl_memdev_state *mds,
type, rc);
break;
}
+
+ if (++passes == CXL_EVENT_LOG_MAX_PASSES) {
+ dev_warn_ratelimited(dev,
+ "Event log '%d': Still reporting records after %d passes, giving up",
+ type, passes);
+ rc = -EIO;
+ break;
+ }
+ cond_resched();
} while (nr_rec);
mutex_unlock(&mds->event.log_lock);
--
2.43.0
next prev parent reply other threads:[~2026-09-01 0:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 0:26 [PATCH v2 0/4] cxl/events: Robustify event interrupt handling Anisa Su
2026-09-01 0:26 ` [PATCH v2 1/4] cxl/events: Bound get records loop in cxl_event_thread() Anisa Su
2026-09-01 0:41 ` sashiko-bot
2026-09-01 11:48 ` Li Ming
2026-09-01 17:59 ` Anisa Su
2026-09-01 19:17 ` Cheatham, Benjamin
2026-09-01 0:26 ` [PATCH v2 2/4] cxl/events: Validate the record count reported by the device Anisa Su
2026-09-01 19:19 ` Cheatham, Benjamin
2026-09-01 0:26 ` Anisa Su [this message]
2026-09-01 0:43 ` [PATCH v2 3/4] cxl/events: Bound the per-log Get Event Records loop sashiko-bot
2026-09-01 19:19 ` Cheatham, Benjamin
2026-09-01 0:26 ` [PATCH v2 4/4] cxl/events: Return IRQ_NONE when no events were processed Anisa Su
2026-09-01 0:38 ` sashiko-bot
2026-09-01 19:19 ` Cheatham, Benjamin
2026-09-08 22:26 ` Jonathan Cameron
2026-09-02 8:27 ` [PATCH v2 0/4] cxl/events: Robustify event interrupt handling Anisa Su
2026-09-02 19:06 ` Davidlohr Bueso
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=20260901002912.958-4-anisa.su@samsung.com \
--to=anisa.su887@gmail.com \
--cc=alison.schofield@intel.com \
--cc=anisa.su@samsung.com \
--cc=benjamin.cheatham@amd.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=icheng@nvidia.com \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.