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

Andrew Morton
2004-08-28T09:36:50Z

William Lee Irwin III <wli@holomorphy.com> 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?