From: Mike Kravetz <mike.kravetz@oracle.com>
To: sparclinux@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
Bob Picco <bob.picco@oracle.com>,
Nitin Gupta <nitin.m.gupta@oracle.com>,
Vijay Kumar <vijay.ac.kumar@oracle.com>,
Julian Calaby <julian.calaby@gmail.com>,
Adam Buchbinder <adam.buchbinder@gmail.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Michal Hocko <mhocko@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: [RFC PATCH 00/14] sparc64 shared context/TLB support
Date: Fri, 16 Dec 2016 10:35:23 -0800 [thread overview]
Message-ID: <1481913337-9331-1-git-send-email-mike.kravetz@oracle.com> (raw)
In Sparc mm code today, each address space is assigned a unique context
identifier. This context ID is stored in context register 0 of the MMU.
This same context ID is stored in TLB entries. When the MMU is searching
for a virtual address translation, the context ID as well as the virtual
address must match for a TLB hit.
Beginning with Sparc Niagara 2 processors, the MMU contains an additional
context register (register 1). When searching the TLB, the MMU will find
a match if the virtual address matches and the ID contained in either
context register 0 -OR- context register 1 matches.
In the Linux kernel today, only context register 0 is set and used by
the MMU. Solaris has made use of the additional context register for shared
mappings. If two tasks share an appropriate mapping, then both tasks set
context register 1 to the same value and associate that value with the
shared mapping. In this way, both tasks can use the same TLB entries for
pages of the shared mapping.
This RFC adds support for the additional context register, and extends the
mmap and System V shared memory system calls so that an application can
request shared context mappings. At a very high level, this works as follows:
- An application passes a new SHARED_CTX flag to mmap or shmat
- The vma associated with the mapping is marked with a SHARED_CTX flag
- When a SHARED_CTX marked vma is first created, all other vma's mapping
the same underlying object are searched looking for a match that:
1) Is also marked SHARED_CTX
2) Is mapped at the same virtual address
- If a match is found, the new vma shares a context ID with the existing vma.
- If no match is found, a context ID is allocated for the new vma
- sparc specific code associates the context ID with pages in the shared
mappings.
This RFC patch series limits a task to having only a single shared context
vma. Shared context vmas in different processes must match exactly (start
and length) to be shared. In addition, shared context support is only
provided for huge page (hugetlb) mappings. These and other restrictions can
be relaxed as the code is further developed.
Most of the code in this patch series is sparc specific for management of
the new context ID and associated TSB entries. However, there is arch
independent code which needs to enable the flagging of mappings which request
shared context.
This is early proof of concept code. It is not polished, and there is need
for much more work. There are even FIXME comments in the code. My hope is
that it is sufficiently readable to start a discussion about the general
direction to enable such functionality.
It does function, and with perf you can see a reduction in TLB misses for
shared context mappings. A simple test program which has two tasks touch
pages in a shared mapping has the following dTLB miss rates.
Testing Normal Mapping Shared Context Mapping
Rounds dTLB-load-misses dTLB-load-misses
1 771 834
10 1,651 881
100 10,422 874
1000 97,992 958
10000 975,910 963
100000 9,719,193 1,017
1000000 97,941,327 4,148
Mike Kravetz (14):
sparc64: placeholder for needed mmu shared context patching
sparc64: add new fields to mmu context for shared context support
sparc64: routines for basic mmu shared context structure management
sparc64: load shared id into context register 1
sparc64: Add PAGE_SHR_CTX flag
sparc64: general shared context tsb creation and support
sparc64: move COMPUTE_TAG_TARGET and COMPUTE_TSB_PTR to header file
sparc64: shared context tsb handling at context switch time
sparc64: TLB/TSB miss handling for shared context
mm: add shared context to vm_area_struct
sparc64: add routines to look for vmsa which can share context
mm: add mmap and shmat arch hooks for shared context
sparc64 mm: add shared context support to mmap() and shmat() APIs
sparc64: add SHARED_MMU_CTX Kconfig option
arch/powerpc/include/asm/mmu_context.h | 12 ++
arch/s390/include/asm/mmu_context.h | 12 ++
arch/sparc/Kconfig | 3 +
arch/sparc/include/asm/hugetlb.h | 4 +
arch/sparc/include/asm/mman.h | 6 +
arch/sparc/include/asm/mmu_64.h | 36 +++++-
arch/sparc/include/asm/mmu_context_64.h | 139 ++++++++++++++++++++++--
arch/sparc/include/asm/page_64.h | 1 +
arch/sparc/include/asm/pgtable_64.h | 13 +++
arch/sparc/include/asm/spitfire.h | 2 +
arch/sparc/include/asm/tlb_64.h | 3 +
arch/sparc/include/asm/trap_block.h | 3 +-
arch/sparc/include/asm/tsb.h | 40 +++++++
arch/sparc/include/uapi/asm/mman.h | 1 +
arch/sparc/kernel/fpu_traps.S | 63 +++++++++++
arch/sparc/kernel/head_64.S | 2 +-
arch/sparc/kernel/rtrap_64.S | 20 ++++
arch/sparc/kernel/setup_64.c | 11 ++
arch/sparc/kernel/smp_64.c | 22 ++++
arch/sparc/kernel/sun4v_tlb_miss.S | 37 ++-----
arch/sparc/kernel/sys_sparc_64.c | 17 +++
arch/sparc/kernel/trampoline_64.S | 20 ++++
arch/sparc/kernel/tsb.S | 172 +++++++++++++++++++++++------
arch/sparc/mm/fault_64.c | 10 ++
arch/sparc/mm/hugetlbpage.c | 94 +++++++++++++++-
arch/sparc/mm/init_64.c | 181 ++++++++++++++++++++++++++++++-
arch/sparc/mm/tsb.c | 95 +++++++++++++++-
arch/unicore32/include/asm/mmu_context.h | 12 ++
arch/x86/include/asm/mmu_context.h | 12 ++
include/asm-generic/mm_hooks.h | 18 ++-
include/linux/mm.h | 1 +
include/linux/mm_types.h | 13 +++
include/uapi/linux/shm.h | 1 +
ipc/shm.c | 13 +++
mm/hugetlb.c | 9 ++
mm/mmap.c | 10 ++
36 files changed, 1018 insertions(+), 90 deletions(-)
--
2.7.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2016-12-16 18:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-16 18:35 Mike Kravetz [this message]
2016-12-16 18:35 ` [RFC PATCH 01/14] sparc64: placeholder for needed mmu shared context patching Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 02/14] sparc64: add new fields to mmu context for shared context support Mike Kravetz
2016-12-17 7:34 ` Sam Ravnborg
2016-12-18 23:33 ` Mike Kravetz
2016-12-21 18:12 ` Sam Ravnborg
2016-12-17 7:38 ` Sam Ravnborg
2016-12-18 23:45 ` Mike Kravetz
2016-12-21 18:13 ` Sam Ravnborg
2016-12-16 18:35 ` [RFC PATCH 03/14] sparc64: routines for basic mmu shared context structure management Mike Kravetz
2016-12-18 3:07 ` David Miller
2016-12-16 18:35 ` [RFC PATCH 04/14] sparc64: load shared id into context register 1 Mike Kravetz
2016-12-17 7:45 ` Sam Ravnborg
2016-12-19 0:22 ` Mike Kravetz
2016-12-21 18:16 ` Sam Ravnborg
2016-12-18 3:14 ` David Miller
2016-12-19 0:06 ` Mike Kravetz
2016-12-20 18:33 ` David Miller
2016-12-20 20:27 ` Mike Kravetz
2016-12-21 18:17 ` Sam Ravnborg
2016-12-16 18:35 ` [RFC PATCH 05/14] sparc64: Add PAGE_SHR_CTX flag Mike Kravetz
2016-12-18 3:12 ` David Miller
2016-12-19 0:42 ` Mike Kravetz
2016-12-20 18:33 ` David Miller
2016-12-16 18:35 ` [RFC PATCH 06/14] sparc64: general shared context tsb creation and support Mike Kravetz
2016-12-17 7:53 ` Sam Ravnborg
2016-12-19 0:52 ` Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 07/14] sparc64: move COMPUTE_TAG_TARGET and COMPUTE_TSB_PTR to header file Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 08/14] sparc64: shared context tsb handling at context switch time Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 09/14] sparc64: TLB/TSB miss handling for shared context Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 10/14] mm: add shared context to vm_area_struct Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 11/14] sparc64: add routines to look for vmsa which can share context Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 12/14] mm: add mmap and shmat arch hooks for shared context Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 13/14] sparc64 mm: add shared context support to mmap() and shmat() APIs Mike Kravetz
2016-12-16 18:35 ` [RFC PATCH 14/14] sparc64: add SHARED_MMU_CTX Kconfig option Mike Kravetz
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=1481913337-9331-1-git-send-email-mike.kravetz@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=adam.buchbinder@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bob.picco@oracle.com \
--cc=davem@davemloft.net \
--cc=julian.calaby@gmail.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nitin.m.gupta@oracle.com \
--cc=sparclinux@vger.kernel.org \
--cc=vijay.ac.kumar@oracle.com \
/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).