On 10/2/19 8:25 AM, Martin Wilck wrote:
> On Wed, 2019-10-02 at 08:17 -0700, Bart Van Assche wrote:
>>
>> Both loops check the loop termination condition twice. Has it been
>> considered to write these loops such that the loop termination
>> condition
>> is only tested once, e.g. using the following pattern?
>>
>> for (i = 0; i < 10; i++)
>> if (wait_event_timeout(...) > 0)
>> break;
>>
>
> Right, that's probably better. This was just meant as a minimal,
> temporary fix for the already applied patch. I expect Himanshu or Quinn
> to follow up anyway.
>
> I also still think that it'd be better to get the wake_up() calls
> right and not have to loop over wait_event_timeout() at all.
Such a loop is most useful if some status information is reported during
every iteration. An example from the SCSI target code:
do {
ret = wait_event_timeout(se_sess->cmd_list_wq,
percpu_ref_is_zero(&se_sess->cmd_count),
180 * HZ);
list_for_each_entry(cmd, &se_sess->sess_cmd_list, se_cmd_list)
target_show_cmd("session shutdown: still waiting for ",
cmd);
} while (ret <= 0);
Bart.