Skip to contentSkip to conversation

mmotm: mm-slub-optimize-alloc-free-fastpath-by-removing-preemption-on-off.patch is causing preemptible splats

DISCUSSION Michal Hocko 6 participants 9 messages Jan 21, 2015 – Jan 22, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
I am getting tons of splats like this:

[  187.593291] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u4:1/24
[  187.593293] caller is debug_smp_processor_id+0x17/0x19
[  187.599127] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[  187.601997]  ffffffff8181786e ffff8800068a3d78 ffffffff8151a4b8 ffffffff81078e0e
[  187.604373]  0000000000000000 ffff8800068a3da8 ffffffff81280ac0 ffff8800068acac8
[  187.606619]  00000000000029b2 ffff880007401500 00000000000000d0 ffff8800068a3db8
[  187.608869] Call Trace:
[  187.609602]  [<ffffffff8151a4b8>] dump_stack+0x4f/0x7c
[  187.615881]  [<ffffffff81078e0e>] ? down_trylock+0x2d/0x37
[  187.617468]  [<ffffffff81280ac0>] check_preemption_disabled+0xe7/0xf9
[  187.619295]  [<ffffffff81280ae9>] debug_smp_processor_id+0x17/0x19
[  187.621055]  [<ffffffff8113b2f6>] kmem_cache_alloc_trace+0x78/0x22e
[  187.622854]  [<ffffffff81088d36>] ? do_syslog+0xb2/0x452
[  187.624376]  [<ffffffff81088d36>] do_syslog+0xb2/0x452
[  187.626030]  [<ffffffff811675b4>] ? __fdget_pos+0x3d/0x43
[  187.627557]  [<ffffffff810745ac>] ? wait_woken+0x5d/0x5d
[  187.629073]  [<ffffffff811675b4>] ? __fdget_pos+0x3d/0x43
[  187.630611]  [<ffffffff811a787b>] kmsg_read+0x2d/0x54
[  187.632069]  [<ffffffff8119c4ff>] proc_reg_read+0x4a/0x6c
[  187.633775]  [<ffffffff8114e4d8>] vfs_read+0xa5/0x141
[  187.635242]  [<ffffffff8114ee35>] SyS_read+0x51/0x8f
[  187.636666]  [<ffffffff81522892>] system_call_fastpath+0x12/0x17
$ grep "BUG: using smp_processor_id" mmap.qcow_serial.log | wc -l
660
after few minutes of runtime when running the current mmotm tree 
(https://git.kernel.org/cgit/linux/kernel/git/mhocko/mm.git/log/?h=since-3.18).

The warning seems to come from this_cpu_ptr which is using my_cpu_offset which is
#define my_cpu_offset per_cpu_offset(smp_processor_id())
if CONFIG_DEBUG_PREEMPT

So it matches the following code in slab_alloc_node resp. slab_free:

        do {
                tid = this_cpu_read(s->cpu_slab->tid);
                c = this_cpu_ptr(s->cpu_slab); <<< HERE
        } while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid));

This is with:
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
CONFIG_DEBUG_PREEMPT=y

I am not sure how to fix this but it sounds like this_cpu_ptr should offer the same preempt expectations as other this_cpu_* functions.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

2015-01-21 14:23 GMT+01:00 Michal Hocko <[email protected]>:

Quoted 16 lines

Hi,
I am getting tons of splats like this:

[ 187.593291] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u4:1/24
[ 187.593293] caller is debug_smp_processor_id+0x17/0x19
[ 187.599127] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[  187.601997]  ffffffff8181786e ffff8800068a3d78 ffffffff8151a4b8 ffffffff81078e0e
[  187.604373]  0000000000000000 ffff8800068a3da8 ffffffff81280ac0 ffff8800068acac8
[  187.606619]  00000000000029b2 ffff880007401500 00000000000000d0 ffff8800068a3db8
[  187.608869] Call Trace:
[  187.609602]  [<ffffffff8151a4b8>] dump_stack+0x4f/0x7c
[  187.615881]  [<ffffffff81078e0e>] ? down_trylock+0x2d/0x37
[  187.617468]  [<ffffffff81280ac0>] check_preemption_disabled+0xe7/0xf9
[  187.619295]  [<ffffffff81280ae9>] debug_smp_processor_id+0x17/0x19
[  187.621055]  [<ffffffff8113b2f6>] kmem_cache_alloc_trace+0x78/0x22e
[  187.622854]  [<ffffffff81088d36>] ? do_syslog+0xb2/0x452
[  187.624376]  [<ffffffff81088d36>] do_syslog+0xb2/0x452
Quoted 8 lines
[  187.626030]  [<ffffffff811675b4>] ? __fdget_pos+0x3d/0x43
[  187.627557]  [<ffffffff810745ac>] ? wait_woken+0x5d/0x5d
[  187.629073]  [<ffffffff811675b4>] ? __fdget_pos+0x3d/0x43
[  187.630611]  [<ffffffff811a787b>] kmsg_read+0x2d/0x54
[  187.632069]  [<ffffffff8119c4ff>] proc_reg_read+0x4a/0x6c
[  187.633775]  [<ffffffff8114e4d8>] vfs_read+0xa5/0x141
[  187.635242]  [<ffffffff8114ee35>] SyS_read+0x51/0x8f
[  187.636666]  [<ffffffff81522892>] system_call_fastpath+0x12/0x17

Same here :) [1] . So actually only ARM seems affected (both armv7 and armv8) because it is the only one which uses smp_processor_id() in my_cpu_offset.

[1] https://lkml.org/lkml/2015/1/20/162

Best regards,
Krzysztof

Quoted 17 lines
$ grep "BUG: using smp_processor_id" mmap.qcow_serial.log | wc -l
660
after few minutes of runtime when running the current mmotm tree
(https://git.kernel.org/cgit/linux/kernel/git/mhocko/mm.git/log/?h=since-3.18).

The warning seems to come from this_cpu_ptr which is using my_cpu_offset which is
#define my_cpu_offset per_cpu_offset(smp_processor_id())
if CONFIG_DEBUG_PREEMPT

So it matches the following code in slab_alloc_node resp. slab_free:

        do {
                tid = this_cpu_read(s->cpu_slab->tid);
                c = this_cpu_ptr(s->cpu_slab); <<< HERE
        } while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid));
Quoted 7 lines

This is with:
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
CONFIG_DEBUG_PREEMPT=y

I am not sure how to fix this but it sounds like this_cpu_ptr should offer the same preempt expectations as other this_cpu_* functions.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw

On Wed 21-01-15 15:06:03, Krzysztof KozA?owski wrote:
[...]

Quoted 3 lines

Same here :) [1] . So actually only ARM seems affected (both armv7 and armv8) because it is the only one which uses smp_processor_id() in my_cpu_offset.

This was on x86_64 with CONFIG_DEBUG_PREEMPT so it is not only ARM specific.

Quoted 1 line

[1] https://lkml.org/lkml/2015/1/20/162

Sorry, have missed this post.

Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer Acked-by Christoph Lameter Acked-by Jesper Dangaard Brouer Tested-by Jesper Dangaard Brouer
#3 lore raw
Quoted 9 lines · On Wed, 21 Jan 2015 15:11:38 +0100 Michal Hocko <[email protected]> wrote:

On Wed 21-01-15 15:06:03, Krzysztof Koz__owski wrote:
[...]

Quoted 3 lines

Same here :) [1] . So actually only ARM seems affected (both armv7 and armv8) because it is the only one which uses smp_processor_id() in my_cpu_offset.

This was on x86_64 with CONFIG_DEBUG_PREEMPT so it is not only ARM specific.

Hopefully mm-slub-optimize-alloc-free-fastpath-by-removing-preemption-on-off-v3.patch will fix this.

The most recent -mmotm was a bit of a trainwreck. I'm scrambling to get the holes plugged so I can get another mmotm out today.

From: Joonsoo Kim <[email protected]>
Subject: mm/slub: optimize alloc/free fastpath by removing preemption on/off

Change from v2:
- use raw_cpu_ptr() rather than this_cpu_ptr() to avoid warning from preemption debug check since this is intended behaviour
- fix typo alogorithm -> algorithm

---

 mm/slub.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/slub.c renamed from mm/slub.c~mm-slub-optimize-alloc-free-fastpath-by-removing-preemption-on-off-v3 +3 -3
diff -puN mm/slub.c~mm-slub-optimize-alloc-free-fastpath-by-removing-preemption-on-off-v3 mm/slub.c
@@ -2404,11 +2404,11 @@ redo:
 	 */
 	do {
 		tid = this_cpu_read(s->cpu_slab->tid);
-		c = this_cpu_ptr(s->cpu_slab);
+		c = raw_cpu_ptr(s->cpu_slab);
 	} while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid));
 
 	/*
-	 * Irqless object alloc/free alogorithm used here depends on sequence
+	 * Irqless object alloc/free algorithm used here depends on sequence
 	 * of fetching cpu_slab's data. tid should be fetched before anything
 	 * on c to guarantee that object and page associated with previous tid
 	 * won't be used with current tid. If we fetch tid first, object and
@@ -2670,7 +2670,7 @@ redo:
 	 */
 	do {
 		tid = this_cpu_read(s->cpu_slab->tid);
-		c = this_cpu_ptr(s->cpu_slab);
+		c = raw_cpu_ptr(s->cpu_slab);
 	} while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid));
 
 	/* Same with comment on barrier() in slab_alloc_node() */

_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 8 lines · Andrew Morton
Quoted 6 lines · On Wed, 21 Jan 2015 15:11:38 +0100 Michal Hocko <[email protected]> wrote:

On Wed 21-01-15 15:06:03, Krzysztof Koz__owski wrote:
[...]

Quoted 3 lines

Same here :) [1] . So actually only ARM seems affected (both armv7 and armv8) because it is the only one which uses smp_processor_id() in my_cpu_offset.

Quoted 7 lines
Quoted 3 lines

This was on x86_64 with CONFIG_DEBUG_PREEMPT so it is not only ARM specific.

Hopefully mm-slub-optimize-alloc-free-fastpath-by-removing-preemption-on-off-v3.patch will fix this.

Yes, it will fix this error.

Quoted 2 lines

The most recent -mmotm was a bit of a trainwreck. I'm scrambling to get the holes plugged so I can get another mmotm out today.

Another mmotm will fix many issues from me. :/

Thanks.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#5 lore raw
Quoted 4 lines · On Thu, 22 Jan 2015 10:51:23 +0900 Joonsoo Kim <[email protected]> wrote:
Quoted 2 lines

The most recent -mmotm was a bit of a trainwreck. I'm scrambling to get the holes plugged so I can get another mmotm out today.

Another mmotm will fix many issues from me. :/

I hit a wont-boot-cant-find-init in linux-next so I get to spend tomorrow bisecting that :(

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw

Hi Andrew,

Quoted 10 lines · On Wed, 21 Jan 2015 19:34:11 -0800 Andrew Morton <[email protected]>…
Quoted 4 lines · On Thu, 22 Jan 2015 10:51:23 +0900 Joonsoo Kim <[email protected]> wrote:
Quoted 2 lines

The most recent -mmotm was a bit of a trainwreck. I'm scrambling to get the holes plugged so I can get another mmotm out today.

Another mmotm will fix many issues from me. :/

I hit a wont-boot-cant-find-init in linux-next so I get to spend tomorrow bisecting that :(

There has been a long discussion about something like that already. Subject "Re: linux-next: Tree for Jan 20 -- Kernel panic - Unable to mount root fs"

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
maintainer
#7 lore raw
Quoted 9 lines · On Thu, 22 Jan 2015 16:14:02 +1100 Stephen Rothwell <[email protected]>…

Hi Andrew,

Quoted 6 lines · On Wed, 21 Jan 2015 19:34:11 -0800 Andrew Morton <[email protected]>…
Quoted 3 lines · On Thu, 22 Jan 2015 10:51:23 +0900 Joonsoo Kim <[email protected]> wrote:
Quoted 2 lines

The most recent -mmotm was a bit of a trainwreck. I'm scrambling to get the holes plugged so I can get another mmotm out today.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Another mmotm will fix many issues from me. :/

I hit a wont-boot-cant-find-init in linux-next so I get to spend tomorrow bisecting that :(

There has been a long discussion about something like that already. Subject "Re: linux-next: Tree for Jan 20 -- Kernel panic - Unable to mount root fs"

ah, thanks. You might have saved me a ton of effort there.

And oolookitat, a fix. I love it when viro says "Oh, fuck".

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
In reply to Michal Hocko
Quoted 3 lines

I am not sure how to fix this but it sounds like this_cpu_ptr should offer the same preempt expectations as other this_cpu_* functions.

One returns a pointer that may not be useful if the context is switched and the other completes a operationo on an opject.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>