From: Sumit Garg <sumit.garg@linaro.org>
To: kgdb-bugreport@lists.sourceforge.net
Cc: jason.wessel@windriver.com, daniel.thompson@linaro.org,
dianders@chromium.org, pmladek@suse.com,
sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org,
Sumit Garg <sumit.garg@linaro.org>
Subject: [PATCH] kdb: Make kdb_printf robust to run in NMI context
Date: Fri, 22 May 2020 15:32:26 +0530 [thread overview]
Message-ID: <1590141746-23559-1-git-send-email-sumit.garg@linaro.org> (raw)
While rounding up CPUs via NMIs, its possible that a rounded up CPU
maybe holding a console port lock leading to kgdb master CPU stuck in
a deadlock during invocation of console write operations. So in order
to avoid such a deadlock, invoke bust_spinlocks() prior to invocation
of console handlers.
Also, add a check for console port to be enabled prior to invocation of
corresponding handler.
Suggested-by: Petr Mladek <pmladek@suse.com>
Suggested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
---
kernel/debug/kdb/kdb_io.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 924bc92..e32ece6 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -699,7 +699,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
}
}
for_each_console(c) {
+ if (!(c->flags & CON_ENABLED))
+ continue;
+ bust_spinlocks(1);
c->write(c, cp, retlen - (cp - kdb_buffer));
+ bust_spinlocks(0);
touch_nmi_watchdog();
}
}
@@ -761,7 +765,11 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
}
}
for_each_console(c) {
+ if (!(c->flags & CON_ENABLED))
+ continue;
+ bust_spinlocks(1);
c->write(c, moreprompt, strlen(moreprompt));
+ bust_spinlocks(0);
touch_nmi_watchdog();
}
--
2.7.4
next reply other threads:[~2020-05-22 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-22 10:02 Sumit Garg [this message]
2020-05-22 10:38 ` Daniel Thompson
2020-05-22 10:52 ` Sumit Garg
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=1590141746-23559-1-git-send-email-sumit.garg@linaro.org \
--to=sumit.garg@linaro.org \
--cc=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=sergey.senozhatsky@gmail.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
all inboxes | Powered by JetHome®