From: Dave Hansen <dave@sr71.net>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, x86@kernel.org,
dave.hansen@linux.intel.com,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/2] x86 mpx: fix potential performance issue on unmaps
Date: Fri, 09 Jan 2015 10:47:14 -0800 [thread overview]
Message-ID: <54B02232.1030609@sr71.net> (raw)
In-Reply-To: <20141223091440.GA9112@gmail.com>
On 12/23/2014 01:14 AM, Ingo Molnar wrote:
>> > {
>> > - mpx_notify_unmap(mm, vma, start, end);
>> > + /*
>> > + * mpx_notify_unmap() goes and reads a rarely-hot
>> > + * cacheline in the mm_struct. That can be expensive
>> > + * enough to be seen in profiles.
>> > + *
>> > + * The mpx_notify_unmap() call and its contents have been
>> > + * observed to affect munmap() performance on hardware
>> > + * where MPX is not present.
>> > + *
>> > + * The unlikely() optimizes for the fast case: no MPX
>> > + * in the CPU, or no MPX use in the process. Even if
>> > + * we get this wrong (in the unlikely event that MPX
>> > + * is widely enabled on some system) the overhead of
>> > + * MPX itself (reading bounds tables) is expected to
>> > + * overwhelm the overhead of getting this unlikely()
>> > + * consistently wrong.
>> > + */
>> > + if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX)))
>> > + mpx_notify_unmap(mm, vma, start, end);
>> > }
> Hm, so this patch still does not help people who have an MPX
> capable CPU but don't have (or don't have many) MPX using apps.
> What about them?
Sorry for the delayed resposne.
The performance regression, as far as I could tell, was the result of a
consistent branch misprediction near the read of mm->bd_addr. I believe
the CPU was able to better predict cpu_feature_enabled() than the
contents of mm->bd_addr.
In running this on a CPU which actually contains MPX, I wasn't able to
see the same regression. The same branch was getting predicted correctly.
I also have a patch to add a global, boot-time MPX disable. It will
clear out the X86_FEATURE_MPX at __setup time. While not optimal, this
would at least let someone who did not have any MPX apps avoid any
potential issues. I was planning on submitting that patch for 3.20.
prev parent reply other threads:[~2015-01-09 18:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 20:08 [PATCH 0/2] x86, mpx: Fixes for 3.19 Dave Hansen
2014-12-22 20:08 ` [PATCH 1/2] x86, mpx: explicitly disable 32-bit MPX support on 64-bit kernels Dave Hansen
2014-12-22 20:17 ` Andy Lutomirski
2014-12-22 20:21 ` Dave Hansen
2014-12-22 20:27 ` Andy Lutomirski
2014-12-23 9:19 ` Ingo Molnar
2014-12-23 18:48 ` Andy Lutomirski
2014-12-22 20:08 ` [PATCH 2/2] x86 mpx: fix potential performance issue on unmaps Dave Hansen
2014-12-23 9:14 ` Ingo Molnar
2015-01-09 18:47 ` Dave Hansen [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=54B02232.1030609@sr71.net \
--to=dave@sr71.net \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=x86@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