tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: allocating memory during kernel startup



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

On May 6, 2010, at 10:19 PM, Masao Uebayashi wrote:

On Thu, May 06, 2010 at 02:32:57PM -0400, Michael wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I recently ran into this problem - there is no easy way to determine
wether it is safe to call kmem_alloc() yet ( as in, are we far
enough through startup ) and when we call it too early the whole
thing just hangs.

We have no clear definition of the kernel state - what is boot, startup,
and when it's done.

Yeah, we only have cold and that's not what I need.

Any chance to just have kmem_alloc() immediately return NULL if it
isn't ready yet so we can fail gracefully instead of hanging?

I like panic().

I think that complicating memory allocation in bootstrap is not a good
thing.  What is your purpose?

It's rasops_reconfig(). It may want to autogenerate box drawing characters, which needs to allocate memory, but it can happily live without them and some ports ( macppc for example ) setup a rasops- based console very early in the boot process. In this case rasops_reconfig() should simply skip the character generating process instead of something nasty like a panic to happen. Also, the man page suggests that kmem_alloc(KM_NOSLEEP) would return NULL if memory can't be allocated which would be the case.

have fun
Michael

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQEVAwUBS+Rl5MpnzkX8Yg2nAQIc6gf8DbtjWUHxRRrjdMyVqZ1zC2uMfQrmCDi2
AdTzXDkXt1t8Ef08BiQi5sCx+Rwtm7bfPxM9UCvgJC6DRFBhkUa8mHjfM8c0u/RT
ijz6oHi8LRBzdkC3bMAubBV/khHIHNjJWSD3vmgN3im6V9YCJkipfoGt+MSepqEA
tB5g2NY3O8JxdQQEBe2FIy5PdICfc7BUTcn5wBIAITnm/Lmcr4JZQ+MhHtcLHz51
SX3WBLlyXYeJzUdXY6ZwexxOOSbzrQSCfYEQL0Mop9aTuOSl+4XHoffiZ3e09zdf
Dz/W1YjMaRIEwnmMjQIwcEQCEgmNWWYiEt95Eg23kKnaj1F8gvQA/A==
=9O6K
-----END PGP SIGNATURE-----


Home | Main Index | Thread Index | Old Index