From: Peter Zijlstra <peterz@infradead.org>
To: Sumit Garg <sumit.garg@linaro.org>
Cc: linux-serial@vger.kernel.org, hasegawa-hitomi@fujitsu.com,
gregkh@linuxfoundation.org, jirislaby@kernel.org,
jason.wessel@windriver.com, daniel.thompson@linaro.org,
dianders@chromium.org, linux-kernel@vger.kernel.org,
kgdb-bugreport@lists.sourceforge.net, arnd@arndb.de
Subject: Re: [RFT v2] tty/sysrq: Make sysrq handler NMI aware
Date: Mon, 28 Feb 2022 13:07:30 +0100 [thread overview]
Message-ID: <Yhy7AnwEMqbcKsEg@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220228075351.1412452-1-sumit.garg@linaro.org>
On Mon, Feb 28, 2022 at 01:23:51PM +0530, Sumit Garg wrote:
> Allow a magic sysrq to be triggered from an NMI context. This is done
*why* though?
> +#define SYSRQ_NMI_FIFO_SIZE 2
> +static DEFINE_KFIFO(sysrq_nmi_fifo, int, SYSRQ_NMI_FIFO_SIZE);
> +
> +static void sysrq_do_nmi_work(struct irq_work *work)
That naming don't make sense, it does the !NMI work, from IRQ context.
> +{
> + const struct sysrq_key_op *op_p;
> + int orig_suppress_printk;
> + int key;
> +
> + orig_suppress_printk = suppress_printk;
> + suppress_printk = 0;
> +
> + rcu_sysrq_start();
> + rcu_read_lock();
> +
> + if (kfifo_peek(&sysrq_nmi_fifo, &key)) {
> + op_p = __sysrq_get_key_op(key);
> + if (op_p)
> + op_p->handler(key);
> + }
> +
> + rcu_read_unlock();
> + rcu_sysrq_end();
> +
> + suppress_printk = orig_suppress_printk;
> +
> + kfifo_reset_out(&sysrq_nmi_fifo);
> +}
> +
> +static DEFINE_IRQ_WORK(sysrq_nmi_work, sysrq_do_nmi_work);
> +
> void __handle_sysrq(int key, bool check_mask)
> {
> const struct sysrq_key_op *op_p;
> @@ -573,6 +612,10 @@ void __handle_sysrq(int key, bool check_mask)
> int orig_suppress_printk;
> int i;
>
> + /* Skip sysrq handling if one already in progress */
> + if (!kfifo_is_empty(&sysrq_nmi_fifo))
> + return;
> +
> orig_suppress_printk = suppress_printk;
> suppress_printk = 0;
>
> @@ -596,7 +639,13 @@ void __handle_sysrq(int key, bool check_mask)
> if (!check_mask || sysrq_on_mask(op_p->enable_mask)) {
> pr_info("%s\n", op_p->action_msg);
> console_loglevel = orig_log_level;
> - op_p->handler(key);
> +
> + if (in_nmi() && !op_p->nmi_safe) {
> + kfifo_put(&sysrq_nmi_fifo, key);
> + irq_work_queue(&sysrq_nmi_work);
> + } else {
> + op_p->handler(key);
> + }
> } else {
> pr_info("This sysrq operation is disabled.\n");
> console_loglevel = orig_log_level;
I'm missing the point of that kfifo stuff; afaict it only ever buffers
_1_ key, might as well use a simple variable, no?
next prev parent reply other threads:[~2022-02-28 12:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 7:53 Sumit Garg
2022-02-28 12:07 ` Peter Zijlstra [this message]
2022-02-28 13:28 ` 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=Yhy7AnwEMqbcKsEg@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=arnd@arndb.de \
--cc=daniel.thompson@linaro.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=hasegawa-hitomi@fujitsu.com \
--cc=jason.wessel@windriver.com \
--cc=jirislaby@kernel.org \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sumit.garg@linaro.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
all inboxes | Powered by JetHome®