Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3182612ybk; Mon, 18 May 2020 20:48:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA/NdROJJyVuPLIz0UEJw/F6MyvuOSfT4V8a9y2yDqv63fi/RFbFENwbFvGTsNgvwsvCDA X-Received: by 2002:a17:907:39b:: with SMTP id ss27mr14914250ejb.209.1589860092307; Mon, 18 May 2020 20:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589860092; cv=none; d=google.com; s=arc-20160816; b=COxcXQeSrzEiHHv8yNovrdoSbQBjKCSB7HU51BU1gZqACZbxDCTUbxddY9nM/FaqVq kA4gYjFWtCPanzLjO3JMTVdEUaEynjDAXHfH6GGsPAsEgkQrAXy/xnEnY3pkHqac+XQg dzazAr064Q89TPyHBilRsTmwxMD1W3D347fpr2oNvhU7SYgUPSFWGDukSXEnhPR35jo3 mNFzTg0IWWzu4tkSti48fXRn0VlxZPZNXKb8Q7JWSYMuGPDKzOLyAKRX0U5uyECsbdkW QszYnrf/I2zRjRdmmI1rD3hocpX+h7o+8l4wxLMMtDn3KMnnGLWnrgFssmTqS4cS0XBT 9dEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=S7QNYPgEee3CZiHXV5RSncGgomXO1mI/YNifiAa7xyk=; b=lTYTNdJ1fiUPFSQJ26XXOY3N6txtZ1W++xEnH9G3K1CMLysyk8N4fThI5T118i+AHU js1GHSo00R16tsM3REz/l4nKbTirnSCk6UmcuSfvjFtxng9SSVcqTf2tIyD2GuWaQ1B9 5SxObmgMs6ajdUqI85DFReDVN3bJj3W907VxiJZs02iN+SDD0zh0iRdFhqUHIJScVN5I 5bDnNAAoUt3Mpsrd02OAsLsEmUogoVa98jUmIkDGHLmM+YO21Hm1548ifobmch313A+C AyHayrzjqBodyD4v/w0m4PeasgepXBZT9GRKnWyPsC1qhGF55eJxsu7/yCcV3AT+dwk0 Jrpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x9MFc7Rf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co4si7327759edb.269.2020.05.18.20.47.49; Mon, 18 May 2020 20:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x9MFc7Rf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726958AbgESDoR (ORCPT + 99 others); Mon, 18 May 2020 23:44:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:54628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgESDoQ (ORCPT ); Mon, 18 May 2020 23:44:16 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DEF5420708; Tue, 19 May 2020 03:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589859856; bh=S5y0IyDpVW3EYw//xQGmNpU37sUGpiHPq5/R1PtuFK0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=x9MFc7RfaziLEN4aadMIoei7QP+yH3Yci+wyG0G7HnkNkA0/hyEOyl+dRKe349/Lx D+tjsXx+k9zzzcPjApD7XRkXc2rvE5xUXG1iLXo/Ja09HC1IUkkefbftirsgtjdk0r R+/E6hoWtWAwdgh8d4g9xelTS+hqe+qmfB26J+c0= Date: Mon, 18 May 2020 20:44:15 -0700 From: Andrew Morton To: =?UTF-8?B?546L56iL5Yia?= Cc: "'Masami Hiramatsu'" , "'Steven Rostedt \(VMware'" , "'Kees Cook'" , "'Thomas Gleixner'" , "'Dominik Brodowski'" , "'Arvind Sankar'" , "'Mike Rapoport'" , "'Alexander Potapenko'" , , Subject: Re: [PATCH] init/main.c: Print all command line when boot Message-Id: <20200518204415.d1a3adaba597ce5b232b4b2a@linux-foundation.org> In-Reply-To: <010201d62d8d$bf7605f0$3e6211d0$@vivo.com> References: <010201d62d8d$bf7605f0$3e6211d0$@vivo.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 19 May 2020 11:29:46 +0800 王程刚 wrote: > Function pr_notice print max length maybe less than the command line length, > need more times to print all. > For example, arm64 has 2048 bytes command line length, but printk maximum > length is only 1024 bytes. I can see why that might be a problem! > --- a/init/main.c > +++ b/init/main.c > @@ -825,6 +825,16 @@ void __init __weak arch_call_rest_init(void) > rest_init(); > } > > +static void __init print_cmdline(void) > +{ > + const char *prefix = "Kernel command line: "; const char prefix[] = "..."; might generate slightly more efficient code. > + int len = -strlen(prefix); hm, tricky. What the heck does printk() actually return to the caller? Seems that we forgot to document this, and there are so many different paths which a printk call can take internally that I'm not confident that they all got it right! > + len += pr_notice("%s%s\n", prefix, boot_command_line); > + while (boot_command_line[len]) > + len += pr_notice("%s\n", &boot_command_line[len]); > +} Did you really intend to insert a \n into the output every 1024'th character? And what effect does this additional \n have upon the code logic? Doesn't this cause the printk() return value to be one greater than expected each time it is called? > > ... >