[PATCH] UBI: Replace yield() with cond_resched()

Richard Weinberger richard at nod.at
Tue May 8 06:59:15 EDT 2012


Am 08.05.2012 11:02, schrieb Artem Bityutskiy:
> On Tue, 2012-05-08 at 10:26 +0200, Richard Weinberger wrote:
>> The comment above yield()'s definition says:
>>  * If you want to use yield() to wait for something, use wait_event().
>>  * If you want to use yield() to be 'nice' for others, use cond_resched().
>>  * If you still want to use yield(), do not!
>>
>> The yield() usage of UBI really looks like the "be nice for others" case,
>> so use cond_resched().
>>
>> Signed-off-by: Richard Weinberger <richard at nod.at>
>> CC: peterz at infradead.org
>
> I guess we would better sleep for a couple of hundreds of milliseconds
> instead.

So, you'd prefer a msleep_interruptible(500) instead of yield() in this case?

> The purpose was different. If we have I/O error, we hope it is a
> transient failure. E.g., the HW is temporary unavailable because of an
> internal issue. And with yield() we hoped to schedule away for longer
> time than usual and let other processes which may affect that HW go
> forward and do something.

Okay, yield() is clearly the wrong choice here.
cond_resched() is better.

Thanks,
//richard

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120508/f8dc7ed4/attachment.sig>


More information about the linux-mtd mailing list