linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/thp: rework the pmd protect changing flow
@ 2020-01-23  7:55 Xuefeng Wang
  2020-01-23  7:55 ` [PATCH v2 1/2] mm: add helpers pmdp_modify_prot_start/commit Xuefeng Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Xuefeng Wang @ 2020-01-23  7:55 UTC (permalink / raw)
  To: catalin.marinas, will, mark.rutland, arnd, akpm
  Cc: linux-arch, linux-mm, linux-kernel, linux-arm-kernel, chenzhou10,
	Xuefeng Wang

On KunPeng920 board. When changing permission of a large range region,
pmdp_invalidate() takes about 65% in profile (with hugepages) in JIT tool.
Kernel will flush tlb twice: first flush happens in pmdp_invalidate, second
flush happens at the end of change_protect_range(). The first pmdp_invalidate
is not necessary if the hardware support atomic pmdp changing. The atomic
changing pimd to zero can prevent the hardware from update asynchronous.
So reconstruct it and remove the first pmdp_invalidate. And the second tlb
flush can make sure the new tlb entry valid.

This patch series add a pmdp_modify_prot transaction abstraction firstly.
Then add pmdp_modify_prot_start() in arm64, which uses pmdp_huge_get_and_clear()
to atomically fetch the pmd and zero the entry.

After rework, the mprotect can get 3~13 times performace gain in range
64M to 512M on KunPeng920:

4K granule/THP on
memory size(M)	64	128	256	320	448	512
pre-patch	0.77	1.40	2.64	3.23	4.49	5.10
post-patch	0.20	0.23	0.28	0.31	0.37	0.39

Changes:
v2:
 - fix set_pmd_at compile problems

Xuefeng Wang (2):
  mm: add helpers pmdp_modify_prot_start/commit
  arm64: mm: rework the pmd protect changing flow

 arch/arm64/include/asm/pgtable.h | 14 +++++++++++++
 include/asm-generic/pgtable.h    | 35 ++++++++++++++++++++++++++++++++
 mm/huge_memory.c                 | 19 ++++++++---------
 3 files changed, 57 insertions(+), 11 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH 0/2] mm/thp: rework the pmd protect changing flow
@ 2020-01-16  3:09 Xuefeng Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Xuefeng Wang @ 2020-01-16  3:09 UTC (permalink / raw)
  To: arnd, akpm, catalin.marinas, will, mark.rutland
  Cc: linux-arch, linux-kernel, linux-mm, linux-arm-kernel, chenzhou10

On KunPeng920 board. When changing permission of a large range region,
pmdp_invalidate() takes about 65% in profile (with hugepages) in JIT tool.
Kernel will flush tlb twice: first flush happens in pmdp_invalidate, second
flush happens at the end of change_protect_range(). The first pmdp_invalidate
is not necessary if the hardware support atomic pmdp changing. The atomic
changing pimd to zero can prevent the hardware from update asynchronous.
So reconstruct it and remove the first pmdp_invalidate. And the second tlb
flush can make sure the new tlb entry valid.

This patch series add a pmdp_modify_prot transaction abstraction firstly.
Then add pmdp_modify_prot_start() in arm64, which uses pmdp_huge_get_and_clear()
to atomically fetch the pmd and zero the entry.

After rework, the mprotect can get 3~13 times performace gain in range
64M to 512M on KunPeng920:

4K granule/THP on
memory size(M)	64	128	256	320	448	512
pre-patch		0.77	1.40	2.64	3.23	4.49	5.10
post-patch		0.20	0.23	0.28	0.31	0.37	0.39

Xuefeng Wang (2):
  mm: add helpers pmdp_modify_prot_start/commit
  arm64: mm: rework the pmd protect changing flow

 arch/arm64/include/asm/pgtable.h | 14 +++++++++++++
 include/asm-generic/pgtable.h    | 35 ++++++++++++++++++++++++++++++++
 mm/huge_memory.c                 | 19 ++++++++---------
 3 files changed, 57 insertions(+), 11 deletions(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-23  8:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-23  7:55 [PATCH 0/2] mm/thp: rework the pmd protect changing flow Xuefeng Wang
2020-01-23  7:55 ` [PATCH v2 1/2] mm: add helpers pmdp_modify_prot_start/commit Xuefeng Wang
2020-01-23  7:55 ` [PATCH v2 2/2] arm64: mm: rework the pmd protect changing flow Xuefeng Wang
2020-01-23  8:24 ` [PATCH 0/2] mm/thp: " Anshuman Khandual
  -- strict thread matches above, loose matches on Subject: below --
2020-01-16  3:09 Xuefeng Wang

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).