User: Password:
|
|
Subscribe / Log in / New account

ashmem

ashmem

Posted Dec 21, 2011 9:51 UTC (Wed) by josh (subscriber, #17465)
In reply to: ashmem by neilbrown
Parent article: Bringing Android closer to the mainline

Linux already supports anonymous shared memory; you can call mmap with MAP_SHARED|MAP_ANONYMOUS to get an anonymous shared region. Child processes will inherit that region. The only difference: you can't get a file descriptor for the region, and thus you can't pass it around like a file descriptor, such as through a pipe. If ashmem works like a natural extension of that, allowing the association of a file descriptor with the mapping to allow passing it around, then it seems like a very reasonable addition.

In theory, a trusted process could serve the same function in userspace, by using the new cross-memory attach (CMA) mechanism. Processes could ask the trusted process to create a new piece of anonymous memory for them to use, and multiple processes could attach to that memory. (The permission issues would prove difficult to deal with, but not impossible; the trusted process would need to manage a set of cooperating processes with various credentials.) However, I think it makes sense to handle this in a much more natural way through the kernel, by associating a file descriptor with anonymous shared memory.


(Log in to post comments)

ashmem

Posted Dec 21, 2011 12:37 UTC (Wed) by swetland (guest, #63414) [Link]

Yup -- that was the main limitation (not being able to get an fd to pass to another process for mapping) that ashmem was working around.

It also (though this feature came later) has functionality which allows a process to indicate ranges of pages which are not needed and may be reclaimed by the kernel in the event of a low memory situation. The idea being that using this to mark caches, etc, gives the kernel the ability to reclaim some pages as an alternative to invoking the low memory killer to obtain more memory in a pinch.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds