lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 24 Apr 2007 14:48:27 +0200
From:	Eric Dumazet <dada1@...mosbay.com>
To:	Alex Vorona <voron@...ost.net>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Re[2]: sendfile to nonblocking socket

On Tue, 24 Apr 2007 14:33:48 +0400
Alex Vorona <voron@...ost.net> wrote:

> Hello David,
> 
> Tuesday, April 24, 2007, 1:19:49 PM, you wrote:
> 
> >> sendfile function is not just a more efficient version of a read 
> >> followed by a write.  It reads from one fd and write to another at tha
> >> same time. Please try to read 2G, and then write 2G - and how much 
> >> memory you will be need and how much time you will loose while reading
> >> 2G from disk, but not writing them to socket.
> 
> DS> You are correct. What I meant to say was that it's just a
> DS> more efficient version of 'mmap'ing a file and then 'write'ing
> DS> from the 'mmap'. The 'write' to a non-blocking socket can still
> DS> 'block' on disk I/O.
> 
> How can I avoid that blocking? Or maybe another question - how can I
> deliver data from disk to network with minimal copy operations, etc.
> 

I believe the modern way would be to use splice() system call :

loop
 splice(from disk , to pipe) with SPLICE_F_NONBLOCK
 wait_event_from_epoll (pipe ready for reading)
 splice(from pipe, to socket)
 wait_event_from_epoll (socket ready for writing)

But :

1) I am not sure epoll can get an event when page(s) is/are ready in pipe (ie disk delivered the page(s) to cache)
2) I am not sure splice() to socket is actually implemented with 0-copy
3) I am not sure pipe capacity (16 pages) would be enough to get a good readahead.

Eric



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ