Re: [patch v3] splice: fix race with page invalidation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Thursday, July 31, 2008 - 9:34 am

On Thu, 31 Jul 2008, Jamie Lokier wrote:

Oh yes it is.

Doing it in user space is _trivial_, because you control everything, and 
there are no barriers.


Umm. And that's exactly what I *described*.

But it's trivial to do inside one program (either all in user space, or 
all in kernel space).

It's very difficult indeed to do across two totally different domains.

Have you _looked_ at the complexities of async IO in UNIX? They are 
horrible. The overhead to even just _track_ the notifiers basically undoes 
all relevant optimizations for doing zero-copy.

IOW, AIO is useful not because of zero-copy, but because it allows 
_overlapping_ IO. Anybody who confuses the two is seriously misguided.


.. and this one shows that you have no clue about performance of a memcpy.

Once you do that COW, you're actually MUCH BETTER OFF just copying.

Really.

Copying a page is much cheaper than doing COW on it. Doing a "write()" 
really isn't that expensive. People think that memory is slow, but memory 
isn't all that slow, and caches work really well. Yes, memory is slow 
compared to a few reference count increments, but memory is absolutely 
*not* slow when compared to the overhead of TLB invalidates across CPUs 
etc.

So don't do it. If you think you need it, you should not be using 
zero-copy in the first place.

In other words, let me repeat:

 - use splice() when you *understand* that it's just taking a refcount and 
   you don't care.

 - use read()/write() when you can't be bothered.

There's nothing wrong with read/write. The _normal_ situation should be 
that 99.9% of all IO is done using the regular interfaces. Splice() (and 
sendpage() before it) is a special case. You should be using splice if you 
have a DVR and you can do all the DMA from the tuner card into buffers 
that you can then split up and send off to show real-time at the same time 
as you copy them to disk.

THAT is when zero-copy is useful. If you think you need to play games with 
async notifiers, you're already off the deep end.

			Linus
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 2:43 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 10:00 am)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 10:29 am)
Re: [patch v3] splice: fix race with page invalidation, Jens Axboe, (Wed Jul 30, 10:54 am)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 11:32 am)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 11:43 am)
Re: [patch v3] splice: fix race with page invalidation, Jens Axboe, (Wed Jul 30, 12:45 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 1:05 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 1:13 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 1:45 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 1:51 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 2:16 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 2:22 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Wed Jul 30, 2:46 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 2:56 pm)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Wed Jul 30, 5:11 pm)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Wed Jul 30, 5:42 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 5:51 pm)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Wed Jul 30, 5:54 pm)
Re: [patch v3] splice: fix race with page invalidation, Nick Piggin, (Wed Jul 30, 7:16 pm)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Wed Jul 30, 11:12 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Thu Jul 31, 12:30 am)
Re: [patch v3] splice: fix race with page invalidation, Evgeniy Polyakov, (Thu Jul 31, 3:26 am)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Thu Jul 31, 5:33 am)
Re: [patch v3] splice: fix race with page invalidation, Nick Piggin, (Thu Jul 31, 5:49 am)
Re: [patch v3] splice: fix race with page invalidation, Nick Piggin, (Thu Jul 31, 5:59 am)
Re: [patch v3] splice: fix race with page invalidation, Evgeniy Polyakov, (Thu Jul 31, 6:29 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Thu Jul 31, 9:34 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Thu Jul 31, 9:56 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Thu Jul 31, 10:00 am)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Thu Jul 31, 10:21 am)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Thu Jul 31, 11:13 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Thu Jul 31, 11:54 am)
Re: [patch v3] splice: fix race with page invalidation, Nick Piggin, (Thu Jul 31, 6:22 pm)
Re: [patch v3] splice: fix race with page invalidation, Miklos Szeredi, (Fri Aug 1, 11:28 am)
Re: [patch v3] splice: fix race with page invalidation, Linus Torvalds, (Fri Aug 1, 11:32 am)
Re: [patch v3] splice: fix race with page invalidation, Jamie Lokier, (Mon Aug 4, 8:29 am)
Re: [patch v3] splice: fix race with page invalidation, Michael Kerrisk, (Sun Aug 10, 8:22 pm)