From: Paul Larson <plars@linuxtestproject.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@transmeta.com>,
lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] pid_max hang again...
Date: 06 Sep 2002 12:43:15 -0500 [thread overview]
Message-ID: <1031334205.30394.14.camel@plars.austin.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0209061738330.24094-100000@localhost.localdomain>
On Fri, 2002-09-06 at 10:39, Ingo Molnar wrote:
> On 6 Sep 2002, Paul Larson wrote:
> > It looks like this change dropped us back to the same error all this was
> > originally supposed to fix. When you hit PID_MAX, get_pid() starts
> > looping forever looking for a free pid and hangs. I could probably make
> > my original fix work on this very easily if you'd like.
>
> yes please send a patch for this. Reintroduction of the looping bug was
> unintended.
Here's the original one without all the bitmap stuff, JUST the fix for
the hang problem plain and simple. It should apply cleanly against the
current bk. The only other small bit in here moves the test for flags &
CLONE_IDLETASK outside of get_pid since we can skip the unnecessary call
to get_pid if it's true. Except for the last part, this is the same
thing I put into 2.4 some time ago.
Please comment or apply.
Thanks,
Paul Larson
diff -Nru a/kernel/fork.c b/kernel/fork.c
--- a/kernel/fork.c Fri Sep 6 20:19:21 2002
+++ b/kernel/fork.c Fri Sep 6 20:19:21 2002
@@ -28,6 +28,7 @@
#include <linux/security.h>
#include <linux/futex.h>
#include <linux/ptrace.h>
+#include <linux/compiler.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -162,12 +163,10 @@
static int get_pid(unsigned long flags)
{
struct task_struct *p;
- int pid;
-
- if (flags & CLONE_IDLETASK)
- return 0;
+ int pid, beginpid;
spin_lock(&lastpid_lock);
+ beginpid = last_pid;
if (++last_pid > pid_max) {
last_pid = 300; /* Skip daemons etc. */
goto inside;
@@ -188,6 +187,8 @@
last_pid = 300;
next_safe = pid_max;
}
+ if (unlikely(last_pid == beginpid))
+ goto nomorepids;
goto repeat;
}
if (p->pid > last_pid && next_safe > p->pid)
@@ -205,6 +206,11 @@
spin_unlock(&lastpid_lock);
return pid;
+
+nomorepids:
+ read_unlock(&tasklist_lock);
+ spin_unlock(&lastpid_lock);
+ return 0;
}
static inline int dup_mmap(struct mm_struct * mm)
@@ -707,7 +713,13 @@
p->state = TASK_UNINTERRUPTIBLE;
copy_flags(clone_flags, p);
- p->pid = get_pid(clone_flags);
+ if (clone_flags & CLONE_IDLETASK)
+ p->pid = 0;
+ else {
+ p->pid = get_pid(clone_flags);
+ if (p->pid == 0)
+ goto bad_fork_cleanup;
+ }
p->proc_dentry = NULL;
INIT_LIST_HEAD(&p->run_list);
next prev parent reply other threads:[~2002-09-06 17:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-06 13:52 Paul Larson
2002-09-06 15:39 ` Ingo Molnar
2002-09-06 15:47 ` Paul Larson
2002-09-06 17:43 ` Paul Larson [this message]
2002-09-06 21:06 [PATCH] " Manfred Spraul
2002-09-07 8:16 Hanumanthu. H
2002-09-07 9:06 Manfred Spraul
2002-09-09 14:22 ` Hanumanthu. H
2002-09-09 15:07 ` Martin J. Bligh
2002-09-09 22:39 ` jw schultz
2002-09-10 9:54 ` Andries Brouwer
2002-09-10 19:29 ` jw schultz
2002-09-11 8:59 Hanumanthu. H
2002-09-11 17:19 ` Andries Brouwer
2002-09-11 20:23 ` jw schultz
2002-09-12 1:11 ` Rik van Riel
2002-09-12 1:54 ` Andrew Morton
2002-09-12 20:23 ` Andries Brouwer
2002-09-12 21:17 ` Rik van Riel
2002-09-12 21:21 ` yodaiken
2002-09-13 5:47 ` Hanumanthu. H
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=1031334205.30394.14.camel@plars.austin.ibm.com \
--to=plars@linuxtestproject.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@transmeta.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
all inboxes | Powered by JetHome®