mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Doug Anderson <dianders@chromium.org>
Cc: linux-kernel@vger.kernel.org, "Andrew Chant" <achant@google.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Brian Gerst" <brgerst@gmail.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Francesco Valla" <francesco@valla.it>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Guo Weikang" <guoweikang.kernel@gmail.com>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"Jan Hendrik Farr" <kernel@jfarr.cc>,
	"Jeff Xu" <jeffxu@chromium.org>, "Kees Cook" <kees@kernel.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Shakeel Butt" <shakeel.butt@linux.dev>,
	"Tejun Heo" <tj@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Uladzislau Rezki (Sony)" <urezki@gmail.com>
Subject: Re: [PATCH] init/main.c: Wrap long kernel cmdline when printing to logs
Date: Tue, 21 Oct 2025 16:06:57 -0700	[thread overview]
Message-ID: <20251021160657.29b745a94ff8cfd2fe92c7af@linux-foundation.org> (raw)
In-Reply-To: <CAD=FV=XXpMnjXzPgDseoLGOYUHVQy9Z2cjmCC+OE+uDC43eNRw@mail.gmail.com>

On Tue, 21 Oct 2025 15:57:18 -0700 Doug Anderson <dianders@chromium.org> wrote:

> In other words `dmesg` seemed to be trying to read 2047 bytes from
> `/dev/kmsg` and this wasn't enough to hold the output line. You can
> see in the kernel function devkmsg_read() that when this happens the
> kernel returns -EINVAL.
> 
> We could _try_ to improve devkmsg_read() to be able to return partial
> log lines, but that violates the docs. The file
> `Documentation/ABI/testing/dev-kmsg` says:
> 
>   Every read() from the opened device node receives one record
>   of the kernel's printk buffer.
>   ...
>   Messages in the record ring buffer get overwritten as whole,
>   there are never partial messages received by read().

Well that was dumb of us.  POSIX be damned.

> So tl;dr: as far as I can tell, we simply cannot put the whole cmdline
> (which is 2048+ on many architectures) on one line without breaking
> userspace. My userspace reads 2047 bytes and we'd need to return not
> just the cmdline but the prefix "Kernel command line:" as well as the
> data about time/log_level/etc.
> 
> 
> Does any of the above change your mind about my wrapping scheme? ;-)

Yeah.

> Obviously, I'd want to update my commit message with some of the
> research...

Sure.

      reply	other threads:[~2025-10-21 23:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-19 17:06 Douglas Anderson
2025-10-19 22:22 ` Randy Dunlap
2025-10-20 15:33   ` Doug Anderson
2025-10-20 15:40     ` Geert Uytterhoeven
2025-10-20 15:57       ` Doug Anderson
2025-10-21  7:05         ` Geert Uytterhoeven
2025-10-21 13:16           ` Heiko Carstens
2025-10-21 16:07             ` Doug Anderson
2025-10-20 17:18     ` Randy Dunlap
2025-10-20 18:51 ` Andrew Morton
2025-10-20 20:00   ` Doug Anderson
2025-10-21 20:55     ` Andrew Morton
2025-10-21 22:57       ` Doug Anderson
2025-10-21 23:06         ` Andrew Morton [this message]

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=20251021160657.29b745a94ff8cfd2fe92c7af@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=achant@google.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=brauner@kernel.org \
    --cc=brgerst@gmail.com \
    --cc=chenhuacai@kernel.org \
    --cc=dianders@chromium.org \
    --cc=francesco@valla.it \
    --cc=geert+renesas@glider.be \
    --cc=guoweikang.kernel@gmail.com \
    --cc=jeffxu@chromium.org \
    --cc=kees@kernel.org \
    --cc=kernel@jfarr.cc \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=nathan@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=tglx@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=tj@kernel.org \
    --cc=urezki@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®