-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add mm map #8026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mm map #8026
Conversation
|
There were some issues left after re-base. I commented them, and will fix those tomorrow. |
|
BTW, it's better to migrate the ram map and anon map to the new interface, which is clearer and also demo that new mmap interface is flexible enough to support the complex case. |
Agree. I can move ram mapping (MAP_PRIVATE, MAP_ANONYMOUS) to an own file at least. It should also have an own CONFIG flag (can make it default to y to keep current functionality). I find this interface quite useless as it is now, it doesn't even support mapping from page pool. rammaps deserve an own PR, but I'll see if I can make use of the mm_map in it already as you suggested above. That sould be extended to also support MAP_SHARED. I find this interface quite useless as it is now, and this is why I don't like touching it too much in this PR. I think that after we agree on the interface for storing the mappings, I will present the posix SHMFS; this is an interface that I know is interesting to many. For example we have implemented an own version of PX4 uORB publish subscribe interface with this, and it is really nice, since it works inter process both in linux and nuttx (in all flat, protected and kernel). There are also other pubsub interfaces which could utilize this. |
Yes, but it's useful for no MMU case. it's a first step to incorporate rammap into the new mmap interface. Once it's done, we can support page pool for MMU.
supporting MAP_SHARED require we save some mapping info to inode, but I think it's very important feature to make rammap usefull.
Yes, I think so.
Nice feature. Where can I find the document or source code? is it bas on PX4 uORB or this new one: #6653 |
It is based on PX4 uORB; the project that I am working with atm. is drone project and the uORB needs to be a drop-in replacement for PX4 |
3dd971b to
79586c7
Compare
4684489 to
df4cd3f
Compare
Added patches for this |
|
The rammaps went broken, I will need to fix it still. It was a bit too quick... |
|
now done. Rammaps doesn't need the private mapping structure for anything, all info fits in map_entry_s. So removed that too. |
|
re-based to latest master |
|
One way to remove group argument from mm_map_remove is just to put a restriction that "driver mustn't call mm_map_remove in the munmap function if the group is unknown (NULL)". Then you would get rid of the iffy goto in mm_map_remove function as well. All entries can be deleted directly in mm_map_destroy() regardless of the current context. |
|
@xiaoxiang781216 : Here is a commit which shows how the IF would look like if you added the mm_map_s as an argument to every function (the option 1. you mentioned avove): In my opinion it just complicates things for every driver using the interface, since they need to fetch & dig into the task_group structure, even if they don't need it for anything else. But if you think that this would look better, I am fine with it. Please let me know which way you insist this to be, I will then clean up the git history accordingly. |
My comment isn't to remove group from mm_map_remove, but make the usage consistent.
Yes, I think it isn't good to let's driver dig into task_group struct. Let's come back to my first suggestion but reject by you: |
04fc90d to
4ed2485
Compare
Any other part of the task_group_s doesn't belong to mm_map code, so it is really better to just pass mm_map_s where it is needed. I decoupled this from task_struct internals by adding helper macros into sched.h |
f9c2645 to
a6dc0cb
Compare
To be able to directly store also other than pointer types Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
|
re-based to current master |
The task_group specific list can be used to store information about mmappings. For a driver or filesystem performing mmap can also enable munmap by adding an item to this list using mm_map_add(). The item is then returned in the corresponding munmap call. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Replace static gs_vaddr with a new dynamic mapping list. Collecting all this kind of virtual memory mappings into a single structure makes things more consistent. This still leaves the task group specific granule alloocator, gs_handle, in the task group Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
xiaoxiang781216
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Summary
This PR adds a simple linked list to store mmap mappings, to support unmap.
The drivers which want to store mappings can use mm_map_add and mm_map_rm to register/unregister mappings to the task_group.
This PR also takes the mm_map into use in mm/shm driver and anonymous mappings. The sys-v shm interface still maintains it's own granule allocator in task_group
This PR also takes the mm_map into use in "rammap"
Impact
Adds interface to make it possible to do munmap
Adds munmap for anonymous mappings
Fixes mm/shm for process exit; previously it doesn't free the reserved physical pages if they are mapped at process exit
Testing
Tested in stm32 and mpfs riscv builds, together with inhouse posix shmfs driver