Skip to content

Commit

Permalink
Merge branch 'kmemleak' of git://linux-arm.org/linux-2.6
Browse files Browse the repository at this point in the history
* 'kmemleak' of git://linux-arm.org/linux-2.6:
  kmemleak: Remove alloc_bootmem annotations introduced in the past
  kmemleak: Add callbacks to the bootmem allocator
  kmemleak: Allow partial freeing of memory blocks
  kmemleak: Trace the kmalloc_large* functions in slub
  kmemleak: Scan objects allocated during a scanning episode
  kmemleak: Do not acquire scan_mutex in kmemleak_open()
  kmemleak: Remove the reported leaks number limitation
  kmemleak: Add more cond_resched() calls in the scanning thread
  kmemleak: Renice the scanning thread to +10
  • Loading branch information
torvalds committed Jul 12, 2009
2 parents dd0d9a4 + 264ef8a commit 7638d53
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 94 deletions.
4 changes: 4 additions & 0 deletions include/linux/kmemleak.h
Expand Up @@ -27,6 +27,7 @@ extern void kmemleak_init(void);
extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
gfp_t gfp);
extern void kmemleak_free(const void *ptr);
extern void kmemleak_free_part(const void *ptr, size_t size);
extern void kmemleak_padding(const void *ptr, unsigned long offset,
size_t size);
extern void kmemleak_not_leak(const void *ptr);
Expand Down Expand Up @@ -71,6 +72,9 @@ static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
static inline void kmemleak_free(const void *ptr)
{
}
static inline void kmemleak_free_part(const void *ptr, size_t size)
{
}
static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags)
{
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/slub_def.h
Expand Up @@ -11,6 +11,7 @@
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/kmemtrace.h>
#include <linux/kmemleak.h>

enum stat_item {
ALLOC_FASTPATH, /* Allocation from cpu slab */
Expand Down Expand Up @@ -233,6 +234,7 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
unsigned int order = get_order(size);
void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);

kmemleak_alloc(ret, size, 1, flags);
trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);

return ret;
Expand Down
7 changes: 0 additions & 7 deletions kernel/pid.c
Expand Up @@ -36,7 +36,6 @@
#include <linux/pid_namespace.h>
#include <linux/init_task.h>
#include <linux/syscalls.h>
#include <linux/kmemleak.h>

#define pid_hashfn(nr, ns) \
hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
Expand Down Expand Up @@ -513,12 +512,6 @@ void __init pidhash_init(void)
pid_hash = alloc_bootmem(pidhash_size * sizeof(*(pid_hash)));
if (!pid_hash)
panic("Could not alloc pidhash!\n");
/*
* pid_hash contains references to allocated struct pid objects and it
* must be scanned by kmemleak to avoid false positives.
*/
kmemleak_alloc(pid_hash, pidhash_size * sizeof(*(pid_hash)), 0,
GFP_KERNEL);
for (i = 0; i < pidhash_size; i++)
INIT_HLIST_HEAD(&pid_hash[i]);
}
Expand Down
6 changes: 6 additions & 0 deletions mm/bootmem.c
Expand Up @@ -12,6 +12,7 @@
#include <linux/pfn.h>
#include <linux/bootmem.h>
#include <linux/module.h>
#include <linux/kmemleak.h>

#include <asm/bug.h>
#include <asm/io.h>
Expand Down Expand Up @@ -335,6 +336,8 @@ void __init free_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
{
unsigned long start, end;

kmemleak_free_part(__va(physaddr), size);

start = PFN_UP(physaddr);
end = PFN_DOWN(physaddr + size);

Expand All @@ -354,6 +357,8 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
{
unsigned long start, end;

kmemleak_free_part(__va(addr), size);

start = PFN_UP(addr);
end = PFN_DOWN(addr + size);

Expand Down Expand Up @@ -516,6 +521,7 @@ static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) +
start_off);
memset(region, 0, size);
kmemleak_alloc(region, size, 1, 0);
return region;
}

Expand Down

0 comments on commit 7638d53

Please sign in to comment.