<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/lib/debugobjects.c, branch v4.19.187</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.19.187</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.19.187'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2018-12-17T08:24:41Z</updated>
<entry>
<title>debugobjects: avoid recursive calls with kmemleak</title>
<updated>2018-12-17T08:24:41Z</updated>
<author>
<name>Qian Cai</name>
<email>cai@gmx.us</email>
</author>
<published>2018-11-30T22:09:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=53f1c27ac5d51cbd1ead30d69180cb5067cb62b0'/>
<id>urn:sha1:53f1c27ac5d51cbd1ead30d69180cb5067cb62b0</id>
<content type='text'>
[ Upstream commit 8de456cf87ba863e028c4dd01bae44255ce3d835 ]

CONFIG_DEBUG_OBJECTS_RCU_HEAD does not play well with kmemleak due to
recursive calls.

fill_pool
  kmemleak_ignore
    make_black_object
      put_object
        __call_rcu (kernel/rcu/tree.c)
          debug_rcu_head_queue
            debug_object_activate
              debug_object_init
                fill_pool
                  kmemleak_ignore
                    make_black_object
                      ...

So add SLAB_NOLEAKTRACE to kmem_cache_create() to not register newly
allocated debug objects at all.

Link: http://lkml.kernel.org/r/20181126165343.2339-1-cai@gmx.us
Signed-off-by: Qian Cai &lt;cai@gmx.us&gt;
Suggested-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Acked-by: Waiman Long &lt;longman@redhat.com&gt;
Acked-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>debugobjects: Remove redundant NULL pointer check</title>
<updated>2018-08-02T11:53:04Z</updated>
<author>
<name>Zhong Jiang</name>
<email>zhongjiang@huawei.com</email>
</author>
<published>2018-07-31T16:24:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44'/>
<id>urn:sha1:3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44</id>
<content type='text'>
kmem_cache_destroy() has a built in NULL pointer check, so the one at the
call can be removed.

Signed-off-by: Zhong Jiang &lt;zhongjiang@huawei.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: &lt;longman@redhat.com&gt;
Cc: &lt;arnd@arndb.de&gt;
Cc: &lt;yang.shi@linux.alibaba.com&gt;
Link: https://lkml.kernel.org/r/1533054298-35824-1-git-send-email-zhongjiang@huawei.com

</content>
</entry>
<entry>
<title>debugobjects: Make stack check warning more informative</title>
<updated>2018-07-30T19:36:37Z</updated>
<author>
<name>Joel Fernandes (Google)</name>
<email>joel@joelfernandes.org</email>
</author>
<published>2018-07-23T21:25:31Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fc91a3c4c27acdca0bc13af6fbb68c35cfd519f2'/>
<id>urn:sha1:fc91a3c4c27acdca0bc13af6fbb68c35cfd519f2</id>
<content type='text'>
While debugging an issue debugobject tracking warned about an annotation
issue of an object on stack. It turned out that the issue was due to the
object in concern being on a different stack which was due to another
issue.

Thomas suggested to print the pointers and the location of the stack for
the currently running task. This helped to figure out that the object was
on the wrong stack.

As this is general useful information for debugging similar issues, make
the error message more informative by printing the pointers.

[ tglx: Massaged changelog ]

Signed-off-by: Joel Fernandes (Google) &lt;joel@joelfernandes.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Waiman Long &lt;longman@redhat.com&gt;
Acked-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Cc: kernel-team@android.com
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Cc: astrachan@google.com
Link: https://lkml.kernel.org/r/20180723212531.202328-1-joel@joelfernandes.org

</content>
</entry>
<entry>
<title>debugobjects: Avoid another unused variable warning</title>
<updated>2018-03-14T19:20:01Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2018-03-13T13:18:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=163cf842f5837334bc69aaf09ad38e11f4573914'/>
<id>urn:sha1:163cf842f5837334bc69aaf09ad38e11f4573914</id>
<content type='text'>
debug_objects_maxchecked is only updated in __debug_check_no_obj_freed(),
and only read in debug_objects_maxchecked, unfortunately both of these are
optional and depend on different Kconfig symbols.

When both CONFIG_DEBUG_OBJECTS_FREE and CONFIG_DEBUG_FS are disabled this
warning is emitted:

  lib/debugobjects.c:56:14: error: 'debug_objects_maxchecked' defined but not used [-Werror=unused-variable]

Rather than trying to add more complex #ifdef protections, mark the
variable as __maybe_unused so it can be silently dropped when usused.

Fixes: bd9dcd046509 ("debugobjects: Export max loops counter")
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Cc: Waiman Long &lt;longman@redhat.com&gt;
Link: https://lkml.kernel.org/r/20180313131857.158876-1-arnd@arndb.de

</content>
</entry>
<entry>
<title>debugobjects: Fix debug_objects_freed accounting</title>
<updated>2018-02-22T21:00:24Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2018-02-22T15:52:58Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=04148187aa9df3626168f7429d2287997787e387'/>
<id>urn:sha1:04148187aa9df3626168f7429d2287997787e387</id>
<content type='text'>
The removal of the batched object freeing has caused the debug_objects_freed
to become read-only, and the reading is inside an ifdef, so gcc warns that it
is completely unused without CONFIG_DEBUG_FS:

lib/debugobjects.c:71:14: error: 'debug_objects_freed' defined but not used [-Werror=unused-variable]

Assuming we are still interested in this number, this adds back code to
keep track of the freed objects.

Fixes: 636e1970fd7d ("debugobjects: Use global free list in free_object()")
Suggested-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Acked-by: Waiman Long &lt;longman@redhat.com&gt;
Link: https://lkml.kernel.org/r/20180222155335.1647466-1-arnd@arndb.de

</content>
</entry>
<entry>
<title>debugobjects: Use global free list in __debug_check_no_obj_freed()</title>
<updated>2018-02-13T09:59:18Z</updated>
<author>
<name>Yang Shi</name>
<email>yang.shi@linux.alibaba.com</email>
</author>
<published>2018-02-05T23:18:28Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=1ea9b98b007a662e402551a41a4413becad40a65'/>
<id>urn:sha1:1ea9b98b007a662e402551a41a4413becad40a65</id>
<content type='text'>
__debug_check_no_obj_freed() iterates over the to be freed memory region in
chunks and iterates over the corresponding hash bucket list for each
chunk. This can accumulate to hundred thousands of checked objects. In the
worst case this can trigger the soft lockup detector:

NMI watchdog: BUG: soft lockup - CPU#15 stuck for 22s!
CPU: 15 PID: 110342 Comm: stress-ng-getde
Call Trace:
  [&lt;ffffffff8141177e&gt;] debug_check_no_obj_freed+0x13e/0x220
  [&lt;ffffffff811f8751&gt;] __free_pages_ok+0x1f1/0x5c0
  [&lt;ffffffff811fa785&gt;] __free_pages+0x25/0x40
  [&lt;ffffffff812638db&gt;] __free_slab+0x19b/0x270
  [&lt;ffffffff812639e9&gt;] discard_slab+0x39/0x50
  [&lt;ffffffff812679f7&gt;] __slab_free+0x207/0x270
  [&lt;ffffffff81269966&gt;] ___cache_free+0xa6/0xb0
  [&lt;ffffffff8126c267&gt;] qlist_free_all+0x47/0x80
  [&lt;ffffffff8126c5a9&gt;] quarantine_reduce+0x159/0x190
  [&lt;ffffffff8126b3bf&gt;] kasan_kmalloc+0xaf/0xc0
  [&lt;ffffffff8126b8a2&gt;] kasan_slab_alloc+0x12/0x20
  [&lt;ffffffff81265e8a&gt;] kmem_cache_alloc+0xfa/0x360
  [&lt;ffffffff812abc8f&gt;] ? getname_flags+0x4f/0x1f0
  [&lt;ffffffff812abc8f&gt;] getname_flags+0x4f/0x1f0
  [&lt;ffffffff812abe42&gt;] getname+0x12/0x20
  [&lt;ffffffff81298da9&gt;] do_sys_open+0xf9/0x210
  [&lt;ffffffff81298ede&gt;] SyS_open+0x1e/0x20
  [&lt;ffffffff817d6e01&gt;] entry_SYSCALL_64_fastpath+0x1f/0xc2

The code path might be called in either atomic or non-atomic context, but
in_atomic() can't tell if the current context is atomic or not on a
PREEMPT=n kernel, so cond_resched() can't be used to prevent the
softlockup.

Utilize the global free list to shorten the loop execution time.

[ tglx: Massaged changelog ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: longman@redhat.com
Link: https://lkml.kernel.org/r/1517872708-24207-5-git-send-email-yang.shi@linux.alibaba.com
</content>
</entry>
<entry>
<title>debugobjects: Use global free list in free_object()</title>
<updated>2018-02-13T09:58:59Z</updated>
<author>
<name>Yang Shi</name>
<email>yang.shi@linux.alibaba.com</email>
</author>
<published>2018-02-05T23:18:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=636e1970fd7deaa0d0ee0dfb6ac65fbd690b32d2'/>
<id>urn:sha1:636e1970fd7deaa0d0ee0dfb6ac65fbd690b32d2</id>
<content type='text'>
The newly added global free list allows to avoid lengthy pool_list
iterations in free_obj_work() by putting objects either into the pool list
when the fill level of the pool is below the maximum or by putting them on
the global free list immediately.

As the pool is now guaranteed to never exceed the maximum fill level this
allows to remove the batch removal from pool list in free_obj_work().

Split free_object() into two parts, so the actual queueing function can be
reused without invoking schedule_work() on every invocation.

[ tglx: Remove the batch removal from pool list and massage changelog ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: longman@redhat.com
Link: https://lkml.kernel.org/r/1517872708-24207-4-git-send-email-yang.shi@linux.alibaba.com

</content>
</entry>
<entry>
<title>debugobjects: Add global free list and the counter</title>
<updated>2018-02-13T09:58:58Z</updated>
<author>
<name>Yang Shi</name>
<email>yang.shi@linux.alibaba.com</email>
</author>
<published>2018-02-05T23:18:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=36c4ead6f6dfbbe777d3d7e9cc8702530b71a94f'/>
<id>urn:sha1:36c4ead6f6dfbbe777d3d7e9cc8702530b71a94f</id>
<content type='text'>
free_object() adds objects to the pool list and schedules work when the
pool list is larger than the pool size.  The worker handles the actual
kfree() of the object by iterating the pool list until the pool size is
below the maximum pool size again.

To iterate the pool list, pool_lock has to be held and the objects which
should be freed() need to be put into temporary storage so pool_lock can be
dropped for the actual kmem_cache_free() invocation. That's a pointless and
expensive exercise if there is a large number of objects to free.

In such a case its better to evaulate the fill level of the pool in
free_objects() and queue the object to free either in the pool list or if
it's full on a separate global free list.

The worker can then do the following simpler operation:

  - Move objects back from the global free list to the pool list if the
    pool list is not longer full.

  - Remove the remaining objects in a single list move operation from the
    global free list and do the kmem_cache_free() operation lockless from
    the temporary list head.

In fill_pool() the global free list is checked as well to avoid real
allocations from the kmem cache.

Add the necessary list head and a counter for the number of objects on the
global free list and export that counter via sysfs:

max_chain     :79
max_loops     :8147
warnings      :0
fixups        :0
pool_free     :1697
pool_min_free :346
pool_used     :15356
pool_max_used :23933
on_free_list  :39
objs_allocated:32617
objs_freed    :16588

Nothing queues objects on the global free list yet. This happens in a
follow up change.

[ tglx: Simplified implementation and massaged changelog ]

Suggested-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: longman@redhat.com
Link: https://lkml.kernel.org/r/1517872708-24207-3-git-send-email-yang.shi@linux.alibaba.com

</content>
</entry>
<entry>
<title>debugobjects: Export max loops counter</title>
<updated>2018-02-13T09:58:58Z</updated>
<author>
<name>Yang Shi</name>
<email>yang.shi@linux.alibaba.com</email>
</author>
<published>2018-02-05T23:18:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bd9dcd046509cd5355605e43791eacee8bf5e40f'/>
<id>urn:sha1:bd9dcd046509cd5355605e43791eacee8bf5e40f</id>
<content type='text'>
__debug_check_no_obj_freed() can be an expensive operation depending on the
size of memory freed. It already exports the maximum chain walk length via
debugfs, but this only records the maximum of a single memory chunk.

Though there is no information about the total number of objects inspected
for a __debug_check_no_obj_freed() operation, which might be significantly
larger when a huge memory region is freed.

Aggregate the number of objects inspected for a single invocation of
__debug_check_no_obj_freed() and export it via sysfs.

The resulting output of /sys/kernel/debug/debug_objects/stats looks like:

max_chain     :121
max_checked   :543267
warnings      :0
fixups        :0
pool_free     :1764
pool_min_free :341
pool_used     :86438
pool_max_used :268887
objs_allocated:6068254
objs_freed    :5981076

[ tglx: Renamed the variable to max_checked and adjusted changelog ]

Signed-off-by: Yang Shi &lt;yang.shi@linux.alibaba.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: longman@redhat.com
Link: https://lkml.kernel.org/r/1517872708-24207-2-git-send-email-yang.shi@linux.alibaba.com

</content>
</entry>
<entry>
<title>debugobjects: Make kmemleak ignore debug objects</title>
<updated>2017-08-14T14:51:01Z</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2017-08-14T13:52:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=caba4cbbd27d755572730801ac34fe063fc40a32'/>
<id>urn:sha1:caba4cbbd27d755572730801ac34fe063fc40a32</id>
<content type='text'>
The allocated debug objects are either on the free list or in the
hashed bucket lists. So they won't get lost. However if both debug
objects and kmemleak are enabled and kmemleak scanning is done
while some of the debug objects are transitioning from one list to
the others, false negative reporting of memory leaks may happen for
those objects. For example,

[38687.275678] kmemleak: 12 new suspected memory leaks (see
/sys/kernel/debug/kmemleak)
unreferenced object 0xffff92e98aabeb68 (size 40):
  comm "ksmtuned", pid 4344, jiffies 4298403600 (age 906.430s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 d0 bc db 92 e9 92 ff ff  ................
    01 00 00 00 00 00 00 00 38 36 8a 61 e9 92 ff ff  ........86.a....
  backtrace:
    [&lt;ffffffff8fa5378a&gt;] kmemleak_alloc+0x4a/0xa0
    [&lt;ffffffff8f47c019&gt;] kmem_cache_alloc+0xe9/0x320
    [&lt;ffffffff8f62ed96&gt;] __debug_object_init+0x3e6/0x400
    [&lt;ffffffff8f62ef01&gt;] debug_object_activate+0x131/0x210
    [&lt;ffffffff8f330d9f&gt;] __call_rcu+0x3f/0x400
    [&lt;ffffffff8f33117d&gt;] call_rcu_sched+0x1d/0x20
    [&lt;ffffffff8f4a183c&gt;] put_object+0x2c/0x40
    [&lt;ffffffff8f4a188c&gt;] __delete_object+0x3c/0x50
    [&lt;ffffffff8f4a18bd&gt;] delete_object_full+0x1d/0x20
    [&lt;ffffffff8fa535c2&gt;] kmemleak_free+0x32/0x80
    [&lt;ffffffff8f47af07&gt;] kmem_cache_free+0x77/0x350
    [&lt;ffffffff8f453912&gt;] unlink_anon_vmas+0x82/0x1e0
    [&lt;ffffffff8f440341&gt;] free_pgtables+0xa1/0x110
    [&lt;ffffffff8f44af91&gt;] exit_mmap+0xc1/0x170
    [&lt;ffffffff8f29db60&gt;] mmput+0x80/0x150
    [&lt;ffffffff8f2a7609&gt;] do_exit+0x2a9/0xd20

The references in the debug objects may also hide a real memory leak.

As there is no point in having kmemleak to track debug object
allocations, kmemleak checking is now disabled for debug objects.

Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Link: http://lkml.kernel.org/r/1502718733-8527-1-git-send-email-longman@redhat.com

</content>
</entry>
</feed>
