Skip to content

Use global pages with PTI

Dave Hansen linux-mm lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest11 patches 8 repliesIn review
  2. v411 patches 6 repliesSuperseded
  3. v311 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v111 patches24 repliesSuperseded

Changes in v5 from the cover letter

* Fix compile error reported by Tom Lendacky
* Avoid setting _PAGE_GLOBAL on non-present entries

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11x86/mm: factor out pageattr _PAGE_GLOBAL settingarch/x86/mm/pageattr.c+23 -430 replies
2/11x86/mm: undo double _PAGE_PSE clearingarch/x86/mm/pageattr.c+6 -30 replies
3/11x86/mm: introduce "default" kernel PTE maskarch/x86/include/asm/pgtable_types.h arch/x86/mm/init.c arch/x86/mm/init_32.c +1 more+33 -130 replies
4/11x86/espfix: document use of _PAGE_GLOBALarch/x86/kernel/espfix_64.c+4 -00 replies
5/11x86/mm: do not auto-massage page protectionsarch/x86/boot/compressed/kaslr.c arch/x86/include/asm/pgtable.h arch/x86/kernel/head64.c +7 more+75 -120 replies
6/11x86/mm: remove extra filtering in pageattr codearch/x86/mm/pageattr.c+2 -40 replies
7/11x86/mm: comment _PAGE_GLOBAL mysteryarch/x86/kernel/head_64.S+10 -10 replies
8/11x86/mm: do not forbid _PAGE_RW before init for __ro_after_initarch/x86/mm/pageattr.c+4 -20 replies
9/11x86/pti: enable global pages for shared areasarch/x86/mm/cpu_entry_area.c arch/x86/mm/pti.c+35 -20 replies
10/11x86/pti: never implicitly clear _PAGE_GLOBAL for kernel imagearch/x86/mm/init.c arch/x86/mm/pageattr.c arch/x86/mm/pti.c+35 -100 replies
11/11x86/pti: leave kernel text global for !PCIDarch/x86/include/asm/pti.h arch/x86/mm/init_64.c arch/x86/mm/pti.c+82 -43 replies

Reviews trailers per patch

1 of 11 patches has a Reviewed-by or Acked-by.

PatchKees Cook
1/11
2/11
3/11
4/11
5/11
6/11
7/11
8/11A-b
9/11
10/11
11/11

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH 00/11] [v5] Use global pages with PTI

Changes from v4
* Fix compile error reported by Tom Lendacky
* Avoid setting _PAGE_GLOBAL on non-present entries

Changes from v3:
* Fix whitespace issue noticed by willy
* Clarify comments about X86_FEATURE_PGE checks
* Clarify commit message around the necessity of _PAGE_GLOBAL filtering when CR4.PGE=0 or PGE is unsupported.

Changes from v2:

* Add performance numbers to changelogs
* Fix compile error resulting from use of x86-specific __default_kernel_pte_mask in arch-generic mm/early_ioremap.c
* Delay kernel text cloning until after we are done messing with it (patch 11).
* Blacklist K8 explicitly from mapping all kernel text as global (this should never happen because K8 does not use pti when pti=auto, but we on the safe side). (patch 11)

--

The later versions of the KAISER patches (pre-PTI) allowed the user/kernel shared areas to be GLOBAL. The thought was that this would reduce the TLB overhead of keeping two copies of these mappings.

During the switch over to PTI, we seem to have lost our ability to have GLOBAL mappings. This adds them back.

To measure the benefits of this, I took a modern Atom system without PCIDs and ran a microbenchmark[1] (higher is better):

No Global Lines (baseline ): 6077741 lseeks/sec 88 Global Lines (kern entry): 7528609 lseeks/sec (+23.9%) 94 Global Lines (all ktext ): 8433111 lseeks/sec (+38.8%)

On a modern Skylake desktop with PCIDs, the benefits are tangible, but not huge:

No Global pages (baseline): 15783951 lseeks/sec
28 Global pages (this set): 16054688 lseeks/sec

                             +270737 lseeks/sec (+1.71%)

I also double-checked with a kernel compile on the Skylake system (lower is better):

No Global pages (baseline): 186.951 seconds time elapsed  ( +-  0.35% )
28 Global pages (this set): 185.756 seconds time elapsed  ( +-  0.09% )
                             -1.195 seconds (-0.64%)

1. https://github.com/antonblanchard/will-it-scale/blob/master/tests/lseek1.c

Cc Andrea Arcangeli <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Kees Cook <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Juergen Gross <[email protected]>
Cc Nadav Amit <[email protected]>