linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ttyprintk: optimize tpk_close flush code
@ 2020-11-17  2:21 Junyong Sun
  2020-11-17  7:04 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Junyong Sun @ 2020-11-17  2:21 UTC (permalink / raw)
  To: arnd, gregkh, sunjunyong; +Cc: linux-kernel

tpk_printk(NULL,0) do nothing but call tpk_flush to
flush buffer, so why don't use tpk_flush diretcly?
this is a small optimization.

Signed-off-by: Junyong Sun <sunjunyong@xiaomi.com>
---
changes in v2:
- rm the flush comment as tpk_flush makes it obvious.
---
---
 drivers/char/ttyprintk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 6a0059e..1f82742 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)
 	unsigned long flags;
 
 	spin_lock_irqsave(&tpkp->spinlock, flags);
-	/* flush tpk_printk buffer */
-	tpk_printk(NULL, 0);
+	tpk_flush();
 	spin_unlock_irqrestore(&tpkp->spinlock, flags);
 
 	tty_port_close(&tpkp->port, tty, filp);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ttyprintk: optimize tpk_close flush code
  2020-11-17  2:21 [PATCH v2] ttyprintk: optimize tpk_close flush code Junyong Sun
@ 2020-11-17  7:04 ` Greg KH
  2020-11-28  6:33   ` sunjunyong
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2020-11-17  7:04 UTC (permalink / raw)
  To: Junyong Sun; +Cc: arnd, sunjunyong, linux-kernel

On Tue, Nov 17, 2020 at 10:21:07AM +0800, Junyong Sun wrote:
> tpk_printk(NULL,0) do nothing but call tpk_flush to
> flush buffer, so why don't use tpk_flush diretcly?
> this is a small optimization.
> 
> Signed-off-by: Junyong Sun <sunjunyong@xiaomi.com>
> ---
> changes in v2:
> - rm the flush comment as tpk_flush makes it obvious.
> ---
> ---
>  drivers/char/ttyprintk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
> index 6a0059e..1f82742 100644
> --- a/drivers/char/ttyprintk.c
> +++ b/drivers/char/ttyprintk.c
> @@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&tpkp->spinlock, flags);
> -	/* flush tpk_printk buffer */
> -	tpk_printk(NULL, 0);
> +	tpk_flush();
>  	spin_unlock_irqrestore(&tpkp->spinlock, flags);

Why did you not make the change to tpk_printk() as well that I asked you
to?

It is a static function, you control the callers, so the extra "is this
NULL, if so flush" logic makes no sense to keep around anymore, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] ttyprintk: optimize tpk_close flush code
  2020-11-17  7:04 ` Greg KH
@ 2020-11-28  6:33   ` sunjunyong
  0 siblings, 0 replies; 3+ messages in thread
From: sunjunyong @ 2020-11-28  6:33 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, sunjunyong, linux-kernel

Hi Greg:

Sorry for the late reply.
> Why did you not make the change to tpk_printk() as well that I asked you
> to?
> 
> It is a static function, you control the callers, so the extra "is this
> NULL, if so flush" logic makes no sense to keep around anymore, right?
tpk_printk have logic to judge whether the input parameter is NULL.But for
below removed line, we already have known the input parameter is null, so
we don't need call logic of judge NULL, just call tpk_flush to flush is enough.
This is just a little optimization.
----------------------------
-	tpk_printk(NULL, 0);
----------------------------

Brs.
Junyong

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-28 21:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17  2:21 [PATCH v2] ttyprintk: optimize tpk_close flush code Junyong Sun
2020-11-17  7:04 ` Greg KH
2020-11-28  6:33   ` sunjunyong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).