Re: [PATCH 11/17] fuse: add number of waiting requests attribute

From: Andrew Morton
Date: Fri Jan 13 2006 - 20:25:28 EST


Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>
> + /** The number of requests waiting for completion */
> + atomic_t num_waiting;

This doesn't get initialised anywhere.

Presumably you're relying on a memset somewhere. That might work on all
architectures, AFAIK. But in theory it's wrong. If, for example, the
architecture implements atomic_t via a spinlock-plus-integer, and that
spinlock's unlocked state is not all-bits-zero, we're dead.

So we should initialise it with

foo->num_waiting = ATOMIC_INIT(0);



nb: it is not correct to initialise an atomic_t with

atomic_set(a, 0);

because in the above theoretical case case where the arch uses a spinlock
in the atomic_t, that spinlock doesn't get initialised. I bet we've got code
in there which does this.
-
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/