Re: Memory Restriction in Kext
Re: Memory Restriction in Kext
- Subject: Re: Memory Restriction in Kext
- From: Michael Smith <email@hidden>
- Date: Thu, 23 Aug 2007 23:50:06 -0700
On Aug 23, 2007, at 11:38 AM, JanakiRam wrote:
I'm a newbie to the kernel programming. Can any one
clarify my following querie(s).
i) Is there any restriction imposed on the memory to be
allocated inside a KEXT and its related functions .
There are several restrictions. They are all pretty generous; if you
hit any of them, you have a serious design problem.
ii) If so , Whats the maximum limit ?
There are serveral.
- Kernel stacks are small. Do not allocate large auto variables.
Ever.
- Small allocations come from the zone allocator. The zone submap
is constrained; the constraint may vary based on the amount of
physical memory in the system. It is, fortunately, fairly fast.
- Larger allocations come from the kernel map. You are constrained
here by both the available kernel virtual space and the physical
memory present in the system, since kernel memory is normally wired
down.
iii) Can i allocate 1MB ( i.e. char [1024][1024] )
memory in generic kext start function ?
Yes, although you may want to do this with an
IOBufferMemoryDescriptor so that you have the memory pre-wrapped for
I/O purposes.
As a general rule, however, if you are allocating large amounts of
memory in a driver it's because you think that copying into/out of
that memory is a good idea.
Usually, you'll be wrong about that. You should, wherever possible,
pursue designs that avoid copying, intermediate buffers, handoff
between threads and other such obscenities. 8)
= Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden