public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andi Kleen <ak@suse.de>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [RFC] Optimize select/poll by putting small data sets on the stack
Date: Wed, 04 Jan 2006 00:07:19 +0100	[thread overview]
Message-ID: <43BB03A7.3090604@cosmosbay.com> (raw)
In-Reply-To: <43BAF72C.2030608@cosmosbay.com>

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

Eric Dumazet a écrit :
> Andi Kleen a écrit :
>> This is a RFC for now. I would be interested in testing
>> feedback. Patch is for 2.6.15.
>>
>> Optimize select and poll by a using stack space for small fd sets
>>
>> This brings back an old optimization from Linux 2.0. Using
>> the stack is faster than kmalloc. On a Intel P4 system
>> it speeds up a select of a single pty fd by about 13%
>> (~4000 cycles -> ~3500)
> 
> Was this result on UP or SMP kernel ? Preempt or not ?
> 
> I think we might play in do_pollfd() and use fget_light()/fput_light() 
> instead of fget()/fput() that are somewhat expensive because of atomic 
> inc/dec on SMP.
> 

Just for completeness I include this patch against 2.6.15



[-- Attachment #2: select_fget_light.patch --]
[-- Type: text/plain, Size: 1165 bytes --]

--- linux-2.6.15/fs/select.c	2006-01-03 04:21:10.000000000 +0100
+++ linux-2.6.15-ed/fs/select.c	2006-01-04 00:04:10.000000000 +0100
@@ -221,17 +221,18 @@
 			}
 
 			for (j = 0; j < __NFDBITS; ++j, ++i, bit <<= 1) {
+				int fput_needed;
 				if (i >= n)
 					break;
 				if (!(bit & all_bits))
 					continue;
-				file = fget(i);
+				file = fget_light(i, &fput_needed);
 				if (file) {
 					f_op = file->f_op;
 					mask = DEFAULT_POLLMASK;
 					if (f_op && f_op->poll)
 						mask = (*f_op->poll)(file, retval ? NULL : wait);
-					fput(file);
+					fput_light(file, fput_needed);
 					if ((mask & POLLIN_SET) && (in & bit)) {
 						res_in |= bit;
 						retval++;
@@ -417,14 +418,15 @@
 		fdp = fdpage+i;
 		fd = fdp->fd;
 		if (fd >= 0) {
-			struct file * file = fget(fd);
+			int fput_needed;
+			struct file * file = fget_light(fd, &fput_needed);
 			mask = POLLNVAL;
 			if (file != NULL) {
 				mask = DEFAULT_POLLMASK;
 				if (file->f_op && file->f_op->poll)
 					mask = file->f_op->poll(file, *pwait);
 				mask &= fdp->events | POLLERR | POLLHUP;
-				fput(file);
+				fput_light(file, fput_needed);
 			}
 			if (mask) {
 				*pwait = NULL;

  parent reply	other threads:[~2006-01-03 23:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-03 20:58 [PATCH] [RFC] Optimize select/poll by putting small data sets on the stack Andi Kleen
2006-01-03 22:14 ` Eric Dumazet
2006-01-03 23:05   ` Andi Kleen
2006-01-03 23:07   ` Eric Dumazet [this message]
2006-01-03 23:13     ` Andi Kleen
2006-01-03 22:22 ` Jesper Juhl
2006-01-03 23:07   ` Andi Kleen
2006-01-04  0:28 ` Arnd Bergmann
2006-01-04  0:33   ` Andi Kleen
2006-01-04  0:43   ` Eric Dumazet
2006-01-04  0:48     ` Andi Kleen

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=43BB03A7.3090604@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=ak@suse.de \
    --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