Re: Recommendation for activating a deferred module init in the kernel

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tim Bird <tim.bird@...>
Cc: linux-embedded <linux-embedded@...>, linux kernel <linux-kernel@...>
Date: Tuesday, June 17, 2008 - 4:19 pm

On Tue, 17 June 2008 12:52:22 -0700, Tim Bird wrote:

Well, there should be a way to ensure this doesn't hog the cpu at all -
unless it is idle or someone is actually waiting for the initialization
to finish.  Not sure if nice 19 is good enough for that.


If you want to keep things simple - and I believe initially you should -
you can simply do all initializations in one go.  Something like this:

int foo_open(...)
{
	wait_for_deferred_init();
	...
}

static DECLARE_COMPLETION(init_complete);

void wait_for_deferred_init(void)
{
	static atomic_t in_progress = ATOMIC_INIT(-1);

	if (!atomic_inc_not_zero(in_progress) {
		wait_for_completion(init_complete);
		return;
	}

	for (all deferred initcalls)
		foo_init();

	complete(init_complete);
	free_memory();
}

Jörn

-- 
Anything that can go wrong, will.
-- Finagle's Law
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Recommendation for activating a deferred module init in ..., Jörn, (Tue Jun 17, 4:19 pm)
Re: Recommendation for activating a deferred module init in ..., Johannes Stezenbach, (Tue Jun 17, 8:03 pm)
Re: Recommendation for activating a deferred module init in ..., Johannes Stezenbach, (Wed Jun 18, 5:38 am)