Re: [PATCH 1/1] init: fix race between rootfs mount and firmware loading

From: Roman Peniaev
Date: Wed Sep 17 2014 - 09:18:28 EST


On Tue, Sep 16, 2014 at 1:39 AM, Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> On 09/15, Roman Pen wrote:
>>
>> +static DECLARE_COMPLETION(rootfs_mounted);
>> +
>> +void wait_for_rootfs(void)
>> +{
>> + /* Avoid waiting for ourselves */
>> + if (is_global_init(current))
>> + pr_warn("it is not a good idea to wait for rootfs mount from init task\n");
>> + else
>> + wait_for_completion(&rootfs_mounted);
>> +}
>> +
>> +static inline void wake_up_rootfs_waiters(void)
>> +{
>> + complete(&rootfs_mounted);
>> +}
>
> Probably you need complete_all() ?

Yes, of course. My fault.

>
> Otherwise wait_for_rootfs() can return only once, the next call will block
> forever. And perhaps it would be better to use another primitive, even if
> UINT_MAX/2 should be enough.

And why do you think completion is not good for this?
Seems it is impossible to have so many threads on early init, which wait
for rootfs.

Oleg, I prepared version 2 (will be in reply to this email). What I did there:

1/ wait_for_rootfs should be exported, because framework_class.c is a tristate,
thus can be built as module.

2/ replaced completion on wait_event and wake_up_all pair.

3/ did some minor tweaks.

--
Roman
--
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/