diff options
author | Marek Szyprowski <[email protected]> | 2012-12-20 15:05:18 -0800 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2012-12-20 17:40:19 -0800 |
commit | bcc2b02f4c1b36bc67272df7119b75bac78525ab (patch) | |
tree | db4b0ad1693c2b25da06655b6e7dd409c85ec120 | |
parent | b66c5984017533316fd1951770302649baf1aa33 (diff) |
mm: cma: WARN if freed memory is still in use
Memory returned to free_contig_range() must have no other references.
Let kernel to complain loudly if page reference count is not equal to 1.
[[email protected]: support sparsemem]
Signed-off-by: Marek Szyprowski <[email protected]>
Reviewed-by: Kyungmin Park <[email protected]>
Acked-by: Michal Nazarewicz <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | mm/page_alloc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2ad2ad168efe..4ba5e37127fc 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5978,8 +5978,15 @@ done: void free_contig_range(unsigned long pfn, unsigned nr_pages) { - for (; nr_pages--; ++pfn) - __free_page(pfn_to_page(pfn)); + unsigned int count = 0; + + for (; nr_pages--; pfn++) { + struct page *page = pfn_to_page(pfn); + + count += page_count(page) != 1; + __free_page(page); + } + WARN(count != 0, "%d pages are still in use!\n", count); } #endif |