[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200611232249.56886.hhh@imada.sdu.dk>
Date: Thu, 23 Nov 2006 22:49:56 +0100
From: Hans Henrik Happe <hhh@...da.sdu.dk>
To: Ulrich Drepper <drepper@...hat.com>
Cc: Evgeniy Polyakov <johnpol@....mipt.ru>,
David Miller <davem@...emloft.net>,
Andrew Morton <akpm@...l.org>, netdev <netdev@...r.kernel.org>,
Zach Brown <zach.brown@...cle.com>,
Christoph Hellwig <hch@...radead.org>,
Chase Venters <chase.venters@...entec.com>,
Johann Borck <johann.borck@...sedata.com>,
linux-kernel@...r.kernel.org, Jeff Garzik <jeff@...zik.org>
Subject: Re: [take25 1/6] kevent: Description.
On Thursday 23 November 2006 21:00, Ulrich Drepper wrote:
> Evgeniy Polyakov wrote:
> > uidx is an index, starting from which there are unread entries. It is
> > updated by userspace when it commits entries, so it is 'consumer'
> > pointer, while kidx is an index where kernel will put new entries, i.e.
> > 'producer' index. We definitely need them both.
> > Userspace can only update (implicitly by calling kevent_commit()) uidx.
>
> Right, which is why exporting this entry is not needed. Keep the
> interface as small as possible.
>
> Userlevel has to maintain its own index. Just assume kevent_wait
> returns 10 new entries and you have multiple threads. In this case all
> threads take their turns and pick an entry from the ring buffer. This
> basically has to be done with something like this (I ignore wrap-arounds
> here to simplify the example):
>
> int getidx() {
> while (uidx < kidx)
> if (atomic_cmpxchg(uidx, uidx + 1, uidx) == 0)
> return uidx;
> return -1;
> }
I don't know if this falls under the simplification, but wouldn't there be a
race when reading/copying the event data? I guess this could be solved with
an extra user index.
--
Hans Henrik Happe
-
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