Messages in this thread Patch in this message | | | Date | Wed, 23 Aug 2000 19:09:07 +0100 (BST) | From | Tigran Aivazian <> | Subject | [patch-2.4.0-test7-pre7] do_fork() optimization. (fwd) |
| |
ahh, I did it again...
---------- Forwarded message ---------- Date: Wed, 23 Aug 2000 19:04:38 +0100 (BST) From: Tigran Aivazian <tigran@veritas.com> To: Linus Torvalds <torvalds@transmeta.com> Cc: linux-kernel@vger.rutgers.edu Subject: [patch-2.4.0-test7-pre7] do_fork() optimization.
Hi Linus,
I was thinking if I could get a few more cycles out of do_fork() (the recent SCO propaganda about their _lwp_create(2) being faster than our clone(2) made me think). And I noticed that get_pid() doesn't actually need the lastpid_lock because it is only ever called from do_fork() inside the lock_kernel(). So, here is the obvious patch.
Regards. Tigran
--- linux/kernel/fork.c Wed Aug 23 08:04:33 2000 +++ work/kernel/fork.c Wed Aug 23 19:01:04 2000 @@ -74,9 +74,6 @@ init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2; } -/* Protects next_safe and last_pid. */ -spinlock_t lastpid_lock = SPIN_LOCK_UNLOCKED; - static int get_pid(unsigned long flags) { static int next_safe = PID_MAX; @@ -85,7 +82,6 @@ if (flags & CLONE_PID) return current->pid; - spin_lock(&lastpid_lock); if((++last_pid) & 0xffff8000) { last_pid = 300; /* Skip daemons etc. */ goto inside; @@ -115,8 +111,6 @@ } read_unlock(&tasklist_lock); } - spin_unlock(&lastpid_lock); - return last_pid; }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
| |