Commit 3795e1616f16905889761536cdc266ebc51855e5
Committed by
Linus Torvalds
1 parent
a547dfe956
Exists in
master
and in
7 other branches
[PATCH] Decrease number of pointer derefs in exit.c
Decrease the number of pointer derefs in kernel/exit.c Benefits of the patch: - Fewer pointer dereferences should make the code slightly faster. - Size of generated code is smaller - improved readability Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Acked-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 21 additions and 16 deletions Side-by-side Diff
kernel/exit.c
... | ... | @@ -1071,6 +1071,9 @@ |
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | if (likely(p->real_parent == p->parent) && likely(p->signal)) { |
1074 | + struct signal_struct *psig; | |
1075 | + struct signal_struct *sig; | |
1076 | + | |
1074 | 1077 | /* |
1075 | 1078 | * The resource counters for the group leader are in its |
1076 | 1079 | * own task_struct. Those for dead threads in the group |
1077 | 1080 | |
1078 | 1081 | |
... | ... | @@ -1087,24 +1090,26 @@ |
1087 | 1090 | * here reaping other children at the same time. |
1088 | 1091 | */ |
1089 | 1092 | spin_lock_irq(&p->parent->sighand->siglock); |
1090 | - p->parent->signal->cutime = | |
1091 | - cputime_add(p->parent->signal->cutime, | |
1093 | + psig = p->parent->signal; | |
1094 | + sig = p->signal; | |
1095 | + psig->cutime = | |
1096 | + cputime_add(psig->cutime, | |
1092 | 1097 | cputime_add(p->utime, |
1093 | - cputime_add(p->signal->utime, | |
1094 | - p->signal->cutime))); | |
1095 | - p->parent->signal->cstime = | |
1096 | - cputime_add(p->parent->signal->cstime, | |
1098 | + cputime_add(sig->utime, | |
1099 | + sig->cutime))); | |
1100 | + psig->cstime = | |
1101 | + cputime_add(psig->cstime, | |
1097 | 1102 | cputime_add(p->stime, |
1098 | - cputime_add(p->signal->stime, | |
1099 | - p->signal->cstime))); | |
1100 | - p->parent->signal->cmin_flt += | |
1101 | - p->min_flt + p->signal->min_flt + p->signal->cmin_flt; | |
1102 | - p->parent->signal->cmaj_flt += | |
1103 | - p->maj_flt + p->signal->maj_flt + p->signal->cmaj_flt; | |
1104 | - p->parent->signal->cnvcsw += | |
1105 | - p->nvcsw + p->signal->nvcsw + p->signal->cnvcsw; | |
1106 | - p->parent->signal->cnivcsw += | |
1107 | - p->nivcsw + p->signal->nivcsw + p->signal->cnivcsw; | |
1103 | + cputime_add(sig->stime, | |
1104 | + sig->cstime))); | |
1105 | + psig->cmin_flt += | |
1106 | + p->min_flt + sig->min_flt + sig->cmin_flt; | |
1107 | + psig->cmaj_flt += | |
1108 | + p->maj_flt + sig->maj_flt + sig->cmaj_flt; | |
1109 | + psig->cnvcsw += | |
1110 | + p->nvcsw + sig->nvcsw + sig->cnvcsw; | |
1111 | + psig->cnivcsw += | |
1112 | + p->nivcsw + sig->nivcsw + sig->cnivcsw; | |
1108 | 1113 | spin_unlock_irq(&p->parent->sighand->siglock); |
1109 | 1114 | } |
1110 | 1115 |