From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2] mm/slub: fix lockups on PREEMPT && !SMP kernels
Date: Tue, 24 Mar 2015 14:17:53 +0000 (UTC) [thread overview]
Message-ID: <loom.20150324T151548-490@post.gmane.org> (raw)
In-Reply-To: <1426594533-18221-1-git-send-email-mark.rutland@arm.com>
Mark Rutland <mark.rutland <at> arm.com> writes:
>
> Commit 9aabf810a67cd97e ("mm/slub: optimize alloc/free fastpath by
> removing preemption on/off") introduced an occasional hang for kernels
> built with CONFIG_PREEMPT && !CONFIG_SMP.
>
> The problem is the following loop the patch introduced to
> slab_alloc_node and slab_free:
>
> do {
> tid = this_cpu_read(s->cpu_slab->tid);
> c = raw_cpu_ptr(s->cpu_slab);
> } while (IS_ENABLED(CONFIG_PREEMPT) && unlikely(tid != c->tid));
>
> GCC 4.9 has been observed to hoist the load of c and c->tid above the
> loop for !SMP kernels (as in this case raw_cpu_ptr(x) is compile-time
> constant and does not force a reload). On arm64 the generated assembly
> looks like:
>
> ffffffc00016d3c4: f9400404 ldr x4, [x0,#8]
> ffffffc00016d3c8: f9400401 ldr x1, [x0,#8]
> ffffffc00016d3cc: eb04003f cmp x1, x4
> ffffffc00016d3d0: 54ffffc1 b.ne ffffffc00016d3c8
<slab_alloc_node.constprop.82+0x30>
Just FYI I've hit this problem on x86. I think I used gcc 4.7 and 4.8, and
maybe also 4.6 earlier.
Here's the diff in asm after applying the fix:
240a: 0f 85 ce 00 00 00 jne 24de <kmem_cache_free+0x10e>
2410: 89 75 f0 mov %esi,-0x10(%ebp)
2413: 8b 07 mov (%edi),%eax
- 2415: 8b 50 04 mov 0x4(%eax),%edx
- 2418: 8b 48 04 mov 0x4(%eax),%ecx
- 241b: 39 d1 cmp %edx,%ecx
- 241d: 75 f9 jne 2418 <kmem_cache_free+0x48>
+ 2415: 8b 48 04 mov 0x4(%eax),%ecx
+ 2418: 8b 50 04 mov 0x4(%eax),%edx
+ 241b: 39 ca cmp %ecx,%edx
+ 241d: 75 f6 jne 2415 <kmem_cache_free+0x45>
241f: 8b 4d f0 mov -0x10(%ebp),%ecx
2422: 39 48 08 cmp %ecx,0x8(%eax)
2425: 0f 85 9a 00 00 00 jne 24c5 <kmem_cache_free+0xf5>
As 3.19+ is broken now, this should go into stable.
Cc: stable@vger.kernel.org
prev parent reply other threads:[~2015-03-24 14:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 15:47 [PATCH] " Mark Rutland
2015-03-13 16:29 ` Christoph Lameter
2015-03-13 18:16 ` Mark Rutland
2015-03-13 18:27 ` Christoph Lameter
2015-03-16 12:45 ` [PATCHv2] " Mark Rutland
2015-03-17 1:09 ` [PATCH] " Joonsoo Kim
2015-03-17 12:00 ` Mark Rutland
2015-03-17 12:15 ` [PATCHv2] " Mark Rutland
2015-03-17 18:57 ` Christoph Lameter
2015-03-18 5:59 ` Joonsoo Kim
2015-03-18 15:21 ` Mark Rutland
2015-03-19 12:13 ` Joonsoo Kim
2015-03-19 16:16 ` Christoph Lameter
2015-03-24 14:17 ` Ville Syrjälä [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20150324T151548-490@post.gmane.org \
--to=ville.syrjala@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome