From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
oss@malat.biz, paulmck@kernel.org,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH 2/3] init: use static buffers for bootconfig extra command line
Date: Fri, 17 Apr 2026 10:44:36 +0900 [thread overview]
Message-ID: <20260417104436.ece29fd5e2cb7a59c8cf8ac1@kernel.org> (raw)
In-Reply-To: <20260415-bootconfig_earlier-v1-2-cf160175de5e@debian.org>
On Wed, 15 Apr 2026 03:51:11 -0700
Breno Leitao <leitao@debian.org> wrote:
> Replace memblock_alloc/memblock_free in xbc_make_cmdline() with
> static __initdata buffers. This removes the last memblock dependency
> from the bootconfig loading path, completing the prerequisite for
> running bootconfig parsing before memblock is available.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> init/main.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/init/main.c b/init/main.c
> index 96f93bb06c490..b9feca55e01f9 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -369,11 +369,18 @@ static int __init xbc_snprint_cmdline(char *buf, size_t size,
> }
> #undef rest
>
> +/*
> + * Static buffers for bootconfig-generated command line parameters.
> + * Two separate buffers are needed because both "kernel" and "init"
> + * parameters are stored simultaneously.
> + */
> +static char extra_cmdline_buf[COMMAND_LINE_SIZE] __initdata;
> +static char extra_initargs_buf[COMMAND_LINE_SIZE] __initdata;
This is not good to me, since bootconfig supports bigger config file
than COMMAND_LINE_SIZE. Even if we limits the size for embedded
bootconfig file, it should depends on CONFIG_BOOT_CONFIG_EMBED.
Please use XBC_DATA_MAX instead of COMMAND_LINE_SIZE, or calculate
expected data length when compiling kernel.
But if we can do it, should we continue using bootconfig? I mean
it is easy to make a tool (or add a feature in tools/bootconfig)
which converts bootconfig file to command line string and embeds
it in the kernel. Hmm.
Thanks,
> +
> /* Make an extra command line under given key word */
> -static char * __init xbc_make_cmdline(const char *key)
> +static char * __init xbc_make_cmdline(const char *key, char *new_cmdline)
> {
> struct xbc_node *root;
> - char *new_cmdline;
> int ret, len = 0;
>
> root = xbc_find_node(key);
> @@ -382,19 +389,12 @@ static char * __init xbc_make_cmdline(const char *key)
>
> /* Count required buffer size */
> len = xbc_snprint_cmdline(NULL, 0, root);
> - if (len <= 0)
> + if (len <= 0 || len >= COMMAND_LINE_SIZE)
> return NULL;
>
> - new_cmdline = memblock_alloc(len + 1, SMP_CACHE_BYTES);
> - if (!new_cmdline) {
> - pr_err("Failed to allocate memory for extra kernel cmdline.\n");
> - return NULL;
> - }
> -
> ret = xbc_snprint_cmdline(new_cmdline, len + 1, root);
> if (ret < 0 || ret > len) {
> pr_err("Failed to print extra kernel cmdline.\n");
> - memblock_free(new_cmdline, len + 1);
> return NULL;
> }
>
> @@ -467,9 +467,9 @@ static void __init setup_boot_config(void)
> xbc_get_info(&ret, NULL);
> pr_info("Load bootconfig: %ld bytes %d nodes\n", (long)size, ret);
> /* keys starting with "kernel." are passed via cmdline */
> - extra_command_line = xbc_make_cmdline("kernel");
> + extra_command_line = xbc_make_cmdline("kernel", extra_cmdline_buf);
> /* Also, "init." keys are init arguments */
> - extra_init_args = xbc_make_cmdline("init");
> + extra_init_args = xbc_make_cmdline("init", extra_initargs_buf);
> }
> return;
> }
>
> --
> 2.52.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2026-04-17 1:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 10:51 [PATCH 0/3] bootconfig: break dependency from memblock Breno Leitao
2026-04-15 10:51 ` [PATCH 1/3] bootconfig: use static buffers instead of memblock allocation Breno Leitao
2026-04-15 10:51 ` [PATCH 2/3] init: use static buffers for bootconfig extra command line Breno Leitao
2026-04-17 1:44 ` Masami Hiramatsu [this message]
2026-04-17 15:38 ` Breno Leitao
2026-04-15 10:51 ` [PATCH 3/3] init: move embedded bootconfig parsing before setup_arch() Breno Leitao
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=20260417104436.ece29fd5e2cb7a59c8cf8ac1@kernel.org \
--to=mhiramat@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=kernel-team@meta.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=oss@malat.biz \
--cc=paulmck@kernel.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