From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, Peter Zijlstra <peterz@infradead.org>,
Bin Yang <bin.yang@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Mark Gross <mark.gross@intel.com>
Subject: [patch V2 00/10] x86/mm/cpa: Improve large page preservation handling
Date: Fri, 14 Sep 2018 15:09:17 +0200 [thread overview]
Message-ID: <20180914130917.155416208@linutronix.de> (raw)
Bin reported that try_preserve_large_page() in the page attribute code
consumes an large amount of CPU time. His initial attempts of addressing
this made me look deeper into the code.
The logic in this code is not really intelligent. It requires to check a
large page in 4k steps for conflicts. That's insane as most operations do
not conflict at all.
The code also lacks sanity checks which allow to detect whether the
existing mapping is incorrect vs. the static protections.
Any form of debugging or statistics is missing as well.
The following series addresses this:
- Clean up the code so it becomes extensible
- Provide the ability to check a full range for conflicts
- Add debug output and statistics to quantify the changes and to allow
observation of the mechanism in the future.
- Add a sanity check for existing mappings with a fixup for the 2M case
and a warning for the 1G case. The 2M case is trivial to address, the
1G case requires larger changes and is just warned about for now.
- Avoid conflict checks for operations which clear the PRESENT bit
- Utilize the range checks to detect conflicts in one operation
- Drop the 4k wise checking which turned out to provide no extra large
page preservation in testing. There might be corner cases where a page
would be preserved, but that's overkill for the common cases.
Before:
1G pages checked: 2
1G pages sameprot: 0
1G pages preserved: 0
2M pages checked: 540
2M pages sameprot: 466
2M pages preserved: 47
4K pages checked: 800770
4K pages set-checked: 7668
After:
1G pages checked: 2
1G pages sameprot: 0
1G pages preserved: 0
2M pages checked: 538
2M pages sameprot: 466
2M pages preserved: 47
4K pages set-checked: 7668
This gets rid of ~800000 checks whether a particular address is with a
static protection region. Each check tests against 4 different regions,
which adds up to several million instructions.
Changes since V1: Fix patch 1/10 extra argument issue which breaks
bisectability.
Thanks,
tglx
8<---------------------
Kconfig | 8
mm/pageattr.c | 515 +++++++++++++++++++++++++++++++++++++++++++---------------
2 files changed, 391 insertions(+), 132 deletions(-)
next reply other threads:[~2018-09-14 13:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-14 13:09 Thomas Gleixner [this message]
2018-09-14 13:09 ` [patch V2 01/10] x86/mm/cpa: Split, rename and clean up try_preserve_large_page() Thomas Gleixner
2018-09-14 13:09 ` [patch V2 02/10] x86/mm/cpa: Rework static_protections() Thomas Gleixner
2018-09-14 13:09 ` [patch V2 03/10] x86/mm/cpa: Allow range check for static protections Thomas Gleixner
2018-09-14 13:09 ` [patch V2 04/10] x86/mm/cpa: Add debug mechanism Thomas Gleixner
2018-09-14 23:22 ` kbuild test robot
2018-09-15 6:58 ` kbuild test robot
2018-09-15 13:06 ` [patch V3 " Thomas Gleixner
2018-09-14 13:09 ` [patch V2 05/10] x86/mm/cpa: Add large page preservation statistics Thomas Gleixner
2018-09-14 13:09 ` [patch V2 06/10] x86/mm/cpa: Avoid static protection checks on unmap Thomas Gleixner
2018-09-14 13:09 ` [patch V2 07/10] x86/mm/cpa: Add sanity check for existing mappings Thomas Gleixner
2018-09-17 0:31 ` [LKP] [x86/mm/cpa] c77d419f92: WARNING:at_arch/x86/mm/pageattr.c:#__change_page_attr_set_clr kernel test robot
2018-09-17 11:05 ` Thomas Gleixner
2018-09-14 13:09 ` [patch V2 08/10] x86/mm/cpa: Optimize same protection check Thomas Gleixner
2018-09-14 13:09 ` [patch V2 09/10] x86/mm/cpa: Do the range check early Thomas Gleixner
2018-09-14 13:09 ` [patch V2 10/10] x86/mm/cpa: Avoid the 4k pages check completely Thomas Gleixner
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=20180914130917.155416208@linutronix.de \
--to=tglx@linutronix.de \
--cc=bin.yang@intel.com \
--cc=dave.hansen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.gross@intel.com \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).