Re: [PATCH 5/5] futex: fix miss ordered wakeups

From: Peter Zijlstra
Date: Thu Jun 12 2008 - 02:07:22 EST


On Wed, 2008-06-11 at 13:49 -0700, Daniel Walker wrote:
> plain text document attachment (blocked_on-futex.patch)

I thought everybody and his dog didn't care for this?

> +void futex_adjust_waiters(struct task_struct *p)
> +{
> +

Seemingly extra whitespace ^

> + if (p->blocked_on) {
> + struct futex_hash_bucket *hb;
> + struct futex_q *q, *next;
> + union futex_key key;
> +
> + spin_lock_irq(&p->pi_lock);
> + if (p->blocked_on && p->blocked_on->lock_type == FUTEX_WAITER) {
> + key = *p->blocked_on->futex_blocked_on;
> + spin_unlock_irq(&p->pi_lock);
> + } else {
> + spin_unlock_irq(&p->pi_lock);
> + return;
> + }
> +
> + hb = hash_futex(&key);
> + spin_lock(&hb->lock);
> + plist_for_each_entry_safe(q, next, &hb->chain, list) {
> + if (match_futex(&q->key, &key) && q->task == p) {
> + int prio = min(p->normal_prio, MAX_RT_PRIO);
> + plist_del(&q->list, &hb->chain);
> + plist_node_init(&q->list, prio);
> + plist_add(&q->list, &hb->chain);
> + break;
> + }
> + }
> + spin_unlock(&hb->lock);
> + }
> +}

Also, if you write it like:

if (!p->blocked_on)
return

do_other_stuff

you loose one nesting level - which imho looks better.

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