patch-2.1.25 linux/kernel/sys.c

Next file: linux/net/Config.in
Previous file: linux/kernel/sched.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.24/linux/kernel/sys.c linux/kernel/sys.c
@@ -766,12 +766,8 @@
 
 asmlinkage int sys_getpgrp(void)
 {
-	int ret;
-
-	lock_kernel();
-	ret = current->pgrp;
-	unlock_kernel();
-	return ret;
+	/* SMP - assuming writes are word atomic this is fine */
+	return current->pgrp;
 }
 
 asmlinkage int sys_getsid(pid_t pid)
@@ -779,10 +775,12 @@
 	struct task_struct * p;
 	int ret;
 
-	lock_kernel();
+	/* SMP: The 'self' case requires no lock */
 	if (!pid) {
 		ret = current->session;
 	} else {
+		/* Walking the process table needs locks */
+		lock_kernel();
 		for_each_task(p) {
 			if (p->pid == pid) {
 				ret = p->session;
@@ -790,9 +788,9 @@
 			}
 		}
 		ret = -ESRCH;
-	}
 out:
-	unlock_kernel();
+		unlock_kernel();
+	}
 	return ret;
 }
 
@@ -1117,11 +1115,7 @@
 
 asmlinkage int sys_umask(int mask)
 {
-	int old;
-
-	lock_kernel();
-	old = current->fs->umask;
-	current->fs->umask = mask & S_IRWXUGO;
-	unlock_kernel();
-	return (old);
+	/* The xchg() isn't SMP-safe on x86 right now.. */
+	mask = xchg(&current->fs->umask, mask & S_IRWXUGO);
+	return mask;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov