From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: bst@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] poller: add option to detect delayed poller activation
Date: Tue, 1 Jul 2025 10:52:50 +0200 [thread overview]
Message-ID: <20250701085251.148111-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250701085251.148111-1-a.fatoum@pengutronix.de>
We already have checks that see if pollers run too long, but none to see
if poller run too late, because scheduling was disabled for a too long
period of time. Add an option that does this to aid with debugging.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/poller.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/common/poller.c b/common/poller.c
index 83f7205e5d57..18bd9c80f4b3 100644
--- a/common/poller.c
+++ b/common/poller.c
@@ -10,6 +10,7 @@
#include <malloc.h>
#include <module.h>
#include <param.h>
+#include <linux/ktime.h>
#include <poller.h>
#include <clock.h>
#include <linux/ktime.h>
@@ -188,19 +189,46 @@ static void poller_info(void)
}
}
+static struct poller_async blocking_poller;
+
+static void blocking_poller_cb(void *priv)
+{
+ ktime_t diff = ktime_get() - blocking_poller.end;
+
+ if (diff < 0) {
+ pr_err("Poller watchdog activated %lluns too early!\n", diff);
+ } else if (diff > SECOND) {
+ pr_warn("Poller watchdog activated %llums too late!\n",
+ ktime_to_ms(diff));
+ }
+
+ poller_call_async(&blocking_poller, SECOND, blocking_poller_cb, NULL);
+}
+
+static void poller_blocking_time(void)
+{
+ if (blocking_poller.active)
+ return;
+
+ poller_async_register(&blocking_poller, "poller-monitor");
+ printf("Poller registered to monitor blocking time\n");
+ poller_call_async(&blocking_poller, SECOND, blocking_poller_cb, NULL);
+}
+
BAREBOX_CMD_HELP_START(poller)
BAREBOX_CMD_HELP_TEXT("print info about registered pollers")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-i", "Print information about registered pollers")
BAREBOX_CMD_HELP_OPT ("-t", "measure how many pollers we run in 1s")
+BAREBOX_CMD_HELP_OPT ("-b", "warn if poller was blocked from running for more than 1 second")
BAREBOX_CMD_HELP_END
static int do_poller(int argc, char *argv[])
{
int opt;
- while ((opt = getopt(argc, argv, "it")) > 0) {
+ while ((opt = getopt(argc, argv, "itb")) > 0) {
switch (opt) {
case 'i':
poller_info();
@@ -208,6 +236,9 @@ static int do_poller(int argc, char *argv[])
case 't':
poller_time();
return 0;
+ case 'b':
+ poller_blocking_time();
+ return 0;
}
}
--
2.39.5
next prev parent reply other threads:[~2025-07-01 10:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 8:52 [PATCH 1/3] commands: sleep: add support for running without pollers Ahmad Fatoum
2025-07-01 8:52 ` Ahmad Fatoum [this message]
2025-07-01 8:52 ` [PATCH 3/3] menu: schedule pollers/workqueues while waiting for menu item selection Ahmad Fatoum
2025-07-01 9:24 ` Bastian Krause
2025-07-02 7:00 ` [PATCH 1/3] commands: sleep: add support for running without pollers Sascha Hauer
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=20250701085251.148111-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=bst@pengutronix.de \
/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