public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org,
	Davide Libenzi <davidel@xmailserver.org>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [RFC v2] epoll: avoid spinlock contention with wfcqueue
Date: Mon, 18 Mar 2013 20:20:18 +0000	[thread overview]
Message-ID: <20130318202018.GA17114@dcvr.yhbt.net> (raw)
In-Reply-To: <20130318173237.GB8798@dcvr.yhbt.net>

Eric Wong <normalperson@yhbt.net> wrote:
> Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
> > I'm also not entirely sure why you need to add enum epoll_item_state
> > along with expensive atomic ops to compute the state.  Wouldn't it be
> > enough to know in which queue the nodes are located ? If need be, you
> > could add new queues, e.g. one per state. So instead of marking states,
> > you would simply re-enqueue the nodes into per-state queues. This would
> > simplify zombie management and save a couple of brains in the process. ;-)
> 
> Is there a quick way to know which queue the node is located?
> 
> ep_enqueue may fire from several places at once (ep_poll_callback,
> ep_insert/ep_modify) so I think guarding it with something (currently
> ep_mark_ready) is required.  We used to use ep->lock to protect all the
> "if (!ep_is_linked) list_add_tail" calls, too.

I now think the EP_STATE_DEQUEUE state (and associated loop) is
unnecessary.  I only had it for the EPOLLET case.

Safe usage of EPOLLET requires hitting EAGAIN before expecting an event
anyways (as documented by epoll(7)).  So the potential of "losing" an
event while it is being sent to userspace existed before, and it still
exists now.  For an app which uses EPOLLET improperly (by not relying on
EAGAIN), the window for "losing" an event is slightly larger, but
probably still too small to matter...

This change wouldn't affect level-trigger (most epoll users, I think)
nor EPOLLONESHOT users.  Hopefully I'll be able to test more, soon.

  reply	other threads:[~2013-03-18 20:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14  4:42 [RFC] epoll: avoid spinlock contention with wfcqueue Eric Wong
2013-03-14 13:31 ` Mathieu Desnoyers
2013-03-18 11:07 ` [RFC v2] " Eric Wong
2013-03-18 13:06   ` Mathieu Desnoyers
2013-03-18 17:32     ` Eric Wong
2013-03-18 20:20       ` Eric Wong [this message]
2013-03-18 20:31       ` Mathieu Desnoyers
2013-05-07 20:09       ` Mathieu Desnoyers

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=20130318202018.GA17114@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=akpm@linux-foundation.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=viro@ZenIV.linux.org.uk \
    /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