-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
kernel module mmap for multiple pages #126
Comments
Hi Nick! Sorry, I don't really know much about this stuff, I just stopped when an example seemed to work! So the things you mentioned, they appear to be bugs on what I had, is that correct? Did you manage to get it working in the end? If you can share you patch, that would be amazing. |
Hi Ciro, no problem! I found that I had to call put_page for the first page only in order for everything to be tracked properly. I read in several places online that freeing the pages should do that automatically, but I consistently got error saying that my group of pages still had a count of 1 even though nothing was using them anymore. After printing out the count value for each page, I found that only the first still had a count value of 1 so I added a call to put_page() in the release function and that fixed everything. After allocating and freeing 64 pages over 230000 times, I still got no errors so I think it's good. My code has changed quite a bit from your original version so I just went back and made the appropriate changes to your code. I'd suggest testing it before committing! Thanks again! Let me know if you have any other questions. Nick P.S. github doesn't like .diff files so I changed it to a .txt |
Awesome, thanks for sharing it. Sorry I couldn't help you :-) but it is good to have that info in public which might help others. If you find any further info, please to share in further comments. Gonna reproduce the patch here:
|
Oh don't worry, you definitely did help! I'll be sure to follow up if I learn anything new. |
Hi Ciro,
First, thank you so much for your mmap example, it saved me a TON of time. I've modified it to use multiple pages (64 pages for my purposes) and it works, but periodically crashes when allocating pages, since some of the pages it's trying to allocate have a count value of 1. I assume this is because the pages aren't properly being freed on previous uses.
I've changed open() to use __get_free_pages() instead of get_zeroed_page(), vm_fault() to find the address of the correct page using vmf->pgoff, and release() to use free_pages() instead of free_page(). Do you know if there is anything else I need to do in order to properly manage the pages? Thank you,
Nick
The text was updated successfully, but these errors were encountered: