From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751605AbXB0JPp (ORCPT ); Tue, 27 Feb 2007 04:15:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161068AbXB0JPp (ORCPT ); Tue, 27 Feb 2007 04:15:45 -0500 Received: from pfx2.jmh.fr ([194.153.89.55]:38221 "EHLO pfx2.jmh.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751605AbXB0JPn (ORCPT ); Tue, 27 Feb 2007 04:15:43 -0500 From: Eric Dumazet To: Davide Libenzi Subject: Re: [patch] epoll reduced (to 1) number of passes over the ready set ... Date: Tue, 27 Feb 2007 10:15:33 +0100 User-Agent: KMail/1.9.5 Cc: Linux Kernel Mailing List , Linus Torvalds , Andrew Morton References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200702271015.33123.dada1@cosmosbay.com> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 27 February 2007 03:32, Davide Libenzi wrote: > Epoll is doing multiple passes over the ready set at the moment, because > of the constraints over the f_op->poll() call. Looking at the code again, > I noticed that we already hold the epoll semaphore in read, and this > (together with other locking conditions that hold while doing an > epoll_wait()) can lead to a smarter way to "ship" events to userspace (in > a single pass). I added more (even) more comments to the code to explain > the conditions why certain operations are safe. > This is a stress application that can be used to test the new code. It > spwans multiple thread and call epoll_wait() and epoll_ctl() from many > threads. Stress tested on my dual Opteron 254 w/out any problems. Davide, This is really cool, because the size of epitem would fit now in 128 bytes instead of 192 (on x86_64 platforms). So we also reduce memory usage. I have one comment : > */ > - list_for_each(lnk, txlist) { > - epi = list_entry(lnk, struct epitem, txlink); > + for (eventcnt = 0; !list_empty(txlist) && eventcnt < maxevents;) { > + epi = list_entry(txlist->next, struct epitem, rdllink); Now that we scan the rdllist list once, it may be usefull to use a prefetch() hint. list_for_each() has one prefetch(pos->next) automatically included, but not your open coded loop. I suggest adding after epi = list_entry(txlist->next, struct epitem, rdllink); prefetch(epi->rdllink.next); Thank you