lkml.org 
[lkml]   [2000]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] large pid and a few other fixes
Below a patch with 31-bit pids and various compilation fixes.
The fork patch makes a fork measurably faster on a system
with more than 5000 processes.

I started making CONFIG_15BIT_PID a config option,
but decided against it as long as no need had been established.
(Yesterday or so I did a grep on "all Linux sources" for
msqid_ds and shmid_ds, more in particular msg_lspid, msg_lrpid,
shm_cpid, shm_lpid, and these are used in only a handful of places,
but I have not yet studied these places. Maybe it will turn out
to be necessary to have a config option after all, say for ibcs users,
we'll see. In case you like the opposite default, change the
#ifdef CONFIG_15BIT_PID
into
#if 1
or so, below in threads.h. (But as long as 2.4 has not been released
some testing is good, to see the effects of a larger pid.
Maybe someone will adapt ps.)

The other changes fix some compilation problems on Sparc,
and some miscellaneous warnings.

Andries



diff -u --recursive --new-file ../linux-2.3.40/linux/drivers/block/ide-geometry.c ./linux/drivers/block/ide-geometry.c
--- ../linux-2.3.40/linux/drivers/block/ide-geometry.c Fri Jan 21 14:28:07 2000
+++ ./linux/drivers/block/ide-geometry.c Fri Jan 21 14:30:03 2000
@@ -2,6 +2,8 @@
* linux/drivers/block/ide-geometry.c
*/
#include <linux/config.h>
+
+#ifdef CONFIG_BLK_DEV_IDE
#include <linux/ide.h>

#include <asm/io.h>
@@ -237,3 +239,4 @@
drive->bios_cyl, drive->bios_head, drive->bios_sect);
return ret;
}
+#endif /* CONFIG_BLK_DEV_IDE */
diff -u --recursive --new-file ../linux-2.3.40/linux/drivers/net/ppp_generic.c ./linux/drivers/net/ppp_generic.c
--- ../linux-2.3.40/linux/drivers/net/ppp_generic.c Tue Nov 9 20:50:49 1999
+++ ./linux/drivers/net/ppp_generic.c Fri Jan 21 15:36:15 2000
@@ -559,7 +559,9 @@
{
int err;
#ifndef MODULE
+#ifdef CONFIG_PPP_DEFLATE
extern struct compressor ppp_deflate, ppp_deflate_draft;
+#endif
extern int ppp_async_init(void);
extern int ppp_sync_init(void);
#endif
diff -u --recursive --new-file ../linux-2.3.40/linux/fs/partitions/check.c ./linux/fs/partitions/check.c
--- ../linux-2.3.40/linux/fs/partitions/check.c Fri Jan 21 14:28:09 2000
+++ ./linux/fs/partitions/check.c Fri Jan 21 14:53:07 2000
@@ -276,7 +276,6 @@
void register_disk(struct gendisk *gdev, kdev_t dev, unsigned minors,
struct block_device_operations *ops, long size)
{
- unsigned first = (unsigned)dev;
if (!gdev)
return;
grok_partitions(gdev, MINOR(dev)>>gdev->minor_shift, minors, size);
diff -u --recursive --new-file ../linux-2.3.40/linux/fs/partitions/msdos.c ./linux/fs/partitions/msdos.c
--- ../linux-2.3.40/linux/fs/partitions/msdos.c Fri Jan 21 14:28:09 2000
+++ ./linux/fs/partitions/msdos.c Fri Jan 21 14:30:03 2000
@@ -26,7 +26,9 @@
#include <linux/major.h>
#include <linux/string.h>
#include <linux/blk.h>
-#include <linux/ide.h> /* IDE xlate */
+#ifdef CONFIG_BLK_DEV_IDE
+#include <linux/ide.h> /* for ide_xlate_1024() */
+#endif

#include <asm/system.h>

diff -u --recursive --new-file ../linux-2.3.40/linux/fs/proc/base.c ./linux/fs/proc/base.c
--- ../linux-2.3.40/linux/fs/proc/base.c Fri Jan 7 21:59:42 2000
+++ ./linux/fs/proc/base.c Fri Jan 21 18:50:53 2000
@@ -29,9 +29,12 @@
* inumbers of the rest of procfs (currently those are in 0x0000--0xffff).
* As soon as we'll get a separate superblock we will be able to forget
* about magical ranges too.
+ *
+ * For example, the define below may be replaced by
+ * #define fake_ino(pid,ino) 0x10000
*/

-#define fake_ino(pid,ino) (((pid)<<16)|(ino))
+#define fake_ino(pid,ino) (((1)<<16)|(ino))

ssize_t proc_pid_read_maps(struct task_struct*,struct file*,char*,size_t,loff_t*);
int proc_pid_stat(struct task_struct*,char*);
@@ -610,7 +613,9 @@
return 1;
p = base_stuff + i;
while (p->name) {
- if (filldir(dirent, p->name, p->len, filp->f_pos, fake_ino(pid, p->type)) < 0)
+ if (filldir(dirent, p->name, p->len,
+ filp->f_pos,
+ fake_ino(pid, p->type)) < 0)
return 0;
filp->f_pos++;
p++;
@@ -621,7 +626,8 @@

/* building an inode */

-static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task, int ino)
+static struct inode *proc_pid_make_inode(struct super_block * sb,
+ struct task_struct *task, int ino)
{
struct inode * inode;

@@ -923,9 +929,7 @@
goto out;
pid *= 10;
pid += c;
- if (!pid)
- goto out;
- if (pid & 0xffff0000)
+ if (pid <= 0 || pid >= PID_MAX)
goto out;
}

diff -u --recursive --new-file ../linux-2.3.40/linux/fs/super.c ./linux/fs/super.c
--- ../linux-2.3.40/linux/fs/super.c Fri Jan 21 14:28:09 2000
+++ ./linux/fs/super.c Fri Jan 21 14:51:02 2000
@@ -1272,7 +1272,7 @@
}
return 0;
}
- printk(KERN_ERR "error %d\n",PTR_ERR(bdev));
+ printk(KERN_ERR "error %ld\n",PTR_ERR(bdev));
return error;
}
remove_vfsmnt(old_root_dev);
diff -u --recursive --new-file ../linux-2.3.40/linux/include/linux/threads.h ./linux/include/linux/threads.h
--- ../linux-2.3.40/linux/include/linux/threads.h Tue Jan 11 03:29:07 2000
+++ ./linux/include/linux/threads.h Fri Jan 21 19:12:26 2000
@@ -15,8 +15,18 @@
#define MIN_THREADS_LEFT_FOR_ROOT 4

/*
- * This controls the maximum pid allocated to a process
+ * One more than the maximum pid allocated to a process
+ * (should be positive when assigned to an int)
*/
+#ifdef CONFIG_15BIT_PID
#define PID_MAX 0x8000
+#else
+#define PID_MAX 0x7fffffff
+#endif
+
+/*
+ * Place where we start again after a full cycle
+ */
+#define PID_MIN 300

#endif
diff -u --recursive --new-file ../linux-2.3.40/linux/kernel/fork.c ./linux/kernel/fork.c
--- ../linux-2.3.40/linux/kernel/fork.c Tue Dec 14 00:39:24 1999
+++ ./linux/kernel/fork.c Fri Jan 21 14:30:04 2000
@@ -194,26 +194,19 @@
return current->pid;

spin_lock(&lastpid_lock);
- if((++last_pid) & 0xffff8000) {
- last_pid = 300; /* Skip daemons etc. */
- goto inside;
- }
- if(last_pid >= next_safe) {
-inside:
- next_safe = PID_MAX;
+ if(++last_pid >= next_safe) {
read_lock(&tasklist_lock);
repeat:
+ if (last_pid >= PID_MAX)
+ last_pid = PID_MIN;
+ next_safe = PID_MAX;
+
for_each_task(p) {
if(p->pid == last_pid ||
p->pgrp == last_pid ||
- p->session == last_pid) {
- if(++last_pid >= next_safe) {
- if(last_pid & 0xffff8000)
- last_pid = 300;
- next_safe = PID_MAX;
- }
- goto repeat;
- }
+ p->session == last_pid)
+ if(++last_pid >= next_safe)
+ goto repeat;
if(p->pid > last_pid && next_safe > p->pid)
next_safe = p->pid;
if(p->pgrp > last_pid && next_safe > p->pgrp)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.034 / U:0.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site