All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Gordon Oliver <gordo@pincoya.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] /dev/epoll update ...
Date: Sun, 23 Sep 2001 17:33:11 -0700 (PDT)	[thread overview]
Message-ID: <XFMail.20010923173311.davidel@xmailserver.org> (raw)
In-Reply-To: <20010923171145.A15109@furble>


On 24-Sep-2001 Gordon Oliver wrote:
> On 2001.09.20 10:18 Davide Libenzi wrote:
>> If you need to request the current status of a socket you've to
>> f_ops->poll the fd.
>> The cost of the extra read, done only for fds that are not "ready", is
>> nothing
>> compared to the cost of a linear scan with HUGE numbers of fds.
>> You could implement a solution where the low level io functions goes
>> directly to write
>> inside the mmapped fd set where the data buffer is empty or the out
>> buffer is full.
>> This would be a way more intrusive patch whose perf gain won't match the
>> cost.
> 
> But you missed the obvious optimization of doing an f_ops->poll when
> the file is _added_. This means that you'll get an initial event when
> there is data ready. This means you still never do a scan (only check
> when an fd is added), but you don't have to do an empty read every time
> you add an fd.
> 

Why is it so diffucult to understand that /dev/epoll is an "state change" interface.
Even if you add an event at fd insert time this DOES NOT transform /dev/epoll
in a "state monitor" interface.
That means that you can't use code like this :

        if (readable(fd))
                read();

that is common to "state monitor" interfaces.
The code prototype for "state change" interfaces is like :

        while (read() == FAIL)
                wait(READ_EVENT);

Suppose you transform this in a code like this :

int my_smart_read() {
        if (wait(READ_EVENT))
                read();
}

and a packet with 1000 bytes lands onto the terminal.
If you call my_smart_read() and you read 666 bytes the next
time you're going to call my_smart_read() you get stuck.
This coz /dev/epoll catch terminal "state change" events by design.
You could say, "but i want the terminal state to be reported" and
i say "use select()/poll()//dev/poll".


> Before you argue that this does not save a system call, it will in
> the typical case of:
>    <add fd>
>    <fail read>
>    <wait on events>
>    <successful read>
> 
> Note that it has the additional advantage of making the dispatch code
> in the user application easier. You no longer have to do special code
> to handle the speculative read after adding the fd.

You've to use speculative read()/write() coz these are going to change
( rx buffer empty, tx buffer full ) the state of the terminal without
which you'll never receive nexts state change events.
Please look at the code the uses rt signals and if you don't like it
i guess you'll never love /dev/epoll.





- Davide


  reply	other threads:[~2001-09-24  0:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-19  2:20 [PATCH] /dev/epoll update Dan Kegel
2001-09-19  6:25 ` Dan Kegel
2001-09-19  7:04 ` Christopher K. St. John
2001-09-19 15:37   ` Dan Kegel
2001-09-19 15:59     ` Zach Brown
2001-09-19 17:12     ` Christopher K. St. John
2001-09-19 17:39     ` Davide Libenzi
2001-09-19 18:26     ` Alan Cox
2001-09-19 17:25   ` Davide Libenzi
2001-09-19 19:03     ` Christopher K. St. John
2001-09-19 19:30       ` Davide Libenzi
2001-09-19 21:49         ` Christopher K. St. John
2001-09-19 22:11           ` Davide Libenzi
2001-09-19 23:24             ` Christopher K. St. John
2001-09-19 23:52               ` Davide Libenzi
2001-09-20  2:13             ` Dan Kegel
2001-09-20  2:28               ` Davide Libenzi
2001-09-20  3:03                 ` Dan Kegel
2001-09-20 16:58                   ` Davide Libenzi
2001-09-20  4:32                 ` Christopher K. St. John
2001-09-20  4:43                   ` Christopher K. St. John
2001-09-20  5:05                     ` Benjamin LaHaise
2001-09-20 18:25                       ` Davide Libenzi
2001-09-20 19:33                         ` Benjamin LaHaise
2001-09-20 19:58                           ` Davide Libenzi
2001-09-20 17:18                   ` Davide Libenzi
2001-09-24  0:11                     ` Gordon Oliver
2001-09-24  0:33                       ` Davide Libenzi [this message]
2001-09-24 19:23                     ` Eric W. Biederman
2001-09-24 20:04                       ` Davide Libenzi
2001-09-21  5:59             ` Ton Hospel
2001-09-21 16:48               ` Davide Libenzi
2001-09-19 17:21 ` Davide Libenzi
  -- strict thread matches above, loose matches on Subject: below --
2002-03-20  3:49 [patch] " Davide Libenzi
     [not found] <local.mail.linux-kernel/3BB03C6A.7D1DD7B3@kegel.com>
     [not found] ` <local.mail.linux-kernel/3BAEB39B.DE7932CF@kegel.com>
     [not found]   ` <local.mail.linux-kernel/3BAF83EF.C8018E45@distributopia.com>
2001-09-25 17:36     ` [PATCH] " Jonathan Lemon
2001-09-25 18:34       ` Dan Kegel
2001-09-24  4:16 Dan Kegel
2001-09-24 19:11 ` Eric W. Biederman
2001-09-24 19:34   ` Jamie Lokier
2001-09-24 20:09     ` Davide Libenzi
2001-09-24 21:56       ` Jamie Lokier
2001-09-24 22:08         ` Davide Libenzi
2001-09-24 22:09           ` Jamie Lokier
2001-09-24 22:20             ` Davide Libenzi
2001-09-24 22:21               ` Jamie Lokier
2001-09-24 22:30                 ` Davide Libenzi
2001-09-25  9:25             ` Dan Kegel
     [not found] ` <3BAF83EF.C8018E45@distributopia.com>
2001-09-25  8:12   ` Dan Kegel
2001-09-21  6:22 Dan Kegel
2001-09-21 18:45 ` Davide Libenzi
2001-09-07 19:27 Davide Libenzi

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=XFMail.20010923173311.davidel@xmailserver.org \
    --to=davidel@xmailserver.org \
    --cc=gordo@pincoya.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.