Skip to contentSkip to conversation

zero^H^H^H^Hsingle copy pipe

PATCH Ben LaHaise 3 participants 5 messages May 7, 2001 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 7 lines · Manfred Spraul

I'm now running with the patch for several hours, no problems.

bw_pipe transfer rate has nearly doubled and the number of context switches for one bw_pipe run is down from 71500 to 5500.

Please test it.

Any particular reason for not using davem's single copy kiobuf based code?

-ben

#2 lore raw
In reply to a message not in the archive

From: "Ben LaHaise" <[email protected]>

Quoted 4 lines

Any particular reason for not using davem's single copy kiobuf based code?

The main problem is that map_user_kiobuf() locks pages into memory. It's a bad idea for pipes. Either we must severely limit the maximum amount of data in the direct-copy buffers, or we must add a swap file based backing store. If I understand the BSD direct-pipe code correctly it has a swap file based backing store. I think that's insane. And limiting the direct copy buffers to a few kB defeats the purpose of direct copy.
Instead pipe_write just queues (tsk,addr,len), and then pipe_read() uses a modified access_process_vm() function to copy directly. Currently I've copied the code from kernel/ptrace.c, but I plan to merge copy_user_to_user() back into access_process_vm().

And the current pipe_{read,write} are a total mess with nested loops and gotos. It's possible to create wakeup storms. I rewrote them as well ;-)

But the new code still contains one deadlock :-(
--
Manfred

#3 lore raw
Quoted 7 lines · Manfred Spraul

The main problem is that map_user_kiobuf() locks pages into memory. It's a bad idea for pipes. Either we must severely limit the maximum amount of data in the direct-copy buffers, or we must add a swap file based backing store. If I understand the BSD direct-pipe code correctly it has a swap file based backing store. I think that's insane. And limiting the direct copy buffers to a few kB defeats the purpose of direct copy.

Okay, how about the following instead (I'm thinking of generic code that we can reuse): continue to queue the mm, address, length tuple (I've actually got use for this too), and then use a map_mm_kiobuf (which is map_user_kiobuf but with an mm parameter) for the portion of the buffer that's currently being copied. That improves code reuse and gives us a few primatives that are quite useful elsewhere.

Quoted 2 lines

And the current pipe_{read,write} are a total mess with nested loops and gotos. It's possible to create wakeup storms. I rewrote them as well ;-)

Cool! =)

-ben

#4 lore raw
Quoted 4 lines · Ben LaHaise

and then use a map_mm_kiobuf (which is
map_user_kiobuf but with an mm parameter) for the portion of the buffer that's currently being copied. That improves code reuse and gives us a few primatives that are quite useful elsewhere.

If it has roughly the same cost as Manfred's copy_user thing, it is therefore roughly equivalent.

If this map_mm_kiobuf() thing would cost more (I think it would because it would be using kiobufs when for this case there is absolutely no need for them) then why? "It's a clean interface everyone can use" is not an acceptable answer when the clean interface costs significantly more than the straightforward approach.

Later,
David S. Miller
[email protected]

#5 lore raw
In reply to Manfred Spraul
Quoted 4 lines · Manfred Spraul

If I understand the BSD direct-pipe code correctly
it has a swap file based backing store. I think that's insane. And limiting the direct copy buffers to a few kB defeats the purpose of direct copy.

Last time I studied that FreeBSD pipe code, it used a global limit for locked memory.

Later,
David S. Miller
[email protected]