* RFC: poll change
@ 2001-08-14 21:08 Tim Hockin
2001-08-14 21:43 ` David S. Miller
2001-08-14 22:03 ` RFC: poll change - nevermind Tim Hockin
0 siblings, 2 replies; 11+ messages in thread
From: Tim Hockin @ 2001-08-14 21:08 UTC (permalink / raw)
To: Linux Kernel Mailing List
hey all, I have a request from someone to investigate this.
poll() currently does not allow you to pass more fd's than you have open.
At first this seems reasonable. However, I have seen now at least one app
that takes advantage of a behavior found on some poll() implementations (I
don't have the standard available..).
On these systems, you may pass in as many fds as you want, and any
structure with the fd member set to < 0 is ignored. This allows apps to
save on allocating and re-allocating, or sorting the fd arrays.
What would the feeling be if I implemented this for Linux?
Tim
--
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change
2001-08-14 21:08 RFC: poll change Tim Hockin
@ 2001-08-14 21:43 ` David S. Miller
2001-08-14 22:38 ` Herbert Xu
2001-08-14 22:03 ` RFC: poll change - nevermind Tim Hockin
1 sibling, 1 reply; 11+ messages in thread
From: David S. Miller @ 2001-08-14 21:43 UTC (permalink / raw)
To: thockin; +Cc: linux-kernel
From: Tim Hockin <thockin@sun.com>
Date: Tue, 14 Aug 2001 14:08:40 -0700
poll() currently does not allow you to pass more fd's than you have open.
Tim, please check the latest sources, this has been fixed
in 2.4.x for several months.
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change
2001-08-14 21:43 ` David S. Miller
@ 2001-08-14 22:38 ` Herbert Xu
2001-08-14 22:42 ` David S. Miller
0 siblings, 1 reply; 11+ messages in thread
From: Herbert Xu @ 2001-08-14 22:38 UTC (permalink / raw)
To: David S. Miller, linux-kernel
David S. Miller <davem@redhat.com> wrote:
> From: Tim Hockin <thockin@sun.com>
> Date: Tue, 14 Aug 2001 14:08:40 -0700
> poll() currently does not allow you to pass more fd's than you have open.
> Tim, please check the latest sources, this has been fixed
> in 2.4.x for several months.
Hmm, it still seems to be wrong:
/* Do a sanity check on nfds ... */
if (nfds > NR_OPEN)
return -EINVAL;
if (nfds > current->files->max_fds)
nfds = current->files->max_fds;
The second if statement should be removed. And it might be better to use
current->rlim[RLIMIT_NOFILE].rlim_cur instead of NR_OPEN.
--
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: RFC: poll change
2001-08-14 22:38 ` Herbert Xu
@ 2001-08-14 22:42 ` David S. Miller
2001-08-15 0:03 ` Andrea Arcangeli
2001-08-15 10:40 ` David Schwartz
0 siblings, 2 replies; 11+ messages in thread
From: David S. Miller @ 2001-08-14 22:42 UTC (permalink / raw)
To: herbert; +Cc: linux-kernel
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Wed, 15 Aug 2001 08:38:02 +1000
Hmm, it still seems to be wrong:
...
if (nfds > current->files->max_fds)
nfds = current->files->max_fds;
The second if statement should be removed. And it might be better to use
current->rlim[RLIMIT_NOFILE].rlim_cur instead of NR_OPEN.
It has to be limited to "max_fds", that is how many files we may
legally address in current->files!
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: RFC: poll change
2001-08-14 22:42 ` David S. Miller
@ 2001-08-15 0:03 ` Andrea Arcangeli
2001-08-15 0:06 ` David S. Miller
2001-08-15 10:40 ` David Schwartz
1 sibling, 1 reply; 11+ messages in thread
From: Andrea Arcangeli @ 2001-08-15 0:03 UTC (permalink / raw)
To: David S. Miller; +Cc: herbert, linux-kernel
On Tue, Aug 14, 2001 at 03:42:33PM -0700, David S. Miller wrote:
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Date: Wed, 15 Aug 2001 08:38:02 +1000
>
> Hmm, it still seems to be wrong:
> ...
>
> if (nfds > current->files->max_fds)
> nfds = current->files->max_fds;
>
> The second if statement should be removed. And it might be better to use
> current->rlim[RLIMIT_NOFILE].rlim_cur instead of NR_OPEN.
>
> It has to be limited to "max_fds", that is how many files we may
> legally address in current->files!
current->files only matters for the contents of the pollfd struct, not
for the number of pollfd structures passed on, removing such two lines
shouldn't destabilize anything, I think it's just a matter of API,
reading SuS it seems not to imply we have to truncate it to the max_fds
but OTOH the feedback I had was just happy with the 2.4 fix (so I didn't
even checked if the 2.4 fix was fully compliant or not..).
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change
2001-08-15 0:03 ` Andrea Arcangeli
@ 2001-08-15 0:06 ` David S. Miller
2001-08-15 0:16 ` Andrea Arcangeli
0 siblings, 1 reply; 11+ messages in thread
From: David S. Miller @ 2001-08-15 0:06 UTC (permalink / raw)
To: andrea; +Cc: herbert, linux-kernel
From: Andrea Arcangeli <andrea@suse.de>
Date: Wed, 15 Aug 2001 02:03:03 +0200
but OTOH the feedback I had was just happy with the 2.4 fix (so I didn't
even checked if the 2.4 fix was fully compliant or not..).
This is why I'm saying there is no practical reason to make
this change.
The current code can actually improve performance, avoiding needlessly
scanning fd==-1 entries.
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change
2001-08-15 0:06 ` David S. Miller
@ 2001-08-15 0:16 ` Andrea Arcangeli
2001-08-15 0:23 ` David S. Miller
0 siblings, 1 reply; 11+ messages in thread
From: Andrea Arcangeli @ 2001-08-15 0:16 UTC (permalink / raw)
To: David S. Miller; +Cc: herbert, linux-kernel
On Tue, Aug 14, 2001 at 05:06:20PM -0700, David S. Miller wrote:
> From: Andrea Arcangeli <andrea@suse.de>
> Date: Wed, 15 Aug 2001 02:03:03 +0200
>
> but OTOH the feedback I had was just happy with the 2.4 fix (so I didn't
> even checked if the 2.4 fix was fully compliant or not..).
>
> This is why I'm saying there is no practical reason to make
> this change.
Probably there isn't pratical reason agreed.
> The current code can actually improve performance, avoiding needlessly
> scanning fd==-1 entries.
you assume the entries above max_fds are set to -1, while strictly
speaking they don't need to.
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change
2001-08-15 0:16 ` Andrea Arcangeli
@ 2001-08-15 0:23 ` David S. Miller
0 siblings, 0 replies; 11+ messages in thread
From: David S. Miller @ 2001-08-15 0:23 UTC (permalink / raw)
To: andrea; +Cc: herbert, linux-kernel
From: Andrea Arcangeli <andrea@suse.de>
Date: Wed, 15 Aug 2001 02:16:48 +0200
> The current code can actually improve performance, avoiding needlessly
> scanning fd==-1 entries.
you assume the entries above max_fds are set to -1, while strictly
speaking they don't need to.
Right, this was my core misunderstanding, see my most
recent mail.
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: RFC: poll change
2001-08-14 22:42 ` David S. Miller
2001-08-15 0:03 ` Andrea Arcangeli
@ 2001-08-15 10:40 ` David Schwartz
1 sibling, 0 replies; 11+ messages in thread
From: David Schwartz @ 2001-08-15 10:40 UTC (permalink / raw)
To: linux-kernel
> From: Herbert Xu <herbert@gondor.apana.org.au>
> Date: Wed, 15 Aug 2001 08:38:02 +1000
>
> Hmm, it still seems to be wrong:
> ...
>
> if (nfds > current->files->max_fds)
> nfds = current->files->max_fds;
>
> The second if statement should be removed. And it might be
> better to use
> current->rlim[RLIMIT_NOFILE].rlim_cur instead of NR_OPEN.
>
> It has to be limited to "max_fds", that is how many files we may
> legally address in current->files!
Though stupid, I believe it is perfectly legal to, say, have one socket
open and poll for it with two separate entries, one checking readability and
one checking writability.
DS
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: RFC: poll change - nevermind
2001-08-14 21:08 RFC: poll change Tim Hockin
2001-08-14 21:43 ` David S. Miller
@ 2001-08-14 22:03 ` Tim Hockin
2001-08-14 22:47 ` Andrea Arcangeli
1 sibling, 1 reply; 11+ messages in thread
From: Tim Hockin @ 2001-08-14 22:03 UTC (permalink / raw)
To: Linux Kernel Mailing List
Tim Hockin wrote:
> poll() currently does not allow you to pass more fd's than you have
I'll shut up - I was looking at 2.2.x source.
--
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2001-08-15 10:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-14 21:08 RFC: poll change Tim Hockin
2001-08-14 21:43 ` David S. Miller
2001-08-14 22:38 ` Herbert Xu
2001-08-14 22:42 ` David S. Miller
2001-08-15 0:03 ` Andrea Arcangeli
2001-08-15 0:06 ` David S. Miller
2001-08-15 0:16 ` Andrea Arcangeli
2001-08-15 0:23 ` David S. Miller
2001-08-15 10:40 ` David Schwartz
2001-08-14 22:03 ` RFC: poll change - nevermind Tim Hockin
2001-08-14 22:47 ` Andrea Arcangeli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox