Messages in this thread |  | | Date | Fri, 5 Oct 2001 13:55:05 +0100 (BST) | From | Hugh Dickins <> | Subject | Re: __get_free_pages(): is the MEM really mine? |
| |
On Mon, 1 Oct 2001, Bernd Harries wrote: > > I wonder why only I see problems so far. Maybe it's because I also mmap() > that RAM to user space?
Probably.
munmap() will handle each order-0-page of your order-9 allocation separately. __get_free_pages gave you count 1 on the first of those order-0-pages, leaving count 0 on the rest. I don't know whether you're following the mmap-makes-all-pages-present model (using remap_page_range), or the fault-page-by-page model (supplying your own nopage function). But either way it sounds like you bump each page count by 1 when you map it in, and then when it's unmapped the count goes down to 0 on all the later order-0-pages, so they get freed before you're done with them.
Either you should force page count 1 on each of the order-0-pages before you mmap them in (and raise count to 2); or you should set the Reserved bit on each them, and clear it before freeing (see use of mem_map_reserve and mem_map_unreserve in various drivers/sound sources using remap_page_range; there's also a couple of examples of the nopage method down there too).
Hugh
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |