public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Silvio Cesare <silvio@qualys.com>
To: linux-kernel@vger.kernel.org
Cc: silvio@qualys.com
Subject: fs/select.c [patch > to >=]
Date: Tue, 20 Aug 2002 18:00:29 -0700	[thread overview]
Message-ID: <20020820180029.A17387@localhost.localdomain> (raw)

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

fs/select.c (from 2.4.19 but present in 2.5.x also)

asmlinkage long sys_poll(struct pollfd * ufds, unsigned int nfds, long timeout)
{
        int i, j, fdcount, err;
        struct pollfd **fds;
        poll_table table, *wait;
        int nchunks, nleft;

[ skip ]

        nchunks = 0;
        nleft = nfds;
        while (nleft > POLLFD_PER_PAGE) { /* allocate complete PAGE_SIZE chunks
*/
                fds[nchunks] = (struct pollfd *)__get_free_page(GFP_KERNEL);
                if (fds[nchunks] == NULL)
                        goto out_fds;
                nchunks++;
                nleft -= POLLFD_PER_PAGE;
        }
        if (nleft) { /* allocate last PAGE_SIZE chunk, only nleft elements used
*/

why not -->

        while (nleft >= POLLFD_PER_PAGE) {

in this case we will use only nchunks in the case that this will end up
page aligned..  the current way of using only > POLLFD_PER_PAGE will
end up with nchunks, and nleft == PAGE_SIZE / sizeof(pollfd) etc..

silly optimisation by changing > to >=, but still an optimisation.. if there
is something obviously wrong with changing > to >=, ignore me since I
probably should get more sleep.. but I dont see any problem though I havent
really looked at it too much.

attachment has 1 line (1 character) patch ;-)

--
Silvio


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

diff -u fs/select.c.2.4.19 fs/select.c 
--- fs/select.c.2.4.19	Tue Aug 20 17:51:48 2002
+++ fs/select.c	Tue Aug 20 17:52:15 2002
@@ -445,7 +445,7 @@
 
 	nchunks = 0;
 	nleft = nfds;
-	while (nleft > POLLFD_PER_PAGE) { /* allocate complete PAGE_SIZE chunks */
+	while (nleft >= POLLFD_PER_PAGE) { /* allocate complete PAGE_SIZE chunks */
 		fds[nchunks] = (struct pollfd *)__get_free_page(GFP_KERNEL);
 		if (fds[nchunks] == NULL)
 			goto out_fds;

                 reply	other threads:[~2002-08-21  1:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20020820180029.A17387@localhost.localdomain \
    --to=silvio@qualys.com \
    --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