[patch-2.3.43-pre5] optimizing cleanup of kernel/exit.c

From: Tigran Aivazian (tigran@sco.COM)
Date: Wed Feb 09 2000 - 06:12:42 EST


Hi Linus,

This simple restructuring of sys_wait4() not only makes it more readable
(because of less pressure on tab'd space) but also saves the precious 16
bytes of kernel text:

Before
======
   text data bss dec hex filename
1383321 257386 413440 2054147 1f5803 vmlinux

After
=====

   text data bss dec hex filename
1383305 257386 413440 2054131 1f57f3 vmlinux

  http://www.ocston.org/~tigran/patches/exit-2.3.43-p5.patch

regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.ocston.org/~tigran

--- exit.c.0 Wed Feb 9 10:55:11 2000
+++ exit.c Wed Feb 9 10:52:05 2000
@@ -470,43 +470,38 @@
                 if ((p->exit_signal != SIGCHLD) ^ ((options & __WCLONE) != 0))
                         continue;
                 flag = 1;
- switch (p->state) {
- case TASK_STOPPED:
- if (!p->exit_code)
- continue;
- if (!(options & WUNTRACED) && !(p->flags & PF_PTRACED))
- continue;
- read_unlock(&tasklist_lock);
- retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
- if (!retval && stat_addr)
- retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
- if (!retval) {
- p->exit_code = 0;
- retval = p->pid;
- }
- goto end_wait4;
- case TASK_ZOMBIE:
- current->times.tms_cutime += p->times.tms_utime + p->times.tms_cutime;
- current->times.tms_cstime += p->times.tms_stime + p->times.tms_cstime;
- read_unlock(&tasklist_lock);
- retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
- if (!retval && stat_addr)
- retval = put_user(p->exit_code, stat_addr);
- if (retval)
- goto end_wait4;
- retval = p->pid;
- if (p->p_opptr != p->p_pptr) {
- write_lock_irq(&tasklist_lock);
- REMOVE_LINKS(p);
- p->p_pptr = p->p_opptr;
- SET_LINKS(p);
- write_unlock_irq(&tasklist_lock);
- notify_parent(p, SIGCHLD);
- } else
- release(p);
- goto end_wait4;
- default:
+ if (p->state == TASK_STOPPED && p->exit_code) {
+ if (!(options & WUNTRACED) && !(p->flags & PF_PTRACED))
                                 continue;
+ read_unlock(&tasklist_lock);
+ retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
+ if (!retval && stat_addr)
+ retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
+ if (!retval) {
+ p->exit_code = 0;
+ retval = p->pid;
+ }
+ goto end_wait4;
+ } else if (p->state == TASK_ZOMBIE) {
+ current->times.tms_cutime += p->times.tms_utime + p->times.tms_cutime;
+ current->times.tms_cstime += p->times.tms_stime + p->times.tms_cstime;
+ read_unlock(&tasklist_lock);
+ retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
+ if (!retval && stat_addr)
+ retval = put_user(p->exit_code, stat_addr);
+ if (retval)
+ goto end_wait4;
+ retval = p->pid;
+ if (p->p_opptr != p->p_pptr) {
+ write_lock_irq(&tasklist_lock);
+ REMOVE_LINKS(p);
+ p->p_pptr = p->p_opptr;
+ SET_LINKS(p);
+ write_unlock_irq(&tasklist_lock);
+ notify_parent(p, SIGCHLD);
+ } else
+ release(p);
+ goto end_wait4;
                 }
         }
         read_unlock(&tasklist_lock);

-
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/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:14 EST