LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] splice: direct call for default_file_splice*()
@ 2020-01-20 20:49 Pavel Begunkov
  2020-01-30 16:54 ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Begunkov @ 2020-01-20 20:49 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel, linux-kernel

Indirect calls could be very expensive nowadays, so try to use direct calls
whenever possible.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/splice.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index 6a6f30432688..91448d855ff0 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -852,15 +852,10 @@ EXPORT_SYMBOL(generic_splice_sendpage);
 static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
 			   loff_t *ppos, size_t len, unsigned int flags)
 {
-	ssize_t (*splice_write)(struct pipe_inode_info *, struct file *,
-				loff_t *, size_t, unsigned int);
-
 	if (out->f_op->splice_write)
-		splice_write = out->f_op->splice_write;
+		return out->f_op->splice_write(pipe, out, ppos, len, flags);
 	else
-		splice_write = default_file_splice_write;
-
-	return splice_write(pipe, out, ppos, len, flags);
+		return default_file_splice_write(pipe, out, ppos, len, flags);
 }
 
 /*
@@ -870,8 +865,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
 			 struct pipe_inode_info *pipe, size_t len,
 			 unsigned int flags)
 {
-	ssize_t (*splice_read)(struct file *, loff_t *,
-			       struct pipe_inode_info *, size_t, unsigned int);
 	int ret;
 
 	if (unlikely(!(in->f_mode & FMODE_READ)))
@@ -885,11 +878,9 @@ static long do_splice_to(struct file *in, loff_t *ppos,
 		len = MAX_RW_COUNT;
 
 	if (in->f_op->splice_read)
-		splice_read = in->f_op->splice_read;
+		return in->f_op->splice_read(in, ppos, pipe, len, flags);
 	else
-		splice_read = default_file_splice_read;
-
-	return splice_read(in, ppos, pipe, len, flags);
+		return default_file_splice_read(in, ppos, pipe, len, flags);
 }
 
 /**
-- 
2.24.0


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

* Re: [PATCH] splice: direct call for default_file_splice*()
  2020-01-20 20:49 [PATCH] splice: direct call for default_file_splice*() Pavel Begunkov
@ 2020-01-30 16:54 ` Christoph Hellwig
  2020-01-31  9:52   ` Pavel Begunkov
  2020-08-01 10:12   ` Pavel Begunkov
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2020-01-30 16:54 UTC (permalink / raw)
  To: Pavel Begunkov; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On Mon, Jan 20, 2020 at 11:49:46PM +0300, Pavel Begunkov wrote:
> Indirect calls could be very expensive nowadays, so try to use direct calls
> whenever possible.

... and independent of that your new version is much shorter and easier
to read.  But it could be improved a tiny little bit further:

>  	if (out->f_op->splice_write)
> -		splice_write = out->f_op->splice_write;
> +		return out->f_op->splice_write(pipe, out, ppos, len, flags);
>  	else
> -		splice_write = default_file_splice_write;
> -
> -	return splice_write(pipe, out, ppos, len, flags);
> +		return default_file_splice_write(pipe, out, ppos, len, flags);

No need for the else after an return.

>  	if (in->f_op->splice_read)
> -		splice_read = in->f_op->splice_read;
> +		return in->f_op->splice_read(in, ppos, pipe, len, flags);
>  	else
> -		splice_read = default_file_splice_read;
> -
> -	return splice_read(in, ppos, pipe, len, flags);
> +		return default_file_splice_read(in, ppos, pipe, len, flags);

Same here.

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

* Re: [PATCH] splice: direct call for default_file_splice*()
  2020-01-30 16:54 ` Christoph Hellwig
@ 2020-01-31  9:52   ` Pavel Begunkov
  2020-08-01 10:12   ` Pavel Begunkov
  1 sibling, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2020-01-31  9:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On 1/30/2020 7:54 PM, Christoph Hellwig wrote:
> On Mon, Jan 20, 2020 at 11:49:46PM +0300, Pavel Begunkov wrote:
>> Indirect calls could be very expensive nowadays, so try to use direct calls
>> whenever possible.
> 
> ... and independent of that your new version is much shorter and easier
> to read.  But it could be improved a tiny little bit further:
> 
>>  	if (out->f_op->splice_write)
>> -		splice_write = out->f_op->splice_write;
>> +		return out->f_op->splice_write(pipe, out, ppos, len, flags);
>>  	else
>> -		splice_write = default_file_splice_write;
>> -
>> -	return splice_write(pipe, out, ppos, len, flags);
>> +		return default_file_splice_write(pipe, out, ppos, len, flags);
> 
> No need for the else after an return.

It generates identical binary. For this to not look sloppy, I'd add new
line between, so the same 4 lines. And this looks better for me, but
that's rather subjective.

I don't think it's worth of changing. What's the benefit?

> 
>>  	if (in->f_op->splice_read)
>> -		splice_read = in->f_op->splice_read;
>> +		return in->f_op->splice_read(in, ppos, pipe, len, flags);
>>  	else
>> -		splice_read = default_file_splice_read;
>> -
>> -	return splice_read(in, ppos, pipe, len, flags);
>> +		return default_file_splice_read(in, ppos, pipe, len, flags);
> 
> Same here.
> 

-- 
Pavel Begunkov

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

* Re: [PATCH] splice: direct call for default_file_splice*()
  2020-01-30 16:54 ` Christoph Hellwig
  2020-01-31  9:52   ` Pavel Begunkov
@ 2020-08-01 10:12   ` Pavel Begunkov
  2020-08-01 17:41     ` Christoph Hellwig
  1 sibling, 1 reply; 6+ messages in thread
From: Pavel Begunkov @ 2020-08-01 10:12 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On 30/01/2020 19:54, Christoph Hellwig wrote:
> On Mon, Jan 20, 2020 at 11:49:46PM +0300, Pavel Begunkov wrote:
>> Indirect calls could be very expensive nowadays, so try to use direct calls
>> whenever possible.

Hah, I'm surprised to find it as
00c285d0d0fe4 ("fs: simplify do_splice_from").

Christoph, even though this one is not a big deal, I'm finding the
practice of taking others patches and silently sending them as yours
own in general disgusting. Just for you to know.


> 
> ... and independent of that your new version is much shorter and easier
> to read.  But it could be improved a tiny little bit further:
> 
>>  	if (out->f_op->splice_write)
>> -		splice_write = out->f_op->splice_write;
>> +		return out->f_op->splice_write(pipe, out, ppos, len, flags);
>>  	else
>> -		splice_write = default_file_splice_write;
>> -
>> -	return splice_write(pipe, out, ppos, len, flags);
>> +		return default_file_splice_write(pipe, out, ppos, len, flags);
> 
> No need for the else after an return.
> 
>>  	if (in->f_op->splice_read)
>> -		splice_read = in->f_op->splice_read;
>> +		return in->f_op->splice_read(in, ppos, pipe, len, flags);
>>  	else
>> -		splice_read = default_file_splice_read;
>> -
>> -	return splice_read(in, ppos, pipe, len, flags);
>> +		return default_file_splice_read(in, ppos, pipe, len, flags);
> 
> Same here.
> 

-- 
Pavel Begunkov

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

* Re: [PATCH] splice: direct call for default_file_splice*()
  2020-08-01 10:12   ` Pavel Begunkov
@ 2020-08-01 17:41     ` Christoph Hellwig
  2020-08-02  8:49       ` Pavel Begunkov
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2020-08-01 17:41 UTC (permalink / raw)
  To: Pavel Begunkov
  Cc: Christoph Hellwig, Alexander Viro, linux-fsdevel, linux-kernel

On Sat, Aug 01, 2020 at 01:12:22PM +0300, Pavel Begunkov wrote:
> On 30/01/2020 19:54, Christoph Hellwig wrote:
> > On Mon, Jan 20, 2020 at 11:49:46PM +0300, Pavel Begunkov wrote:
> >> Indirect calls could be very expensive nowadays, so try to use direct calls
> >> whenever possible.
> 
> Hah, I'm surprised to find it as
> 00c285d0d0fe4 ("fs: simplify do_splice_from").
> 
> Christoph, even though this one is not a big deal, I'm finding the
> practice of taking others patches and silently sending them as yours
> own in general disgusting. Just for you to know.

Err, what makes you think I took your patch vs just not remembering
and pointlessly doing the same cleanup again?  If I had rembered your
patch I would have just added to the series with your credit as I've
done for plenty other patches..

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

* Re: [PATCH] splice: direct call for default_file_splice*()
  2020-08-01 17:41     ` Christoph Hellwig
@ 2020-08-02  8:49       ` Pavel Begunkov
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2020-08-02  8:49 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On 01/08/2020 20:41, Christoph Hellwig wrote:
> On Sat, Aug 01, 2020 at 01:12:22PM +0300, Pavel Begunkov wrote:
>> On 30/01/2020 19:54, Christoph Hellwig wrote:
>>> On Mon, Jan 20, 2020 at 11:49:46PM +0300, Pavel Begunkov wrote:
>>>> Indirect calls could be very expensive nowadays, so try to use direct calls
>>>> whenever possible.
>>
>> Hah, I'm surprised to find it as
>> 00c285d0d0fe4 ("fs: simplify do_splice_from").
>>
>> Christoph, even though this one is not a big deal, I'm finding the
>> practice of taking others patches and silently sending them as yours
>> own in general disgusting. Just for you to know.
> 
> Err, what makes you think I took your patch vs just not remembering
> and pointlessly doing the same cleanup again?  If I had rembered your
> patch I would have just added to the series with your credit as I've
> done for plenty other patches..

I have no intention of picking it to pieces or something, it doesn't
worth our time, and glad that's by accident, but you may guess how it
looks -- you commented on it, and after not being picked, the patch
reappears slightly rebranded.

-- 
Pavel Begunkov

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 20:49 [PATCH] splice: direct call for default_file_splice*() Pavel Begunkov
2020-01-30 16:54 ` Christoph Hellwig
2020-01-31  9:52   ` Pavel Begunkov
2020-08-01 10:12   ` Pavel Begunkov
2020-08-01 17:41     ` Christoph Hellwig
2020-08-02  8:49       ` Pavel Begunkov

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git