Re: [2/4] consolidate bit waiting code patterns

From: Andrew Morton
Date: Sat Aug 28 2004 - 04:38:22 EST


William Lee Irwin III <wli@xxxxxxxxxxxxxx> wrote:
>
> +int __sched __wait_on_bit_lock(wait_queue_head_t *wq, struct wait_bit_queue *q,
> + void *word, int bit,
> + int (*wait)(void *), unsigned mode)
> +{
> + int ret;
> +
> + while (test_and_set_bit(bit, word)) {
> + prepare_to_wait_exclusive(wq, &q->wait, mode);
> + if (test_bit(bit, word)) {
> + if ((ret = (*wait)(word)))
> + return ret;
> + }
> + }
> + finish_wait(wq, &q->wait);
> + return 0;
> +}

Some comments over this thing would be nice.

The `wait' argument seems to be misnamed. It typically points at
sync_page(), yes? Maybe it should be called `action' or `kick' or
something.

If (*wait)() returns non-zero then it looks to me like the callers will get
confused, thinking that the page did come unlocked?

If (*wait)() returns non-zero then we need to run finish_wait(), no?
-
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/