From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79650C4361B for ; Thu, 3 Dec 2020 15:58:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21BDB207AD for ; Thu, 3 Dec 2020 15:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731084AbgLCP6O (ORCPT ); Thu, 3 Dec 2020 10:58:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:35256 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726055AbgLCP6N (ORCPT ); Thu, 3 Dec 2020 10:58:13 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607011047; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3D5PmsM5o2/MsyFq3BHithOYdqUSwVQEVFuHkMBs+lE=; b=E1arrP/BXzu1AEH5OJMW/e258UKo0Ul3MP6ZX230bn9qxBL93sV2g9eFumgGG1Q5sbK9Uz SIZyWsY2F2Zr+OkyJ0z1ntFX84zBRCO2f92/exAkJUvpecu2+L1QKFWIUdK2YwD7D1h8mC fyANJZT+zf6OXoNGKz6xrMWUdtVJZgM= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 91784AC65; Thu, 3 Dec 2020 15:57:27 +0000 (UTC) Date: Thu, 3 Dec 2020 16:57:26 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH next v2 1/3] printk: inline log_output(),log_store() in vprintk_store() Message-ID: References: <20201201205341.3871-1-john.ogness@linutronix.de> <20201201205341.3871-2-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201205341.3871-2-john.ogness@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2020-12-01 21:59:39, John Ogness wrote: > In preparation for removing logbuf_lock, inline log_output() > and log_store() into vprintk_store(). This will simplify dealing > with the various code branches and fallbacks that are possible. > --- > kernel/printk/printk.c | 134 +++++++++++++++++------------------------ > 1 file changed, 56 insertions(+), 78 deletions(-) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index f279d4fbd9dd..fc5e3a7d6d89 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -1983,7 +1915,53 @@ int vprintk_store(int facility, int level, > if (dev_info) > lflags |= LOG_NEWLINE; > > - return log_output(facility, level, lflags, dev_info, text, text_len); > + if (lflags & LOG_CONT) { > + prb_rec_init_wr(&r, text_len); > + if (prb_reserve_in_last(&e, prb, &r, caller_id, LOG_LINE_MAX)) { > + memcpy(&r.text_buf[r.info->text_len], text, text_len); > + r.info->text_len += text_len; > + > + if (lflags & LOG_NEWLINE) { > + r.info->flags |= LOG_NEWLINE; > + prb_final_commit(&e); > + } else { > + prb_commit(&e); > + } > + > + return text_len; > + } > + } > + > + prb_rec_init_wr(&r, text_len); This is called in both branches. I would do it just once at the beginning. > + if (!prb_reserve(&e, prb, &r)) { > + /* truncate the message if it is too long for empty buffer */ > + truncate_msg(&text_len, &trunc_msg_len); > + > + prb_rec_init_wr(&r, text_len + trunc_msg_len); > + if (!prb_reserve(&e, prb, &r)) > + return 0; > + } > + > + /* fill message */ > + memcpy(&r.text_buf[0], text, text_len); > + if (trunc_msg_len) > + memcpy(&r.text_buf[text_len], trunc_msg, trunc_msg_len); > + r.info->text_len = text_len + trunc_msg_len; > + r.info->facility = facility; > + r.info->level = level & 7; > + r.info->flags = lflags & 0x1f; > + r.info->ts_nsec = ts_nsec; This is the only location where ts_nsec is used. I would remove the variable and call: r.info->ts_nsec = local_clock(); > + r.info->caller_id = caller_id; > + if (dev_info) > + memcpy(&r.info->dev_info, dev_info, sizeof(r.info->dev_info)); > + > + /* A message without a trailing newline can be continued. */ > + if (!(lflags & LOG_NEWLINE)) > + prb_commit(&e); > + else > + prb_final_commit(&e); > + > + return (text_len + trunc_msg_len); > } Both changes are cosmetic and I do not resist on them. Please, do the changes if v3 is needed and you agree with them. Anyway, feel free to use: Reviewed-by: Petr Mladek Best Regards, Petr