]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sched: consolidate CLONE_IDLETASK masking
authorWilliam Lee Irwin III <wli@holomorphy.com>
Tue, 24 Aug 2004 04:27:07 +0000 (21:27 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 24 Aug 2004 04:27:07 +0000 (21:27 -0700)
Every arch now bears the burden of sanitizing CLONE_IDLETASK out of the
clone_flags passed to do_fork() by userspace.  This patch hoists the
masking of CLONE_IDLETASK out of the system call entrypoints into
do_fork(), and thereby removes some small overheads from do_fork(), as
do_fork() may now assume that CLONE_IDLETASK has been cleared.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
25 files changed:
arch/alpha/kernel/process.c
arch/arm/kernel/sys_arm.c
arch/arm26/kernel/sys_arm.c
arch/cris/arch-v10/kernel/process.c
arch/h8300/kernel/process.c
arch/i386/kernel/process.c
arch/ia64/ia32/ia32_entry.S
arch/ia64/kernel/asm-offsets.c
arch/ia64/kernel/entry.S
arch/m68k/kernel/process.c
arch/m68knommu/kernel/process.c
arch/mips/kernel/syscall.c
arch/parisc/kernel/process.c
arch/ppc/kernel/process.c
arch/ppc64/kernel/process.c
arch/s390/kernel/compat_linux.c
arch/s390/kernel/process.c
arch/sh/kernel/process.c
arch/sh64/kernel/process.c
arch/sparc/kernel/process.c
arch/sparc64/kernel/process.c
arch/x86_64/ia32/sys_ia32.c
arch/x86_64/kernel/process.c
include/linux/sched.h
kernel/fork.c

index 6fd8546554e9b1f9ae9802a8ca12851b9e6f98c2..4933f3ce58339c182897fe08d25f4e329083cae4 100644 (file)
@@ -246,8 +246,7 @@ alpha_clone(unsigned long clone_flags, unsigned long usp,
        if (!usp)
                usp = rdusp();
 
-       return do_fork(clone_flags & ~CLONE_IDLETASK, usp, regs, 0,
-                      parent_tid, child_tid);
+       return do_fork(clone_flags, usp, regs, 0, parent_tid, child_tid);
 }
 
 int
index fb26b3bf96b1c6019d46509dbaa598dff27f9ac3..5b03e1dd9fffcddf10fac8e6a62f0f27379c9435 100644 (file)
@@ -257,7 +257,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, struct
        if (!newsp)
                newsp = regs->ARM_sp;
 
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0, NULL, NULL);
+       return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
 }
 
 asmlinkage int sys_vfork(struct pt_regs *regs)
index 0d1cdd503f3b556e3a497bed2a603542316e27b9..431f9f85e0693a7697b3499225b6ca9e8670bcee 100644 (file)
@@ -256,7 +256,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, struct
        if (!newsp)
                newsp = regs->ARM_sp;
 
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0, NULL, NULL);
+       return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
 }
 
 asmlinkage int sys_vfork(struct pt_regs *regs)
index 8aba42472912dc3a87531ea492c5444a03f19037..d0993bf720183e8530afe4faaee046b9d7aa012a 100644 (file)
@@ -180,7 +180,7 @@ asmlinkage int sys_clone(unsigned long newusp, unsigned long flags,
 {
        if (!newusp)
                newusp = rdusp();
-       return do_fork(flags & ~CLONE_IDLETASK, newusp, regs, 0, parent_tid, child_tid);
+       return do_fork(flags, newusp, regs, 0, parent_tid, child_tid);
 }
 
 /* vfork is a system call in i386 because of register-pressure - maybe
index d7c058d64030ecbd21a14f8882412fc313d92fdb..134aec1c6d199d259a5207a2c0ea427bc487843a 100644 (file)
@@ -189,7 +189,7 @@ asmlinkage int h8300_clone(struct pt_regs *regs)
        newsp = regs->er2;
        if (!newsp)
                newsp  = rdusp();
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0, NULL, NULL);
+       return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
 
 }
 
index 0b3b83450b19d0ccd38ad603fd6d0e47b672101b..477c68eeb979ee1a2adeedf4126a63232670be0d 100644 (file)
@@ -595,7 +595,7 @@ asmlinkage int sys_clone(struct pt_regs regs)
        child_tidptr = (int __user *)regs.edi;
        if (!newsp)
                newsp = regs.esp;
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0, parent_tidptr, child_tidptr);
+       return do_fork(clone_flags, newsp, &regs, 0, parent_tidptr, child_tidptr);
 }
 
 /*
index fa3ac962a5f665816747cc3d9407829fd10287ad..d8824113ebaa5fb9e8cc5cdfb1f13bdfaa7b333e 100644 (file)
@@ -41,7 +41,7 @@ ENTRY(ia32_clone)
        zxt4 out1=in1                           // newsp
        mov out3=16                             // stacksize (compensates for 16-byte scratch area)
        adds out2=IA64_SWITCH_STACK_SIZE+16,sp  // out2 = &regs
-       dep out0=0,in0,CLONE_IDLETASK_BIT,1     // out0 = clone_flags & ~CLONE_IDLETASK
+       mov out0=in0                            // out0 = clone_flags
        zxt4 out4=in2                           // out4 = parent_tidptr
        zxt4 out5=in4                           // out5 = child_tidptr
        br.call.sptk.many rp=do_fork
index f166571ecbb91783616248594fbabdc5770beeac..695299af0c603413b8ff91cbea6e6605188c31a8 100644 (file)
@@ -195,11 +195,6 @@ void foo(void)
        DEFINE(IA64_TIMESPEC_TV_NSEC_OFFSET, offsetof (struct timespec, tv_nsec));
 
 
-       DEFINE(CLONE_IDLETASK_BIT, 12);
-#if CLONE_IDLETASK != (1 << 12)
-# error "CLONE_IDLETASK_BIT incorrect, please fix"
-#endif
-
        DEFINE(CLONE_SETTLS_BIT, 19);
 #if CLONE_SETTLS != (1<<19)
 # error "CLONE_SETTLS_BIT incorrect, please fix"
index 52576c34c30ac6f79bd0dad03e996a67275cdf91..1fe9575c7f7b50099aba6cf2957e9ec25faf84f7 100644 (file)
@@ -128,7 +128,7 @@ GLOBAL_ENTRY(sys_clone2)
 (p6)   st8 [r2]=in5                            // store TLS in r16 for copy_thread()
        mov out5=in4    // child_tidptr:  valid only w/CLONE_CHILD_SETTID or CLONE_CHILD_CLEARTID
        adds out2=IA64_SWITCH_STACK_SIZE+16,sp  // out2 = &regs
-       dep out0=0,in0,CLONE_IDLETASK_BIT,1     // out0 = clone_flags & ~CLONE_IDLETASK
+       mov out0=in0                            // out0 = clone_flags
        br.call.sptk.many rp=do_fork
 .ret1: .restore sp
        adds sp=IA64_SWITCH_STACK_SIZE,sp       // pop the switch stack
@@ -157,7 +157,7 @@ GLOBAL_ENTRY(sys_clone)
 (p6)   st8 [r2]=in4                            // store TLS in r13 (tp)
        mov out5=in3    // child_tidptr:  valid only w/CLONE_CHILD_SETTID or CLONE_CHILD_CLEARTID
        adds out2=IA64_SWITCH_STACK_SIZE+16,sp  // out2 = &regs
-       dep out0=0,in0,CLONE_IDLETASK_BIT,1     // out0 = clone_flags & ~CLONE_IDLETASK
+       mov out0=in0                            // out0 = clone_flags
        br.call.sptk.many rp=do_fork
 .ret2: .restore sp
        adds sp=IA64_SWITCH_STACK_SIZE,sp       // pop the switch stack
index b426ab55ad39eb0fa37819c0a0ef511028928abc..93b043e2a4359985b80ab1890135ccc1e57351dc 100644 (file)
@@ -232,7 +232,7 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
        child_tidptr = (int *)regs->d4;
        if (!newsp)
                newsp = rdusp();
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0,
+       return do_fork(clone_flags, newsp, regs, 0,
                       parent_tidptr, child_tidptr);
 }
 
index 581eef2b796b243a0b8c290480cac19783648cbb..b0901d8171d9c856017df3cdd94b480a9bfe74ce 100644 (file)
@@ -188,7 +188,7 @@ asmlinkage int m68k_clone(struct pt_regs *regs)
        newsp = regs->d2;
        if (!newsp)
                newsp = rdusp();
-        return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0, NULL, NULL);
+        return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
 }
 
 int copy_thread(int nr, unsigned long clone_flags,
index 16519f7e8c3bafd608fe573d7407a8dc82fa1748..51f4676857ed42b04cc0cc0aa9ec84a10b24b7d2 100644 (file)
@@ -180,7 +180,7 @@ static_unused int _sys_clone(nabi_no_regargs struct pt_regs regs)
                newsp = regs.regs[29];
        parent_tidptr = (int *) regs.regs[6];
        child_tidptr = (int *) regs.regs[7];
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0,
+       return do_fork(clone_flags, newsp, &regs, 0,
                       parent_tidptr, child_tidptr);
 }
 
index dd938ef771916e2e82c0dbf864935a0117bf390c..d7365b958f7eb7040539a70a73c5ac3769e6a3f4 100644 (file)
@@ -262,7 +262,7 @@ sys_clone(unsigned long clone_flags, unsigned long usp,
        if(usp == 0)
                usp = regs->gr[30];
 
-       return do_fork(clone_flags & ~CLONE_IDLETASK, usp, regs, 0, user_tid, NULL);
+       return do_fork(clone_flags, usp, regs, 0, user_tid, NULL);
 }
 
 int
index 2ea505381139ca7f678d0b29582fef59f4514d60..cc20fa3e61a9e36ecd20bd5c586060f3a1e4142d 100644 (file)
@@ -555,8 +555,7 @@ int sys_clone(unsigned long clone_flags, unsigned long usp,
        CHECK_FULL_REGS(regs);
        if (usp == 0)
                usp = regs->gpr[1];     /* stack pointer for child */
-       return do_fork(clone_flags & ~CLONE_IDLETASK, usp, regs, 0,
-                       parent_tidp, child_tidp);
+       return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp);
 }
 
 int sys_fork(int p1, int p2, int p3, int p4, int p5, int p6,
index 5acc56729160a6ae4c04913e03fcefcb77e1f09e..60a849279ed4642fe4468b9fa3c05dad75899e7f 100644 (file)
@@ -458,7 +458,7 @@ int sys_clone(unsigned long clone_flags, unsigned long p2, unsigned long p3,
                }
        }
 
-       return do_fork(clone_flags & ~CLONE_IDLETASK, p2, regs, 0,
+       return do_fork(clone_flags, p2, regs, 0,
                    (int __user *)parent_tidptr, (int __user *)child_tidptr);
 }
 
index 5685c5feb3c68ed9d4a0b4507a924d4992b46902..f3464cc5c178ee9f1f6d26134d0fe3f986d5fc03 100644 (file)
@@ -1219,7 +1219,7 @@ asmlinkage long sys32_clone(struct pt_regs regs)
        child_tidptr = (int *) (regs.gprs[5] & 0x7fffffffUL);
         if (!newsp)
                 newsp = regs.gprs[15];
-        return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0,
+        return do_fork(clone_flags, newsp, &regs, 0,
                       parent_tidptr, child_tidptr);
 }
 
index 73cb6baeb5259c1a39277273099cc709a61a373e..c31efb82797e282fe40da0614773e0df0a4fe1ae 100644 (file)
@@ -336,7 +336,7 @@ asmlinkage long sys_clone(struct pt_regs regs)
        child_tidptr = (int __user *) regs.gprs[5];
         if (!newsp)
                 newsp = regs.gprs[15];
-        return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0,
+        return do_fork(clone_flags, newsp, &regs, 0,
                       parent_tidptr, child_tidptr);
 }
 
index 8ba6dd3009577fcb3fea7bb1d0f894f19ea84e30..c9a43c8df32fb461cb3281238064283bbc2f676e 100644 (file)
@@ -440,7 +440,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
 {
        if (!newsp)
                newsp = regs.regs[15];
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, &regs, 0,
+       return do_fork(clone_flags, newsp, &regs, 0,
                        (int __user *)parent_tidptr, (int __user *)child_tidptr);
 }
 
index f9e82274e35f4a17e66b86b6869427ccdb821023..001f1255390720a5ef2e7e52cce204102d5228e9 100644 (file)
@@ -820,7 +820,7 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
 {
        if (!newsp)
                newsp = pregs->regs[15];
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, pregs, 0, 0, 0);
+       return do_fork(clone_flags, newsp, pregs, 0, 0, 0);
 }
 
 /*
index 4ff019336e94424ccceb2e82fd516834dcca8d57..1dc918135eb333ee3053b490fc11e9984af51461 100644 (file)
@@ -435,8 +435,6 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags,
 {
        unsigned long parent_tid_ptr, child_tid_ptr;
 
-       clone_flags &= ~CLONE_IDLETASK;
-
        parent_tid_ptr = regs->u_regs[UREG_I2];
        child_tid_ptr = regs->u_regs[UREG_I4];
 
index 145ce7c7308794c34e4af3dd57eec93e612481a8..f3e3c657e9cb87c5c77d052f8ff3580de1faed1a 100644 (file)
@@ -588,8 +588,6 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
 {
        int __user *parent_tid_ptr, *child_tid_ptr;
 
-       clone_flags &= ~CLONE_IDLETASK;
-
 #ifdef CONFIG_COMPAT
        if (test_thread_flag(TIF_32BIT)) {
                parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]);
index 277c05a7b6b33978f0eea481e7f6553a82247efc..6a33dbb93b71d0dcebda7560764cfc9175131cf7 100644 (file)
@@ -1148,8 +1148,7 @@ asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
        void __user *child_tid = (void __user *)regs->rdi;
        if (!newsp)
                newsp = regs->rsp;
-        return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0,
-                   parent_tid, child_tid);
+        return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
 }
 
 /*
index ddc7a7311f68d2588e57e6dc82e047a83990b55f..3d3f6c5e063aedf85deb257571062bfc1dcbcc9a 100644 (file)
@@ -555,8 +555,7 @@ asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, void _
 {
        if (!newsp)
                newsp = regs->rsp;
-       return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, regs, 0,
-                   parent_tid, child_tid);
+       return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
 }
 
 /*
index a9877efe6cb7fafb9fc37119420cef4eafe063e2..62a6f3e00d84e591bf349d378b65c43feb33c11b 100644 (file)
@@ -40,7 +40,6 @@ struct exec_domain;
 #define CLONE_FS       0x00000200      /* set if fs info shared between processes */
 #define CLONE_FILES    0x00000400      /* set if open files shared between processes */
 #define CLONE_SIGHAND  0x00000800      /* set if signal handlers and blocked signals shared */
-#define CLONE_IDLETASK 0x00001000      /* set if new pid should be 0 (kernel only)*/
 #define CLONE_PTRACE   0x00002000      /* set if we want to let tracing continue on the child too */
 #define CLONE_VFORK    0x00004000      /* set if the parent wants the child to wake it up on mm_release */
 #define CLONE_PARENT   0x00008000      /* set if we want to have the same parent as the cloner */
index 477efdabe4f6dfc398e907d8d2e280224d703d53..5bc6a0aae69f6b1af7b8eea4e900877c52a4f608 100644 (file)
@@ -45,6 +45,9 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
+/* set if new pid should be 0 (kernel only)*/
+#define CLONE_IDLETASK 0x00001000
+
 /* The idle threads do not count..
  * Protected by write_lock_irq(&tasklist_lock)
  */
@@ -1194,7 +1197,7 @@ task_t * __init fork_idle(int cpu)
 
 static inline int fork_traceflag (unsigned clone_flags)
 {
-       if (clone_flags & (CLONE_UNTRACED | CLONE_IDLETASK))
+       if (clone_flags & CLONE_UNTRACED)
                return 0;
        else if (clone_flags & CLONE_VFORK) {
                if (current->ptrace & PT_TRACE_VFORK)
@@ -1225,6 +1228,7 @@ long do_fork(unsigned long clone_flags,
        int trace = 0;
        long pid;
 
+       clone_flags &= ~CLONE_IDLETASK;
        if (unlikely(current->ptrace)) {
                trace = fork_traceflag (clone_flags);
                if (trace)
@@ -1254,13 +1258,11 @@ long do_fork(unsigned long clone_flags,
                        set_tsk_thread_flag(p, TIF_SIGPENDING);
                }
 
-               if (likely(!(clone_flags & CLONE_IDLETASK))) {
-                       if (!(clone_flags & CLONE_STOPPED))
-                               wake_up_new_task(p, clone_flags);
-                       else
-                               p->state = TASK_STOPPED;
-                       ++total_forks;
-               }
+               if (!(clone_flags & CLONE_STOPPED))
+                       wake_up_new_task(p, clone_flags);
+               else
+                       p->state = TASK_STOPPED;
+               ++total_forks;
 
                if (unlikely (trace)) {
                        current->ptrace_message = pid;