diff options
author | Vegard Nossum <vegard.nossum@gmail.com> | 2008-11-25 10:55:53 -0500 |
---|---|---|
committer | Vegard Nossum <vegard.nossum@gmail.com> | 2009-06-15 09:48:33 -0400 |
commit | b1eeab67682a5e397aecf172046b3a8bd4808ae4 (patch) | |
tree | c357b6ac1945dc8beecc2f8c4d84660ad8d35aae /mm/slab.c | |
parent | 9b5cab31897e9e89e36c0c2a89b16b93ff1a971a (diff) |
kmemcheck: add hooks for the page allocator
This adds support for tracking the initializedness of memory that
was allocated with the page allocator. Highmem requests are not
tracked.
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
[build fix for !CONFIG_KMEMCHECK]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
[rebased for mainline inclusion]
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1612,7 +1612,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) | |||
1612 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) | 1612 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) |
1613 | flags |= __GFP_RECLAIMABLE; | 1613 | flags |= __GFP_RECLAIMABLE; |
1614 | 1614 | ||
1615 | page = alloc_pages_node(nodeid, flags, cachep->gfporder); | 1615 | page = alloc_pages_node(nodeid, flags | __GFP_NOTRACK, cachep->gfporder); |
1616 | if (!page) | 1616 | if (!page) |
1617 | return NULL; | 1617 | return NULL; |
1618 | 1618 | ||
@@ -1626,8 +1626,14 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid) | |||
1626 | for (i = 0; i < nr_pages; i++) | 1626 | for (i = 0; i < nr_pages; i++) |
1627 | __SetPageSlab(page + i); | 1627 | __SetPageSlab(page + i); |
1628 | 1628 | ||
1629 | if (kmemcheck_enabled && !(cachep->flags & SLAB_NOTRACK)) | 1629 | if (kmemcheck_enabled && !(cachep->flags & SLAB_NOTRACK)) { |
1630 | kmemcheck_alloc_shadow(cachep, flags, nodeid, page, cachep->gfporder); | 1630 | kmemcheck_alloc_shadow(page, cachep->gfporder, flags, nodeid); |
1631 | |||
1632 | if (cachep->ctor) | ||
1633 | kmemcheck_mark_uninitialized_pages(page, nr_pages); | ||
1634 | else | ||
1635 | kmemcheck_mark_unallocated_pages(page, nr_pages); | ||
1636 | } | ||
1631 | 1637 | ||
1632 | return page_address(page); | 1638 | return page_address(page); |
1633 | } | 1639 | } |
@@ -1641,8 +1647,7 @@ static void kmem_freepages(struct kmem_cache *cachep, void *addr) | |||
1641 | struct page *page = virt_to_page(addr); | 1647 | struct page *page = virt_to_page(addr); |
1642 | const unsigned long nr_freed = i; | 1648 | const unsigned long nr_freed = i; |
1643 | 1649 | ||
1644 | if (kmemcheck_page_is_tracked(page)) | 1650 | kmemcheck_free_shadow(page, cachep->gfporder); |
1645 | kmemcheck_free_shadow(cachep, page, cachep->gfporder); | ||
1646 | 1651 | ||
1647 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) | 1652 | if (cachep->flags & SLAB_RECLAIM_ACCOUNT) |
1648 | sub_zone_page_state(page_zone(page), | 1653 | sub_zone_page_state(page_zone(page), |