From patchwork Tue Apr 9 04:43:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13621791 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD0192B2DD; Tue, 9 Apr 2024 04:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712637840; cv=none; b=KYvFTUuymI75vFs/E1etxtqmHHJ6ogrcFjW2uq2PxAd4XPWpgfVrwWUHRsCYwawovJm3P8VxIuawMFMU1zLZazcBGHdUFFtlx96bTLO2xXCWqy3Txjh2ycdwi+ZUmBjaQs9My/Rwc/6B3836dK9G6n0fYaEVs08c4a+oy3oGKds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712637840; c=relaxed/simple; bh=leBEXkCaK3+c0BDJTMQ4LEGGdKWqrrDOjns+gsQwv74=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ix5rZMK26rqUCOGlgN8oKOvj98iliJbKnFXC4a9gknzcuVQa+WL+o30WPWXxnm3vihm6c1x7HiLeQAKqXLj3/7XxGUI6wUVjH3txnxupZPIL4I8U8qhms4jrzi57m3K6CPatSjIS07mAWAw8T7H+eS+fvdN2xpvr9FHnTwrb3Hk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aRu3Bevp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aRu3Bevp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D4DFC433F1; Tue, 9 Apr 2024 04:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712637840; bh=leBEXkCaK3+c0BDJTMQ4LEGGdKWqrrDOjns+gsQwv74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aRu3BevpJC52+U4MlDu1y6ru0D6MgY5T0BAc87twzgNRRZ6A9UFLNMDomkHATVMl7 0AYqHHBBTamsVtcgw7ekAJ/kiKEqEDB7q8P2uPUcIi6fLOfP43h3KqMs13Dz80nGE+ cEjrVT8fDHZHD6pswn6Tyr/uqq4Qr2d5vVuSvR3kx7KzIRmFpCkyQwJsVECHj6Fj2I Qp+lxSsNUuqZA4roJp/+pOvLKdQSHagc8cp8AWjxNQs030n8tNJGdHt9KqhIV3d3pO G9zbnnCOisFCMaOeSQbem33/YMHqYh05/92Nf/TMquH3Y5T7mZBUSodoNcC+gulfd5 Q8lxe+o6QGM4w== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2A875CE12F2; Mon, 8 Apr 2024 21:44:00 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Zhenhua Huang , Masami Hiramatsu , "Paul E . McKenney" Subject: [PATCH v2 fs/proc/bootconfig 1/2] fs/proc: remove redundant comments from /proc/bootconfig Date: Mon, 8 Apr 2024 21:43:57 -0700 Message-Id: <20240409044358.1156477-1-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Zhenhua Huang commit 717c7c894d4b ("fs/proc: Add boot loader arguments as comment to /proc/bootconfig") adds bootloader argument comments into /proc/bootconfig. /proc/bootconfig shows boot_command_line[] multiple times following every xbc key value pair, that's duplicated and not necessary. Remove redundant ones. Output before and after the fix is like: key1 = value1 *bootloader argument comments* key2 = value2 *bootloader argument comments* key3 = value3 *bootloader argument comments* ... key1 = value1 key2 = value2 key3 = value3 *bootloader argument comments* ... Fixes: 717c7c894d4b ("fs/proc: Add boot loader arguments as comment to /proc/bootconfig") Signed-off-by: Zhenhua Huang Signed-off-by: Paul E. McKenney Cc: Cc: Acked-by: Masami Hiramatsu (Google) --- fs/proc/bootconfig.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c index 902b326e1e560..e5635a6b127b0 100644 --- a/fs/proc/bootconfig.c +++ b/fs/proc/bootconfig.c @@ -62,12 +62,12 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) break; dst += ret; } - if (ret >= 0 && boot_command_line[0]) { - ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n", - boot_command_line); - if (ret > 0) - dst += ret; - } + } + if (ret >= 0 && boot_command_line[0]) { + ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n", + boot_command_line); + if (ret > 0) + dst += ret; } out: kfree(key); From patchwork Tue Apr 9 04:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 13621792 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF6333399B; Tue, 9 Apr 2024 04:44:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712637841; cv=none; b=PpsRYWLQQfLcziOXBAs5ggDcu7c5qt211VjtwmXD1NJAeBgP0XWrXqHO+L2P82Ka0yIc90ufI2djbUwEPYLr4v7m+g1qyIlF0EO3QTdki87yc5kJ1qsK+kFSPgKWZH228eI97hq8W3YET0Sl1hzCYCl/M2VexY5VvxEJBwiWwko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712637841; c=relaxed/simple; bh=bDcauKtxgbpkQX74FEAfo2NPyUT++CTn+Q/La644a14=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JtE302oORNBmvDaGxh1Qiv00eWsN7+SHF4qaT2K4zN/OhcM+L7/pzIDl1H4XQzfe1pHLjSjC9N17ENqBnpO7d5k15J0aiNeuEE0QcuQmwC20NwCDW2FNtmwDDv69RM5E2rMraRLjs8t0Q9WabIIGMKAczbZQMcq4ht8kxA32aYc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XR6VWoEr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XR6VWoEr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 884B3C43390; Tue, 9 Apr 2024 04:44:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712637840; bh=bDcauKtxgbpkQX74FEAfo2NPyUT++CTn+Q/La644a14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XR6VWoEr6C7UVwqHUKtLyLbUz4qYGSXAKHCNIiptwPWIDqrIfaLUWzoPePz7PtEuN wphPVduavnbNUVefIAOcOagpySisqPOThq0VyJyyvwQ+4Y/Wg9+fri719oSGzkCEqs H5r9GaaLlxtrlNrqkb2eHzkoAUrcBIxZ81SXnvUFpZGQ5J4vAZC9eVJJtGRlbnnLlB RjwuSH3DdzSR/HtNH9Fd4byeTiuSRAvI4Ho16/k3BFmUVWG9tHz56oyrHsstMygsoX t++okkLDebsmYjk7r7z4l/8uZLT2NTYCDnZgcK7Dwu5BS4gqktC68r/bxYcO4AMjVq He+j+KMFNRU0Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 2D827CE1E93; Mon, 8 Apr 2024 21:44:00 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Zhenhua Huang , Masami Hiramatsu , "Paul E . McKenney" Subject: [PATCH v2 fs/proc/bootconfig 2/2] fs/proc: Skip bootloader comment if no embedded kernel parameters Date: Mon, 8 Apr 2024 21:43:58 -0700 Message-Id: <20240409044358.1156477-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Masami Hiramatsu If the "bootconfig" kernel command-line argument was specified or if the kernel was built with CONFIG_BOOT_CONFIG_FORCE, but if there are no embedded kernel parameter, omit the "# Parameters from bootloader:" comment from the /proc/bootconfig file. This will cause automation to fall back to the /proc/cmdline file, which will be identical to the comment in this no-embedded-kernel-parameters case. Signed-off-by: Masami Hiramatsu Signed-off-by: Paul E. McKenney --- fs/proc/bootconfig.c | 2 +- include/linux/bootconfig.h | 1 + init/main.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c index e5635a6b127b0..87dcaae32ff87 100644 --- a/fs/proc/bootconfig.c +++ b/fs/proc/bootconfig.c @@ -63,7 +63,7 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) dst += ret; } } - if (ret >= 0 && boot_command_line[0]) { + if (cmdline_has_extra_options() && ret >= 0 && boot_command_line[0]) { ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n", boot_command_line); if (ret > 0) diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h index ca73940e26df8..e5ee2c694401e 100644 --- a/include/linux/bootconfig.h +++ b/include/linux/bootconfig.h @@ -10,6 +10,7 @@ #ifdef __KERNEL__ #include #include +bool __init cmdline_has_extra_options(void); #else /* !__KERNEL__ */ /* * NOTE: This is only for tools/bootconfig, because tools/bootconfig will diff --git a/init/main.c b/init/main.c index 2ca52474d0c30..881f6230ee59e 100644 --- a/init/main.c +++ b/init/main.c @@ -487,6 +487,11 @@ static int __init warn_bootconfig(char *str) early_param("bootconfig", warn_bootconfig); +bool __init cmdline_has_extra_options(void) +{ + return extra_command_line || extra_init_args; +} + /* Change NUL term back to "=", to make "param" the whole string. */ static void __init repair_env_string(char *param, char *val) {