linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 2/5] sysrq: use pr_cont_t for cont messages
Date: Thu, 20 Aug 2020 10:48:40 -0700	[thread overview]
Message-ID: <472f2e553805b52d9834d64e4056db965edee329.camel@perches.com> (raw)
In-Reply-To: <CAHk-=wj_b6Bh=d-Wwh0xYqoQBhHkYeExhszkpxdRA6GjTvkRiQ@mail.gmail.com>

On Wed, 2020-08-19 at 18:03 -0700, Linus Torvalds wrote:
> On Wed, Aug 19, 2020 at 4:26 PM John Ogness <john.ogness@linutronix.de> wrote:
> > Use the new pr_cont_t mechanism.
> 
> This looks actively much worse than the old code.

Isn't this just a generic mechanism to simplify
the accumulation of
logging message chunks?

It does seem straightforward enough to me.

And here it seems like the 'for (j =...)' loop is superfluous.

Maybe something like this would be reasonable:
---
 drivers/tty/sysrq.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index a8e39b2cdd55..a145e4fc1a2a 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -572,21 +572,14 @@ void __handle_sysrq(int key, bool check_mask)
 			console_loglevel = orig_log_level;
 		}
 	} else {
-		pr_info("HELP : ");
-		/* Only print the help msg once per handler */
+		pr_context c;
+		pr_info_start(&c, "HELP :");
 		for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) {
-			if (sysrq_key_table[i]) {
-				int j;
-
-				for (j = 0; sysrq_key_table[i] !=
-						sysrq_key_table[j]; j++)
-					;
-				if (j != i)
-					continue;
-				pr_cont("%s ", sysrq_key_table[i]->help_msg);
-			}
+			if (!sysrq_key_table[i])
+				continue;
+			pr_next(&c, " %s", sysrq_key_table[i]->help_msg);
 		}
-		pr_cont("\n");
+		pr_end(&c, "\n");
 		console_loglevel = orig_log_level;
 	}
 	rcu_read_unlock();



  reply	other threads:[~2020-08-20 17:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 23:26 [RFC PATCH 0/5] printk: new log_cont implementation John Ogness
2020-08-19 23:26 ` [RFC PATCH 1/5] printk: implement pr_cont_t John Ogness
2020-08-20  0:33   ` Joe Perches
2020-08-20  7:44     ` David Laight
2020-08-20  7:59       ` Joe Perches
2020-08-20  8:49         ` David Laight
2020-08-20  9:18           ` John Ogness
2020-08-20 16:03       ` Joe Perches
2020-08-20 10:16   ` Petr Mladek
2020-08-20 12:33     ` David Laight
2020-08-25 13:10       ` Petr Mladek
2020-08-25 13:38         ` David Laight
2020-08-25 15:32           ` Petr Mladek
2020-08-24  2:08     ` Sergey Senozhatsky
2020-08-24  5:37   ` Sergey Senozhatsky
2020-08-19 23:26 ` [RFC PATCH 2/5] sysrq: use pr_cont_t for cont messages John Ogness
2020-08-20  1:03   ` Linus Torvalds
2020-08-20 17:48     ` Joe Perches [this message]
2020-08-20 17:53       ` Linus Torvalds
2020-08-20 22:11       ` John Ogness
2020-08-20 22:36         ` Joe Perches
2020-08-19 23:26 ` [RFC PATCH 3/5] workqueue: " John Ogness
2020-08-19 23:26 ` [RFC PATCH 4/5] locking/selftest: " John Ogness
2020-08-19 23:26 ` [RFC PATCH 5/5] lockdep: " John Ogness

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=472f2e553805b52d9834d64e4056db965edee329.camel@perches.com \
    --to=joe@perches.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).