public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolai ZHUBR <zhubr@mail.ru>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re[2]: epoll'ing tcp sockets for reading
Date: Sun, 20 Dec 2009 01:38:54 +0300	[thread overview]
Message-ID: <203216314.20091220013854@mail.ru> (raw)
In-Reply-To: <alpine.DEB.2.00.0912190953160.4482@makko.or.mcafeemobile.com>

Saturday, December 19, 2009, 9:07:05 PM, Davide Libenzi wrote:
> On Sat, 19 Dec 2009, Nikolai ZHUBR wrote:

>> Hello people, I have a question about epoll'ing tcp sockets.
>> 
>> Is it possible (with epoll or some other good method) to get userspace
>> notified not only of the fact that some data has become available
>> for the socket, but also of the respective _size_ available for
>> reading connected with this exact event?
>> 
>> Yes, read'ing until EAGAIN or using FIONREAD would provide this
>> sort of information, but there is a problem. In case of subsequent
>> continuous data arrival, an application could get stuck reading
>> data for one socket infinitely (after epoll return, just before
>> the next epoll), unless it implements some kind of artifical safety
>> measures.

> It is up to your application to handle data arrival correctly, according 
> to the latency/throughput constraints of your software.
> The "read until EAGAIN" that is cited inside the epoll man pages, does not 
> mean that you have to exhaust the data in one single event processing loop.
> After you have read and processed "enough data" (where enough depends on 
> the nature and constraints of your software), you can just drop that fd 
> into an "hot list" and pick the timeout for your next epoll_wait() 
> depending on the fact that such list is empty or not (you'd pick zero if 
> not empty). Proper handling of new and hot events will ensure that no 
> connections will be starving for service.

Well, no doubt, terrible starvation can be avoided this way, ok.
However doesn't this look like userspace code is forced to make decisions
(when to pause reading new data and proceed to other sockets etc.) based on
some rather abstract/imprecise/overcomplicated assumptions and/or with
the help of additional syscalls, while a simple and reasonable hint for
such a decision being wasted somewhere on the way from kernelspace to
userspace?

(Not that I had something better really; I'm just trying to find the best
approach and its limitations)

Thank you!

Nikolai ZHUBR

> - Davide



  reply	other threads:[~2009-12-19 22:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-19 12:02 epoll'ing tcp sockets for reading Nikolai ZHUBR
2009-12-19 18:07 ` Davide Libenzi
2009-12-19 22:38   ` Nikolai ZHUBR [this message]
2009-12-19 22:56     ` Re[2]: " Davide Libenzi
2009-12-20  0:26       ` Re[3]: " Nikolai ZHUBR
2009-12-20 15:54         ` Davide Libenzi
2009-12-20 16:14           ` Willy Tarreau
2009-12-20 23:26             ` Re[2]: " Nikolai ZHUBR
2009-12-21  5:46               ` Willy Tarreau
2009-12-21  9:34                 ` Re[2]: " Nikolai ZHUBR

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=203216314.20091220013854@mail.ru \
    --to=zhubr@mail.ru \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox