2/2 2.5.45 cleanup & add original copy_ro/from_user
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Andrew Morton
(That is, using the movnta instructions for well-aligned copies and clears so that we don't read the destination memory while overwriting it).
I did some experiments with movnta and it was near always a loss for memcpy/copy_*_user type stuff. The reason is that it flushes the destination out of cache and when you try to read it afterwards for some reason (which happens often - e.g. most copy_*_user uses actually do access it afterwards) then you eat a full cache miss for them and that is costly and kills all other advantages.
It may be a win for direct copy-to-page cache and then page cache DMA outside and page cache not mapped anywhere, but even then it's not completely clear it's that helpful to have it not in cache. For example an Athlon can serve an DMA directly out of its CPU caches and that may be faster than serving it out of RAM (Intel CPUs cannot however)
-Andi
Quoted 7 lines · Andi Kleen
Quoted 3 lines · Andrew Morton
(That is, using the movnta instructions for well-aligned copies and clears so that we don't read the destination memory while overwriting it).
Quoted 6 lines
I did some experiments with movnta and it was near always a loss for memcpy/copy_*_user type stuff. The reason is that it flushes the destination out of cache and when you try to read it afterwards for some reason (which happens often - e.g. most copy_*_user uses actually do access it afterwards) then you eat a full cache miss for them and that is costly and kills all other advantages.
Oh. I was under the impression that the destination ended up in the CPU caches.
Yes, if that's not the case then the whole thing is pretty useless.
Quoted 5 lines
It may be a win for direct copy-to-page cache and then page cache DMA outside and page cache not mapped anywhere, but even then it's not completely clear it's that helpful to have it not in cache. For example an Athlon can serve an DMA directly out of its CPU caches and that may be faster than serving it out of RAM (Intel CPUs cannot however)
So it may be applicable to write(2) on intel.
Quoted 11 lines · Andi Kleen
Quoted 3 lines · Andrew Morton
(That is, using the movnta instructions for well-aligned copies and clears so that we don't read the destination memory while overwriting it).
I did some experiments with movnta and it was near always a loss for memcpy/copy_*_user type stuff. The reason is that it flushes the destination out of cache and when you try to read it afterwards for some reason (which happens often - e.g. most copy_*_user uses actually do access it afterwards) then you eat a full cache miss for them and that is costly and kills all other advantages.
That depends on size. If you do huge memcpy (say 1 mb) it still wins by wide margin. Not that we do such huge operations often, but code can check size and pick different routines for small and big blocks
--
vda
Quoted 4 lines
That depends on size. If you do huge memcpy (say 1 mb) it still wins by wide margin. Not that we do such huge operations often, but code can check size and pick different routines for small and big blocks
The kernel nevers does such huge memcpys. It rarely does handle any buffer bigger than a page (4K)
-Andi
Quoted 7 lines · Andi Kleen
Quoted 4 lines
That depends on size. If you do huge memcpy (say 1 mb) it still wins by wide margin. Not that we do such huge operations often, but code can check size and pick different routines for small and big blocks
The kernel nevers does such huge memcpys. It rarely does handle any buffer bigger than a page (4K)
Okay I take that.
How did you determined that movntXX stores are net loss? I thought about that and didn't came to a working solution.
It's easy to time memcpy() but harder to measure susequent cache misses when copied data gets accessed. We can read it back after memcpy and measure memcpy()+read, but is entire copy gets used immediately after memcpy() in real world usage? We're in benchmarking hell :(
--
vda
Quoted 5 lines
It's easy to time
memcpy()but harder to measure susequent cache misses when copied data gets accessed. We can read it back after memcpy and measure memcpy()+read, but is entire copy gets used immediately aftermemcpy()in real world usage? We're in benchmarking hell :(
You test common operations, like pipe bandwidth or ioctls.
-Andi