<feed xmlns='http://www.w3.org/2005/Atom'>
<title>pm24.git/lib/debugobjects.c, branch v4.18-rc2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<id>https://git.kobert.dev/pm24.git/atom?h=v4.18-rc2</id>
<link rel='self' href='https://git.kobert.dev/pm24.git/atom?h=v4.18-rc2'/>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/'/>
<updated>2018-03-14T19:20:01Z</updated>
<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.kobert.dev/pm24.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.kobert.dev/pm24.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.kobert.dev/pm24.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.kobert.dev/pm24.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.kobert.dev/pm24.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.kobert.dev/pm24.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.kobert.dev/pm24.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>
<entry>
<title>sched/headers: Prepare for new header dependencies before moving code to &lt;linux/sched/task_stack.h&gt;</title>
<updated>2017-03-02T07:42:36Z</updated>
<author>
<name>Ingo Molnar</name>
<email>mingo@kernel.org</email>
</author>
<published>2017-02-08T17:51:37Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=68db0cf10678630d286f4bbbbdfa102951a35faa'/>
<id>urn:sha1:68db0cf10678630d286f4bbbbdfa102951a35faa</id>
<content type='text'>
We are going to split &lt;linux/sched/task_stack.h&gt; out of &lt;linux/sched.h&gt;, which
will have to be picked up from other headers and a couple of .c files.

Create a trivial placeholder &lt;linux/sched/task_stack.h&gt; file that just
maps to &lt;linux/sched.h&gt; to make this patch obviously correct and
bisectable.

Include the new header in the files that are going to need it.

Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Mike Galbraith &lt;efault@gmx.de&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>debugobjects: Improve variable naming</title>
<updated>2017-02-10T08:53:04Z</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2017-02-07T21:40:30Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=0cad93c3453fc9d11692d3924ac3a520821bbf64'/>
<id>urn:sha1:0cad93c3453fc9d11692d3924ac3a520821bbf64</id>
<content type='text'>
As suggested by Ingo, the debug_objects_alloc counter is now renamed to
debug_objects_allocated with minor twist in comment and debug output.

Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Link: http://lkml.kernel.org/r/1486503630-1501-1-git-send-email-longman@redhat.com
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>debugobjects: Reduce contention on the global pool_lock</title>
<updated>2017-02-05T16:09:32Z</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2017-01-05T20:17:05Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=858274b6a13b4db0e6fb451eea7f8817c42426a7'/>
<id>urn:sha1:858274b6a13b4db0e6fb451eea7f8817c42426a7</id>
<content type='text'>
On a large SMP system with many CPUs, the global pool_lock may become
a performance bottleneck as all the CPUs that need to allocate or
free debug objects have to take the lock. That can sometimes cause
soft lockups like:

 NMI watchdog: BUG: soft lockup - CPU#35 stuck for 22s! [rcuos/1:21]
 ...
 RIP: 0010:[&lt;ffffffff817c216b&gt;]  [&lt;ffffffff817c216b&gt;]
	_raw_spin_unlock_irqrestore+0x3b/0x60
 ...
 Call Trace:
  [&lt;ffffffff813f40d1&gt;] free_object+0x81/0xb0
  [&lt;ffffffff813f4f33&gt;] debug_check_no_obj_freed+0x193/0x220
  [&lt;ffffffff81101a59&gt;] ? trace_hardirqs_on_caller+0xf9/0x1c0
  [&lt;ffffffff81284996&gt;] ? file_free_rcu+0x36/0x60
  [&lt;ffffffff81251712&gt;] kmem_cache_free+0xd2/0x380
  [&lt;ffffffff81284960&gt;] ? fput+0x90/0x90
  [&lt;ffffffff81284996&gt;] file_free_rcu+0x36/0x60
  [&lt;ffffffff81124c23&gt;] rcu_nocb_kthread+0x1b3/0x550
  [&lt;ffffffff81124b71&gt;] ? rcu_nocb_kthread+0x101/0x550
  [&lt;ffffffff81124a70&gt;] ? sync_exp_work_done.constprop.63+0x50/0x50
  [&lt;ffffffff810c59d1&gt;] kthread+0x101/0x120
  [&lt;ffffffff81101a59&gt;] ? trace_hardirqs_on_caller+0xf9/0x1c0
  [&lt;ffffffff817c2d32&gt;] ret_from_fork+0x22/0x50

To reduce the amount of contention on the pool_lock, the actual
kmem_cache_free() of the debug objects will be delayed if the pool_lock
is busy. This will temporarily increase the amount of free objects
available at the free pool when the system is busy. As a result,
the number of kmem_cache allocation and freeing is reduced.

To further reduce the lock operations free debug objects in batches of
four.

Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Cc: Christian Borntraeger &lt;borntraeger@de.ibm.com&gt;
Cc: "Du Changbin" &lt;changbin.du@intel.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Jan Stancek &lt;jstancek@redhat.com&gt;
Link: http://lkml.kernel.org/r/1483647425-4135-4-git-send-email-longman@redhat.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
</feed>
