int max_threads;
unsigned long total_forks; /* Handle normal Linux uptimes. */
+
+/*
+ * Protects next_safe, last_pid and pid_max:
+ */
+spinlock_t lastpid_lock = SPIN_LOCK_UNLOCKED;
+
+static int next_safe = DEFAULT_PID_MAX;
+int pid_max = DEFAULT_PID_MAX;
int last_pid;
struct task_struct *pidhash[PIDHASH_SZ];
return tsk;
}
-spinlock_t lastpid_lock = SPIN_LOCK_UNLOCKED;
-
static int get_pid(unsigned long flags)
{
- static int next_safe = PID_MAX;
struct task_struct *p;
int pid;
return 0;
spin_lock(&lastpid_lock);
- if((++last_pid) & ~PID_MASK) {
+ if (++last_pid > pid_max) {
last_pid = 300; /* Skip daemons etc. */
goto inside;
}
- if(last_pid >= next_safe) {
+
+ if (last_pid >= next_safe) {
inside:
- next_safe = PID_MAX;
+ next_safe = pid_max;
read_lock(&tasklist_lock);
repeat:
for_each_task(p) {
- if(p->pid == last_pid ||
+ if (p->pid == last_pid ||
p->pgrp == last_pid ||
p->tgid == last_pid ||
p->session == last_pid) {
- if(++last_pid >= next_safe) {
- if(last_pid & ~PID_MASK)
+ if (++last_pid >= next_safe) {
+ if (last_pid >= pid_max)
last_pid = 300;
- next_safe = PID_MAX;
+ next_safe = pid_max;
}
goto repeat;
}
- if(p->pid > last_pid && next_safe > p->pid)
+ if (p->pid > last_pid && next_safe > p->pid)
next_safe = p->pid;
- if(p->pgrp > last_pid && next_safe > p->pgrp)
+ if (p->pgrp > last_pid && next_safe > p->pgrp)
next_safe = p->pgrp;
- if(p->tgid > last_pid && next_safe > p->tgid)
+ if (p->tgid > last_pid && next_safe > p->tgid)
next_safe = p->tgid;
- if(p->session > last_pid && next_safe > p->session)
+ if (p->session > last_pid && next_safe > p->session)
next_safe = p->session;
}
read_unlock(&tasklist_lock);
extern int sysrq_enabled;
extern int core_uses_pid;
extern int cad_pid;
+extern int pid_max;
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
{KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug",
&sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec},
#endif
+ {KERN_PIDMAX, "pid_max", &pid_max, sizeof (int),
+ 0600, NULL, &proc_dointvec},
{0}
};