Re: [PATCH] De-macro spin_trylock_irq, spin_trylock_irqsave,write_trylock_irqsave

From: Ingo Molnar
Date: Sat Aug 16 2008 - 09:46:25 EST



* Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:

> 1) de-macro, remove ({ usages as side-effect,
> 2) change calling convention to not accept "flags" by value -- trylock
> functions can modify them, so by-value is misleading, and number of users
> is relatively low.
> 3) de-macro spin_trylock_irq() for a change.

> +++ b/kernel/sched.c
> @@ -1174,7 +1174,7 @@ static void resched_cpu(int cpu)
> struct rq *rq = cpu_rq(cpu);
> unsigned long flags;
>
> - if (!spin_trylock_irqsave(&rq->lock, flags))
> + if (!spin_trylock_irqsave(&rq->lock, &flags))
> return;

hm, i dont really like this assymetric calling convention to other
locking primitives that all take 'flags' as a value.
[spin_lock_irqsave(), etc.]

so what's the point really? It sure does not make actual usage more
readable. If we switched _all_ primitives to use flags as a pointer,
that might make sense, in theory. (but it would also be hugely invasive,
with not much upside with tons of downside like years of migration
fallout and having to rewrite hundreds of kernel hacking books ;-) )

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