04 Apr, 2014

4 commits

  • They don't have to be atomic_t, because they are simple boolean toggles.

    Signed-off-by: Li Zefan
    Acked-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     
  • Remove kmemleak_padding() and kmemleak_release().

    Signed-off-by: Li Zefan
    Acked-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     
  • Currently if kmemleak is disabled, the kmemleak objects can never be
    freed, no matter if it's disabled by a user or due to fatal errors.

    Those objects can be a big waste of memory.

    OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
    1200264 1197433 99% 0.30K 46164 26 369312K kmemleak_object

    With this patch, after kmemleak was disabled you can reclaim memory
    with:

    # echo clear > /sys/kernel/debug/kmemleak

    Also inform users about this with a printk.

    Signed-off-by: Li Zefan
    Acked-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     
  • Currently if you stop kmemleak thread before disabling kmemleak,
    kmemleak objects will be freed and so you won't be able to check
    previously reported leaks.

    With this patch, kmemleak objects won't be freed if there're leaks that
    can be reported.

    Signed-off-by: Li Zefan
    Acked-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     

13 Nov, 2013

1 commit

  • Commit 248ac0e1943a ("mm/vmalloc: remove guard page from between vmap
    blocks") had the side effect of making vmap_area.va_end member point to
    the next vmap_area.va_start. This was creating an artificial reference
    to vmalloc'ed objects and kmemleak was rarely reporting vmalloc() leaks.

    This patch marks the vmap_area containing pointers explicitly and
    reduces the min ref_count to 2 as vm_struct still contains a reference
    to the vmalloc'ed object. The kmemleak add_scan_area() function has
    been improved to allow a SIZE_MAX argument covering the rest of the
    object (for simpler calling sites).

    Signed-off-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Catalin Marinas
     

12 Sep, 2013

1 commit


28 Feb, 2013

1 commit

  • I'm not sure why, but the hlist for each entry iterators were conceived

    list_for_each_entry(pos, head, member)

    The hlist ones were greedy and wanted an extra parameter:

    hlist_for_each_entry(tpos, pos, head, member)

    Why did they need an extra pos parameter? I'm not quite sure. Not only
    they don't really need it, it also prevents the iterator from looking
    exactly like the list iterator, which is unfortunate.

    Besides the semantic patch, there was some manual work required:

    - Fix up the actual hlist iterators in linux/list.h
    - Fix up the declaration of other iterators based on the hlist ones.
    - A very small amount of places were using the 'node' parameter, this
    was modified to use 'obj->member' instead.
    - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
    properly, so those had to be fixed up manually.

    The semantic patch which is mostly the work of Peter Senna Tschudin is here:

    @@
    iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;

    type T;
    expression a,c,d,e;
    identifier b;
    statement S;
    @@

    -T b;

    [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
    [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
    [akpm@linux-foundation.org: checkpatch fixes]
    [akpm@linux-foundation.org: fix warnings]
    [akpm@linux-foudnation.org: redo intrusive kvm changes]
    Tested-by: Peter Senna Tschudin
    Acked-by: Paul E. McKenney
    Signed-off-by: Sasha Levin
    Cc: Wu Fengguang
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sasha Levin
     

24 Feb, 2013

1 commit

  • Add 2 helpers (zone_end_pfn() and zone_spans_pfn()) to reduce code
    duplication.

    This also switches to using them in compaction (where an additional
    variable needed to be renamed), page_alloc, vmstat, memory_hotplug, and
    kmemleak.

    Note that in compaction.c I avoid calling zone_end_pfn() repeatedly
    because I expect at some point the sycronization issues with start_pfn &
    spanned_pages will need fixing, either by actually using the seqlock or
    clever memory barrier usage.

    Signed-off-by: Cody P Schafer
    Cc: David Hansen
    Cc: Catalin Marinas
    Cc: Johannes Weiner
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cody P Schafer
     

19 Dec, 2012

1 commit


09 Oct, 2012

1 commit

  • kmemleak uses a tree where each node represents an allocated memory object
    in order to quickly find out what object a given address is part of.
    However, the objects don't overlap, so rbtrees are a better choice than
    prio tree for this use. They are both faster and have lower memory
    overhead.

    Tested by booting a kernel with kmemleak enabled, loading the
    kmemleak_test module, and looking for the expected messages.

    Signed-off-by: Michel Lespinasse
    Cc: Rik van Riel
    Cc: Hillf Danton
    Cc: Peter Zijlstra
    Cc: Andrea Arcangeli
    Cc: David Woodhouse
    Acked-by: Catalin Marinas
    Tested-by: Catalin Marinas
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michel Lespinasse
     

23 Sep, 2012

1 commit


21 Jan, 2012

2 commits

  • Commit b6693005 (kmemleak: When the early log buffer is exceeded, report
    the actual number) deferred the disabling of the early logging to
    kmemleak_init(). However, when CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y, the
    early logging was no longer disabled causing __init kmemleak functions
    to be called even after the kernel freed the init memory. This patch
    disables the early logging during kmemleak_init() if kmemleak is left
    disabled.

    Reported-by: Dirk Gouders
    Tested-by: Dirk Gouders
    Tested-by: Josh Boyer
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Kmemleak should only track valid scan areas with a non-zero size.
    Otherwise, such area may reside just at the end of an object and
    kmemleak would report "Adding scan area to unknown object".

    Signed-off-by: Tiejun Chen
    Signed-off-by: Catalin Marinas

    Tiejun Chen
     

03 Dec, 2011

5 commits

  • Ensure that memory hotplug can co-exist with kmemleak
    by taking the hotplug lock before scanning the memory
    banks.

    Signed-off-by: Laura Abbott
    Signed-off-by: Catalin Marinas

    Laura Abbott
     
  • This patch adds kmemleak callbacks from the percpu allocator, reducing a
    number of false positives caused by kmemleak not scanning such memory
    blocks. The percpu chunks are never reported as leaks because of current
    kmemleak limitations with the __percpu pointer not pointing directly to
    the actual chunks.

    Reported-by: Huajun Li
    Acked-by: Christoph Lameter
    Acked-by: Tejun Heo
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • If an error fatal to kmemleak (like memory allocation failure) happens,
    kmemleak disables itself but it also removes the access to any
    previously found memory leaks. This patch allows read-only access to the
    kmemleak debugfs interface but disables any other action.

    Reported-by: Nick Bowler
    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Just telling that the early log buffer has been exceeded doesn't mean
    much. This patch moves the error printing to the kmemleak_init()
    function and displays the actual calls to the kmemleak API during early
    logging.

    Signed-off-by: Catalin Marinas

    Catalin Marinas
     
  • Based on initial patch by Steven Rostedt.

    Early kmemleak warnings did not show where the actual kmemleak API had
    been called from but rather just a backtrace to the kmemleak_init()
    function. By having all early kmemleak logs record the stack_trace, we
    can have kmemleak_init() write exactly where the problem occurred. This
    patch adds the setting of the kmemleak_warning variable every time a
    kmemleak warning is issued. The kmemleak_init() function checks this
    variable during early log replaying and prints the log trace if there
    was any warning.

    Reported-by: Steven Rostedt
    Cc: Andrew Morton
    Signed-off-by: Catalin Marinas
    Acked-by: Steven Rostedt

    Catalin Marinas
     

31 Oct, 2011

1 commit


27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

20 May, 2011

1 commit


31 Mar, 2011

1 commit


28 Jan, 2011

1 commit

  • This patch adds __GFP_NORETRY and __GFP_NOMEMALLOC flags to the kmemleak
    metadata allocations so that it has a smaller effect on the users of the
    kernel slab allocator. Since kmemleak allocations can now fail more
    often, this patch also reduces the verbosity by passing __GFP_NOWARN and
    not dumping the stack trace when a kmemleak allocation fails.

    Signed-off-by: Catalin Marinas
    Reported-by: Toralf Förster
    Acked-by: Pekka Enberg
    Acked-by: David Rientjes
    Cc: Ted Ts'o

    Catalin Marinas
     

09 Aug, 2010

1 commit


19 Jul, 2010

3 commits


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

18 Dec, 2009

1 commit

  • * 'kmemleak' of git://linux-arm.org/linux-2.6:
    kmemleak: fix kconfig for crc32 build error
    kmemleak: Reduce the false positives by checking for modified objects
    kmemleak: Show the age of an unreferenced object
    kmemleak: Release the object lock before calling put_object()
    kmemleak: Scan the _ftrace_events section in modules
    kmemleak: Simplify the kmemleak_scan_area() function prototype
    kmemleak: Do not use off-slab management with SLAB_NOLEAKTRACE

    Linus Torvalds
     

09 Nov, 2009

1 commit


29 Oct, 2009

3 commits


28 Oct, 2009

1 commit


10 Oct, 2009

2 commits


11 Sep, 2009

1 commit


09 Sep, 2009

3 commits