Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance of IOMemoryDescriptor::prepare on contiguous, wired memory



On Wednesday, December 18, 2002, at 10:00 PM, "Sean McBride" <email@hidden> wrote:

Lets say I do the following:

- IOMallocContiguous some memory in a driver
- map this memory to a user process
- change the (entire) contents of the memory (in the user process)
- pass the user address to a (different) driver
- create an IOMemoryDescriptor for this user address
- call IOMemoryDescriptor->prepare
- call IOMemoryDescriptor->getPhysicalAddress
- do some DMA

Since I know the memory is contiguous and wired, I had expected prepare()
to be very fast. However, it sometimes takes up to 11 ms (Dual 450 G4)!

That's not surprising. You know it's wired and contiguous, but the VM
doesn't (and can't) know or assume that.

Is my expectation of prepare() invalid?

What expectation do you have?

Is it safe to not call prepare
(yet call getPhysicalAddress) when I know the memory is contiguous and wired?

That would be the wrong thing to do, and you could expect it to come back and
bite you later.

In your case, the VM has no way of knowing that the virtual address range that
you are passing it is mapped to memory that is already wired. Wiring memory
is deathly slow in MacOS X, and you pay the entire cost even though the pages
are already pinned down because you're not doing it against the original region.

To avoid this, you'd want to pass a cookie across so that you could use the
originally allocated and wired region from the first driver in the second, or
alternatively, since you appear to be running a transform of some kind, have
the user process work from a buffer owned and known by the first driver and
into a buffer owned and known by the second. This could avoid having to pay
the setup costs more than once, assuming there aren't other constraints you
haven't mentioned.

On a tangent, since you quite possibly work for or with the people responsible
for the hardware design(s) in question, I should point out that from an OS
perspective, hardware that requires contiguous allocations is Bad, mmkay?

Regards,
Mike
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.