From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: "David S. Miller" <davem@redhat.com>, <zaitcev@redhat.com>,
Oleg Drokin <green@namesys.com>, <linux-kernel@vger.kernel.org>
Subject: [patch] pidhash-2.5.38-A0
Date: Wed, 25 Sep 2002 10:48:49 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.44.0209251047040.5857-100000@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0209251024580.4690-100000@localhost.localdomain>
the attached patch removes the cmpxchg from the PID allocator and replaces
it with a spinlock. This spinlock is hit only a couple of times per
bootup, so it's not a performance issue.
Ingo
--- linux/kernel/pid.c.orig Wed Sep 25 10:36:13 2002
+++ linux/kernel/pid.c Wed Sep 25 10:38:55 2002
@@ -53,6 +53,8 @@
static pidmap_t *map_limit = pidmap_array + PIDMAP_ENTRIES;
+static spinlock_t pidmap_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
+
inline void free_pidmap(int pid)
{
pidmap_t *map = pidmap_array + pid / BITS_PER_PAGE;
@@ -77,8 +79,13 @@
* Free the page if someone raced with us
* installing it:
*/
- if (cmpxchg(&map->page, NULL, (void *) page))
+ spin_lock(&pidmap_lock);
+ if (map->page)
free_page(page);
+ else
+ map->page = (void *)page;
+ spin_unlock(&pidmap_lock);
+
if (!map->page)
break;
}
next prev parent reply other threads:[~2002-09-25 8:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-25 5:00 cmpxchg in 2.5.38 Pete Zaitcev
2002-09-25 4:54 ` David S. Miller
2002-09-25 7:18 ` Oleg Drokin
2002-09-25 7:47 ` David S. Miller
2002-09-25 8:07 ` Oleg Drokin
2002-09-25 8:26 ` Ingo Molnar
2002-09-25 8:48 ` Ingo Molnar [this message]
2002-09-25 12:04 ` Geert Uytterhoeven
2002-09-25 17:42 ` Pete Zaitcev
2002-09-25 19:34 ` Ingo Molnar
2002-09-25 20:03 ` David S. Miller
2002-09-25 18:59 ` David S. Miller
2002-09-25 19:02 ` David S. Miller
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=Pine.LNX.4.44.0209251047040.5857-100000@localhost.localdomain \
--to=mingo@elte.hu \
--cc=davem@redhat.com \
--cc=green@namesys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
--cc=zaitcev@redhat.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;
as well as URLs for NNTP newsgroup(s).