mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Petr Mladek <pmladek@suse.com>
Cc: Namit Gupta <gupta.namit@samsung.com>,
	sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org,
	pankaj.m@samsung.com, a.sahrawat@samsung.com,
	himanshu.m@samsung.com
Subject: Re: [PATCH] printk: remove unnecessary kmalloc() from syslog during clear
Date: Mon, 25 Jun 2018 10:37:04 -0400	[thread overview]
Message-ID: <20180625103704.49811ec1@gandalf.local.home> (raw)
In-Reply-To: <20180625133705.7zsg2rkw4xtyg6ie@pathway.suse.cz>

On Mon, 25 Jun 2018 15:37:05 +0200
Petr Mladek <pmladek@suse.com> wrote:

> On Wed 2018-06-20 19:26:19, Namit Gupta wrote:
> > When the request is only for clearing logs, there is no need for
> > allocation/deallocation. Only the indexes need to be reset and returned.
> > Rest of the patch is mostly made up of changes because of indention.
> > 
> > Signed-off-by: Namit Gupta <gupta.namit@samsung.com>
> > Signed-off-by: Himanshu Maithani <himanshu.m@samsung.com>  
> 
> > ---
> >  kernel/printk/printk.c | 111 ++++++++++++++++++++++++++-----------------------
> >  1 file changed, 60 insertions(+), 51 deletions(-)
> > 
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 512f7c2..53952ce 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -1348,71 +1348,80 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
> >  {
> >  	char *text;
> >  	int len = 0;
> > +	u64 next_seq;
> > +	u64 seq;
> > +	u32 idx;
> > +
> > +	if (!buf) {
> > +		if (clear) {
> > +			logbuf_lock_irq();
> > +			clear_seq = log_next_seq;
> > +			clear_idx = log_next_idx;
> > +			logbuf_unlock_irq();  
> 
> I pushed a bit different version into printk.git, branch for-4.19,
> see below. It removes the code duplication. Also it keeps the original
> indentation. IMHO, it helped to better distinguish the code for printing
> and clearing.
> 
> It is rather a cosmetic change, so I do not want you to resend
> Reviewed-by tags. But feel free to disagree and ask me to use
> the original variant.
> 

I actually prefer the original version. It's not really duplicating
much text, and it's cleaner, because it lets you know exactly what is
happening when buf == NULL.

	if (buf)
		text = kmalloc();

	logbuf_lock_irq();

	if (buf) {
		[...]
	}

Is IMHO rather ugly.

And the original patch has one more advantage. If buf and clear are
both NULL/zero, we don't take any locks.

-- Steve



  parent reply	other threads:[~2018-06-25 14:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180620135951epcas5p3bd2a8f25ec689ca333bce861b527dba2@epcas5p3.samsung.com>
2018-06-20 13:56 ` Namit Gupta
2018-06-20 14:16   ` Steven Rostedt
2018-06-21  6:58   ` Sergey Senozhatsky
2018-06-25 13:37   ` Petr Mladek
2018-06-25 13:42     ` Jiri Kosina
2018-06-25 14:35     ` Sergey Senozhatsky
2018-06-25 14:37     ` Steven Rostedt [this message]
2018-06-25 14:44       ` Sergey Senozhatsky
2018-06-26 12:43         ` Petr Mladek
2018-06-26 14:39           ` Steven Rostedt
2018-06-27 15:06             ` Petr Mladek
2018-07-09 11:48               ` Petr Mladek

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=20180625103704.49811ec1@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=a.sahrawat@samsung.com \
    --cc=gupta.namit@samsung.com \
    --cc=himanshu.m@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.m@samsung.com \
    --cc=pmladek@suse.com \
    --cc=sergey.senozhatsky@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®