Re: [PATCH] -mm: Small schedule() optimization

From: Ingo Molnar
Date: Fri Mar 17 2006 - 04:14:00 EST



* Con Kolivas <kernel@xxxxxxxxxxx> wrote:

> > - if (likely(!current->exit_state)) {
> > - if (unlikely(in_atomic())) {
> > + if (unlikely(in_atomic())) {
> > + if (likely(!current->exit_state)) {
>
> I suspect that once we're in_atomic() then we're no longer likely to
> be !current->exit_state
>
> Probably better to just
> if (unlikely(in_atomic())) {
> if (!current->exit_state) {
>
> Ingo?

yeah. There's not much point in nesting likely/unlikely. In fact we can
just merge the two conditions, as per updated patch below.

Ingo

---
From: Andreas Mohr <andi@xxxxxxxx>

small schedule() microoptimization.

Signed-off-by: Andreas Mohr <andi@xxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--- linux/kernel/sched.c.orig
+++ linux/kernel/sched.c
@@ -2873,13 +2873,11 @@ asmlinkage void __sched schedule(void)
* schedule() atomically, we ignore that path for now.
* Otherwise, whine if we are scheduling when we should not be.
*/
- if (likely(!current->exit_state)) {
- if (unlikely(in_atomic())) {
- printk(KERN_ERR "scheduling while atomic: "
- "%s/0x%08x/%d\n",
- current->comm, preempt_count(), current->pid);
- dump_stack();
- }
+ if (unlikely(in_atomic() && !current->exit_state)) {
+ printk(KERN_ERR "scheduling while atomic: "
+ "%s/0x%08x/%d\n",
+ current->comm, preempt_count(), current->pid);
+ dump_stack();
}
profile_hit(SCHED_PROFILING, __builtin_return_address(0));

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/