From: "Raphael S.Carvalho" <raphael.scarv@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Serge Hallyn <serge.hallyn@canonical.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Eric W. Biederman" <ebiederm@xmission.com>
Cc: linux-kernel@vger.kernel.org,
"Raphael S.Carvalho" <raphael.scarv@gmail.com>
Subject: [PATCH 1/1] kernel/pid.c: Improve flow of a loop inside alloc_pidmap.
Date: Fri, 8 Mar 2013 20:07:47 -0300 [thread overview]
Message-ID: <1362784067-15537-1-git-send-email-raphael.scarv@gmail.com> (raw)
Notes: find_next_offset searches for an available "cleaned bit"
in the respective pid bitmap (page), so returns the offset if found,
otherwise it returns a value equals to BITS_PER_PAGE (invalid offset).
For example, suppose find_next_offset didn't find any available
bit, so there's no purpose to call mk_pid (Wasteful Cpu Cycles)
since it only computes a new PID based on a *valid* offset of
the current map.
Therefore, I found it could be better to call mk_pid after
the checking (offset < BITS_PER_PAGE) returned sucessfully!
Signed-off-by: Raphael S.Carvalho <raphael.scarv@gmail.com>
---
kernel/pid.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index 047dc62..7ecb09a 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -190,8 +190,8 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
return pid;
}
offset = find_next_offset(map, offset);
- pid = mk_pid(pid_ns, map, offset);
- } while (offset < BITS_PER_PAGE && pid < pid_max);
+ } while (offset < BITS_PER_PAGE &&
+ (pid = mk_pid(pid_ns, map, offset)) < pid_max);
}
if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
++map;
--
1.7.2.5
next reply other threads:[~2013-03-08 23:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-08 23:07 Raphael S.Carvalho [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-03-11 21:18 [PATCH 1/1] kernel/pid.c: Improve flow of a loop inside alloc_pidmap Raphael S. Carvalho
2013-03-11 21:57 ` Andrew Morton
2013-03-11 22:01 ` Raphael S Carvalho
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=1362784067-15537-1-git-send-email-raphael.scarv@gmail.com \
--to=raphael.scarv@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=serge.hallyn@canonical.com \
--cc=serge@hallyn.com \
/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