From: Petr Mladek <pmladek@suse.com>
To: John Ogness <john.ogness@linutronix.de>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH printk 15/18] printk: Add struct cons_text_buf
Date: Fri, 7 Oct 2022 17:15:32 +0200 [thread overview]
Message-ID: <Y0BClAlwfWfWcsDD@alley> (raw)
In-Reply-To: <20220924000454.3319186-16-john.ogness@linutronix.de>
On Sat 2022-09-24 02:10:51, John Ogness wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> Create a data structure to replace the open coded separate buffers for
> regular and extended formatting.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
> include/linux/console.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 8ec24fe097d3..05c7325e98f9 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -173,6 +173,20 @@ enum cons_flags {
> CON_EXTENDED = BIT(6),
> };
>
> +/**
> + * struct cons_text_buf - console output text buffer
> + * @ext_text: Buffer for extended log format text
> + * @dropped_text: Buffer for dropped text
> + * @text: Buffer for ringbuffer text
> + */
> +struct cons_text_buf {
Sigh, I feel bad to nit-pick about this. It seems that you have used
"cons" everywhere in the new API so any change might be painful.
But I personally find really handful when an API is predictable
and consistent.
I see that "cons" has already been used few times in tty subsystem,
especially tty/vt and tty/hvc.
But I do not see any single "cons_" under kernel/printk/ before
this patchset. Either "console_" or "con_" prefix was
used everywhere, including CON_XXX flags.
Is there any change to change this to either "console_"
or "con_", please? Or is there any particular reason why
this new API should be distinguished by the new prefix?
> + union {
> + char ext_text[CONSOLE_EXT_LOG_MAX];
> + char dropped_text[DROPPED_TEXT_MAX];
> + };
> + char text[CONSOLE_LOG_MAX];
We should explain in the commit message why we need
the separate ext_text buffer and why it can be shared
with dropped_text buffer. Something like:
<proposal>
Create a data structure to replace the open coded separate buffers for
regular and extended formatting.
Separate @ext_text buffer is needed because info_print_ext_header()
and msg_print_ext_body() are not able to add the needed extra
information inplace.
@ext_text and @dropped_text buffer can be shared because
they are never used at the same time.
</proposal>
Also I think about using pointers instead of the hard-coded
buffer size. For example, there is no need to have
the big ext_text buffer in the kthread when the related
console does not allow to allocated the extended text.
There is actually only one console that has this enabled.
I mean something like:
struct cons_text_buf {
char *text;
char *ext_text;
char *dropped_text;
unsigned int text_size;
unsigned int ext_text_size;
unsigned int dropped_text_size;
}
We might create a helper to define static buffer:
#define DEFINE_CONS_TEXT_BUF(name) \
static char _##name##_text[CONSOLE_LOG_MAX]; \
static char _##name##_ext_text[CONSOLE_EXT_LOG_MAX]; \
static struct const_text_buf name = { \
.text = _##name##_text, \
.ext_text = _##name##_ext_text, \
.dropped_text = _##name##_ext_text, \
\
.text_size = CONSOLE_LOG_MAX; \
.ext_text_size = CONSOLE_LOG_MAX; \
.dropped_text_size = DROPPED_TEXT_MAX; \
};
Another advantage would be that it looks like a more safe way to
pass the buffer size. The existing code hardcodes CONSOLE_LOG_MAX
and CONSOLE_EXT_LOG_MAX everywhere. And it is less obvious that
the buffer and size fits together. Especially that the names
do not match (text vs. LOG_MAX and ext_text vs. EXT_LOG_MAX).
Well, this might be out of scope of this patchset. I do not resist
on it. We might do this later.
Best Regards,
Petr
next prev parent reply other threads:[~2022-10-07 15:15 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-24 0:04 [PATCH printk 00/18] preparation for threaded/atomic printing John Ogness
2022-09-24 0:04 ` [PATCH printk 01/18] printk: Make pr_flush() static John Ogness
2022-09-26 14:12 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 02/18] printk: Declare log_wait properly John Ogness
2022-09-26 14:22 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 03/18] printk: Remove write only variable nr_ext_console_drivers John Ogness
2022-09-26 14:25 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 04/18] printk: Remove bogus comment vs. boot consoles John Ogness
2022-09-26 14:26 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 05/18] printk: Mark __printk percpu data ready __ro_after_init John Ogness
2022-09-26 14:27 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 06/18] printk: Protect [un]register_console() with a mutex John Ogness
2022-09-24 9:31 ` Sergey Senozhatsky
2022-09-27 15:16 ` Petr Mladek
2022-09-28 9:46 ` Sergey Senozhatsky
2022-09-28 23:42 ` John Ogness
2022-09-29 15:43 ` Petr Mladek
2022-09-30 9:24 ` Petr Mladek
2022-09-30 14:16 ` John Ogness
2022-09-30 18:04 ` Petr Mladek
2022-09-30 20:26 ` John Ogness
2022-10-03 14:37 ` Petr Mladek
2022-10-03 19:35 ` John Ogness
2022-10-04 2:06 ` Sergey Senozhatsky
2022-10-04 7:28 ` Petr Mladek
2022-09-30 13:30 ` John Ogness
2022-09-24 0:04 ` [PATCH printk 07/18] printk: Convert console list walks for readers to list lock John Ogness
2022-09-27 14:07 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 08/18] parisc: Put console abuse into one place John Ogness
2022-09-24 0:20 ` Steven Rostedt
2022-09-30 7:54 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 09/18] serial: kgdboc: Lock console list in probe function John Ogness
2022-09-28 23:32 ` Doug Anderson
2022-09-30 8:07 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 10/18] kgbd: Pretend that console list walk is safe John Ogness
2022-09-26 9:33 ` Aaron Tomlin
2022-09-28 23:32 ` Doug Anderson
2022-09-30 8:39 ` Petr Mladek
2022-09-30 13:44 ` John Ogness
2022-09-30 17:27 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 11/18] printk: Convert console_drivers list to hlist John Ogness
2022-09-24 10:53 ` Sergey Senozhatsky
2022-09-24 17:20 ` Helge Deller
2022-09-25 0:43 ` Sergey Senozhatsky
2022-09-24 17:27 ` Helge Deller
2022-09-30 14:20 ` Petr Mladek
2022-09-30 16:53 ` Helge Deller
2022-09-30 19:46 ` John Ogness
2022-09-30 22:41 ` Helge Deller
2022-09-24 0:04 ` [PATCH printk 12/18] printk: Prepare for SCRU console list protection John Ogness
2022-09-24 10:58 ` Sergey Senozhatsky
2022-09-24 0:04 ` [PATCH printk 13/18] printk: Move buffer size defines John Ogness
2022-09-24 11:01 ` Sergey Senozhatsky
2022-10-07 9:11 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 14/18] printk: Document struct console John Ogness
2022-09-24 11:08 ` Sergey Senozhatsky
2022-10-07 11:57 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 15/18] printk: Add struct cons_text_buf John Ogness
2022-09-24 11:09 ` Sergey Senozhatsky
2022-10-07 15:15 ` Petr Mladek [this message]
2022-09-24 0:04 ` [PATCH printk 16/18] printk: Use " John Ogness
2022-09-24 11:34 ` Sergey Senozhatsky
2022-10-10 10:11 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 17/18] printk: Use an output descriptor struct for emit John Ogness
2022-10-10 15:40 ` Petr Mladek
2022-09-24 0:04 ` [PATCH printk 18/18] printk: Handle dropped message smarter John Ogness
2022-09-26 4:19 ` Sergey Senozhatsky
2022-09-26 7:54 ` John Ogness
2022-09-26 9:18 ` Sergey Senozhatsky
2022-10-10 16:07 ` Petr Mladek
2022-09-26 9:22 ` Sergey Senozhatsky
2022-09-24 6:44 ` [PATCH printk 00/18] preparation for threaded/atomic printing Greg Kroah-Hartman
2022-09-25 15:23 ` John Ogness
2022-09-24 9:47 ` Sergey Senozhatsky
2022-09-29 16:33 ` Petr Mladek
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=Y0BClAlwfWfWcsDD@alley \
--to=pmladek@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.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