License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2006-02-01 09:29:18 +07:00
|
|
|
/* tsb.S: Sparc64 TSB table handling.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 David S. Miller <davem@davemloft.net>
|
|
|
|
*/
|
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
|
2006-02-01 09:29:18 +07:00
|
|
|
#include <asm/tsb.h>
|
2006-02-10 08:21:53 +07:00
|
|
|
#include <asm/hypervisor.h>
|
2006-03-22 15:49:59 +07:00
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/cpudata.h>
|
|
|
|
#include <asm/mmu.h>
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
.text
|
|
|
|
.align 32
|
|
|
|
|
|
|
|
/* Invoked from TLB miss handler, we are in the
|
|
|
|
* MMU global registers and they are setup like
|
|
|
|
* this:
|
|
|
|
*
|
|
|
|
* %g1: TSB entry pointer
|
|
|
|
* %g2: available temporary
|
|
|
|
* %g3: FAULT_CODE_{D,I}TLB
|
|
|
|
* %g4: available temporary
|
|
|
|
* %g5: available temporary
|
|
|
|
* %g6: TAG TARGET
|
2006-02-07 14:44:37 +07:00
|
|
|
* %g7: available temporary, will be loaded by us with
|
|
|
|
* the physical address base of the linux page
|
2006-02-01 09:29:18 +07:00
|
|
|
* tables for the current address space
|
|
|
|
*/
|
|
|
|
tsb_miss_dtlb:
|
|
|
|
mov TLB_TAG_ACCESS, %g4
|
2016-07-28 07:50:26 +07:00
|
|
|
ldxa [%g4] ASI_DMMU, %g4
|
|
|
|
srlx %g4, PAGE_SHIFT, %g4
|
2006-02-01 09:29:18 +07:00
|
|
|
ba,pt %xcc, tsb_miss_page_table_walk
|
2016-07-28 07:50:26 +07:00
|
|
|
sllx %g4, PAGE_SHIFT, %g4
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
tsb_miss_itlb:
|
|
|
|
mov TLB_TAG_ACCESS, %g4
|
2016-07-28 07:50:26 +07:00
|
|
|
ldxa [%g4] ASI_IMMU, %g4
|
|
|
|
srlx %g4, PAGE_SHIFT, %g4
|
2006-02-01 09:29:18 +07:00
|
|
|
ba,pt %xcc, tsb_miss_page_table_walk
|
2016-07-28 07:50:26 +07:00
|
|
|
sllx %g4, PAGE_SHIFT, %g4
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-02-11 15:29:34 +07:00
|
|
|
/* At this point we have:
|
2006-03-22 15:49:59 +07:00
|
|
|
* %g1 -- PAGE_SIZE TSB entry address
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
* %g3 -- FAULT_CODE_{D,I}TLB
|
|
|
|
* %g4 -- missing virtual address
|
2006-02-18 09:01:02 +07:00
|
|
|
* %g6 -- TAG TARGET (vaddr >> 22)
|
2006-02-07 14:44:37 +07:00
|
|
|
*/
|
2006-02-01 09:29:18 +07:00
|
|
|
tsb_miss_page_table_walk:
|
2006-03-22 15:49:59 +07:00
|
|
|
TRAP_LOAD_TRAP_BLOCK(%g7, %g5)
|
2006-02-27 14:24:22 +07:00
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
/* Before committing to a full page table walk,
|
|
|
|
* check the huge page TSB.
|
|
|
|
*/
|
2012-10-09 06:34:29 +07:00
|
|
|
#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
|
2006-03-22 15:49:59 +07:00
|
|
|
|
|
|
|
661: ldx [%g7 + TRAP_PER_CPU_TSB_HUGE], %g5
|
|
|
|
nop
|
|
|
|
.section .sun4v_2insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
mov SCRATCHPAD_UTSBREG2, %g5
|
|
|
|
ldxa [%g5] ASI_SCRATCHPAD, %g5
|
|
|
|
.previous
|
|
|
|
|
|
|
|
cmp %g5, -1
|
|
|
|
be,pt %xcc, 80f
|
|
|
|
nop
|
|
|
|
|
|
|
|
/* We need an aligned pair of registers containing 2 values
|
|
|
|
* which can be easily rematerialized. %g6 and %g7 foot the
|
|
|
|
* bill just nicely. We'll save %g6 away into %g2 for the
|
|
|
|
* huge page TSB TAG comparison.
|
|
|
|
*
|
|
|
|
* Perform a huge page TSB lookup.
|
|
|
|
*/
|
|
|
|
mov %g6, %g2
|
|
|
|
and %g5, 0x7, %g6
|
|
|
|
mov 512, %g7
|
|
|
|
andn %g5, 0x7, %g5
|
|
|
|
sllx %g7, %g6, %g7
|
sparc64: Move from 4MB to 8MB huge pages.
The impetus for this is that we would like to move to 64-bit PMDs and
PGDs, but that would result in only supporting a 42-bit address space
with the current page table layout. It'd be nice to support at least
43-bits.
The reason we'd end up with only 42-bits after making PMDs and PGDs
64-bit is that we only use half-page sized PTE tables in order to make
PMDs line up to 4MB, the hardware huge page size we use.
So what we do here is we make huge pages 8MB, and fabricate them using
4MB hw TLB entries.
Facilitate this by providing a "REAL_HPAGE_SHIFT" which is used in
places that really need to operate on hardware 4MB pages.
Use full pages (512 entries) for PTE tables, and adjust PMD_SHIFT,
PGD_SHIFT, and the build time CPP test as needed. Use a CPP test to
make sure REAL_HPAGE_SHIFT and the _PAGE_SZHUGE_* we use match up.
This makes the pgtable cache completely unused, so remove the code
managing it and the state used in mm_context_t. Now we have less
spinlocks taken in the page table allocation path.
The technique we use to fabricate the 8MB pages is to transfer bit 22
from the missing virtual address into the PTEs physical address field.
That takes care of the transparent huge pages case.
For hugetlb, we fill things in at the PTE level and that code already
puts the sub huge page physical bits into the PTEs, based upon the
offset, so there is nothing special we need to do. It all just works
out.
So, a small amount of complexity in the THP case, but this code is
about to get much simpler when we move the 64-bit PMDs as we can move
away from the fancy 32-bit huge PMD encoding and just put a real PTE
value in there.
With bug fixes and help from Bob Picco.
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-09-26 03:48:49 +07:00
|
|
|
srlx %g4, REAL_HPAGE_SHIFT, %g6
|
2006-03-22 15:49:59 +07:00
|
|
|
sub %g7, 1, %g7
|
|
|
|
and %g6, %g7, %g6
|
|
|
|
sllx %g6, 4, %g6
|
|
|
|
add %g5, %g6, %g5
|
|
|
|
|
|
|
|
TSB_LOAD_QUAD(%g5, %g6)
|
|
|
|
cmp %g6, %g2
|
|
|
|
be,a,pt %xcc, tsb_tlb_reload
|
|
|
|
mov %g7, %g5
|
|
|
|
|
|
|
|
/* No match, remember the huge page TSB entry address,
|
|
|
|
* and restore %g6 and %g7.
|
|
|
|
*/
|
|
|
|
TRAP_LOAD_TRAP_BLOCK(%g7, %g6)
|
|
|
|
srlx %g4, 22, %g6
|
|
|
|
80: stx %g5, [%g7 + TRAP_PER_CPU_TSB_HUGE_TEMP]
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ldx [%g7 + TRAP_PER_CPU_PGD_PADDR], %g7
|
2006-02-01 09:29:18 +07:00
|
|
|
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
/* At this point we have:
|
|
|
|
* %g1 -- TSB entry address
|
|
|
|
* %g3 -- FAULT_CODE_{D,I}TLB
|
2006-03-22 15:49:59 +07:00
|
|
|
* %g4 -- missing virtual address
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
* %g6 -- TAG TARGET (vaddr >> 22)
|
2006-03-22 15:49:59 +07:00
|
|
|
* %g7 -- page table physical address
|
|
|
|
*
|
|
|
|
* We know that both the base PAGE_SIZE TSB and the HPAGE_SIZE
|
|
|
|
* TSB both lack a matching entry.
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
*/
|
2006-03-22 15:49:59 +07:00
|
|
|
tsb_miss_page_table_walk_sun4v_fastpath:
|
|
|
|
USER_PGTABLE_WALK_TL1(%g4, %g7, %g5, %g2, tsb_do_fault)
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2012-10-09 06:34:29 +07:00
|
|
|
/* Valid PTE is now in %g5. */
|
2006-03-22 15:49:59 +07:00
|
|
|
|
2012-10-09 06:34:29 +07:00
|
|
|
#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
|
2017-08-12 06:46:50 +07:00
|
|
|
sethi %uhi(_PAGE_PMD_HUGE | _PAGE_PUD_HUGE), %g7
|
2006-03-22 15:49:59 +07:00
|
|
|
sllx %g7, 32, %g7
|
|
|
|
|
2017-02-02 07:16:36 +07:00
|
|
|
andcc %g5, %g7, %g0
|
|
|
|
be,pt %xcc, 60f
|
2006-03-22 15:49:59 +07:00
|
|
|
nop
|
|
|
|
|
|
|
|
/* It is a huge page, use huge page TSB entry address we
|
2013-02-20 13:34:10 +07:00
|
|
|
* calculated above. If the huge page TSB has not been
|
|
|
|
* allocated, setup a trap stack and call hugetlb_setup()
|
|
|
|
* to do so, then return from the trap to replay the TLB
|
|
|
|
* miss.
|
|
|
|
*
|
|
|
|
* This is necessary to handle the case of transparent huge
|
|
|
|
* pages where we don't really have a non-atomic context
|
|
|
|
* in which to allocate the hugepage TSB hash table. When
|
|
|
|
* the 'mm' faults in the hugepage for the first time, we
|
|
|
|
* thus handle it here. This also makes sure that we can
|
|
|
|
* allocate the TSB hash table on the correct NUMA node.
|
2006-03-22 15:49:59 +07:00
|
|
|
*/
|
|
|
|
TRAP_LOAD_TRAP_BLOCK(%g7, %g2)
|
2013-02-20 13:34:10 +07:00
|
|
|
ldx [%g7 + TRAP_PER_CPU_TSB_HUGE_TEMP], %g1
|
|
|
|
cmp %g1, -1
|
|
|
|
bne,pt %xcc, 60f
|
|
|
|
nop
|
|
|
|
|
|
|
|
661: rdpr %pstate, %g5
|
|
|
|
wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
|
|
|
|
.section .sun4v_2insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
SET_GL(1)
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
2014-10-19 10:03:09 +07:00
|
|
|
rdpr %tl, %g7
|
|
|
|
cmp %g7, 1
|
2013-02-20 13:34:10 +07:00
|
|
|
bne,pn %xcc, winfix_trampoline
|
2014-10-19 10:03:09 +07:00
|
|
|
mov %g3, %g4
|
2013-02-20 13:34:10 +07:00
|
|
|
ba,pt %xcc, etrap
|
|
|
|
rd %pc, %g7
|
|
|
|
call hugetlb_setup
|
|
|
|
add %sp, PTREGS_OFF, %o0
|
|
|
|
ba,pt %xcc, rtrap
|
|
|
|
nop
|
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
60:
|
|
|
|
#endif
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
/* At this point we have:
|
|
|
|
* %g1 -- TSB entry address
|
|
|
|
* %g3 -- FAULT_CODE_{D,I}TLB
|
|
|
|
* %g5 -- valid PTE
|
|
|
|
* %g6 -- TAG TARGET (vaddr >> 22)
|
|
|
|
*/
|
|
|
|
tsb_reload:
|
|
|
|
TSB_LOCK_TAG(%g1, %g2, %g7)
|
2006-02-01 09:29:18 +07:00
|
|
|
TSB_WRITE(%g1, %g5, %g6)
|
|
|
|
|
|
|
|
/* Finally, load TLB and return from trap. */
|
|
|
|
tsb_tlb_reload:
|
|
|
|
cmp %g3, FAULT_CODE_DTLB
|
|
|
|
bne,pn %xcc, tsb_itlb_load
|
|
|
|
nop
|
|
|
|
|
|
|
|
tsb_dtlb_load:
|
2006-02-07 14:44:37 +07:00
|
|
|
|
|
|
|
661: stxa %g5, [%g0] ASI_DTLB_DATA_IN
|
2006-02-01 09:29:18 +07:00
|
|
|
retry
|
2006-02-07 15:00:16 +07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-07 14:44:37 +07:00
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
|
|
|
/* For sun4v the ASI_DTLB_DATA_IN store and the retry
|
|
|
|
* instruction get nop'd out and we get here to branch
|
|
|
|
* to the sun4v tlb load code. The registers are setup
|
|
|
|
* as follows:
|
|
|
|
*
|
|
|
|
* %g4: vaddr
|
|
|
|
* %g5: PTE
|
|
|
|
* %g6: TAG
|
|
|
|
*
|
|
|
|
* The sun4v TLB load wants the PTE in %g3 so we fix that
|
|
|
|
* up here.
|
|
|
|
*/
|
|
|
|
ba,pt %xcc, sun4v_dtlb_load
|
|
|
|
mov %g5, %g3
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
tsb_itlb_load:
|
2006-03-02 13:42:18 +07:00
|
|
|
/* Executable bit must be set. */
|
2010-02-20 06:19:52 +07:00
|
|
|
661: sethi %hi(_PAGE_EXEC_4U), %g4
|
|
|
|
andcc %g5, %g4, %g0
|
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-03-02 13:42:18 +07:00
|
|
|
.word 661b
|
|
|
|
andcc %g5, _PAGE_EXEC_4V, %g0
|
2010-02-20 06:19:52 +07:00
|
|
|
nop
|
2006-03-02 13:42:18 +07:00
|
|
|
.previous
|
|
|
|
|
|
|
|
be,pn %xcc, tsb_do_fault
|
|
|
|
nop
|
2006-02-07 14:44:37 +07:00
|
|
|
|
|
|
|
661: stxa %g5, [%g0] ASI_ITLB_DATA_IN
|
2006-02-01 09:29:18 +07:00
|
|
|
retry
|
2006-02-07 15:00:16 +07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-07 14:44:37 +07:00
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
|
|
|
/* For sun4v the ASI_ITLB_DATA_IN store and the retry
|
|
|
|
* instruction get nop'd out and we get here to branch
|
|
|
|
* to the sun4v tlb load code. The registers are setup
|
|
|
|
* as follows:
|
|
|
|
*
|
|
|
|
* %g4: vaddr
|
|
|
|
* %g5: PTE
|
|
|
|
* %g6: TAG
|
|
|
|
*
|
|
|
|
* The sun4v TLB load wants the PTE in %g3 so we fix that
|
|
|
|
* up here.
|
|
|
|
*/
|
|
|
|
ba,pt %xcc, sun4v_itlb_load
|
|
|
|
mov %g5, %g3
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
/* No valid entry in the page tables, do full fault
|
|
|
|
* processing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
.globl tsb_do_fault
|
|
|
|
tsb_do_fault:
|
|
|
|
cmp %g3, FAULT_CODE_DTLB
|
2006-02-06 13:27:28 +07:00
|
|
|
|
|
|
|
661: rdpr %pstate, %g5
|
|
|
|
wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
|
2006-02-07 15:00:16 +07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-06 13:27:28 +07:00
|
|
|
.word 661b
|
2006-02-18 05:58:02 +07:00
|
|
|
SET_GL(1)
|
2006-02-18 09:01:02 +07:00
|
|
|
ldxa [%g0] ASI_SCRATCHPAD, %g4
|
2006-02-06 13:27:28 +07:00
|
|
|
.previous
|
|
|
|
|
2006-02-01 09:29:18 +07:00
|
|
|
bne,pn %xcc, tsb_do_itlb_fault
|
2006-02-06 13:27:28 +07:00
|
|
|
nop
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
tsb_do_dtlb_fault:
|
2006-02-07 14:44:37 +07:00
|
|
|
rdpr %tl, %g3
|
|
|
|
cmp %g3, 1
|
|
|
|
|
|
|
|
661: mov TLB_TAG_ACCESS, %g4
|
2006-02-01 09:29:18 +07:00
|
|
|
ldxa [%g4] ASI_DMMU, %g5
|
2006-02-07 15:00:16 +07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-07 14:44:37 +07:00
|
|
|
.word 661b
|
2006-02-18 09:01:02 +07:00
|
|
|
ldx [%g4 + HV_FAULT_D_ADDR_OFFSET], %g5
|
2006-02-07 14:44:37 +07:00
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
2016-07-28 07:50:26 +07:00
|
|
|
/* Clear context ID bits. */
|
|
|
|
srlx %g5, PAGE_SHIFT, %g5
|
|
|
|
sllx %g5, PAGE_SHIFT, %g5
|
|
|
|
|
2006-02-01 09:29:18 +07:00
|
|
|
be,pt %xcc, sparc64_realfault_common
|
|
|
|
mov FAULT_CODE_DTLB, %g4
|
|
|
|
ba,pt %xcc, winfix_trampoline
|
|
|
|
nop
|
|
|
|
|
|
|
|
tsb_do_itlb_fault:
|
|
|
|
rdpr %tpc, %g5
|
|
|
|
ba,pt %xcc, sparc64_realfault_common
|
|
|
|
mov FAULT_CODE_ITLB, %g4
|
|
|
|
|
|
|
|
.globl sparc64_realfault_common
|
|
|
|
sparc64_realfault_common:
|
2006-02-01 09:34:21 +07:00
|
|
|
/* fault code in %g4, fault address in %g5, etrap will
|
|
|
|
* preserve these two values in %l4 and %l5 respectively
|
|
|
|
*/
|
2006-02-01 09:29:18 +07:00
|
|
|
ba,pt %xcc, etrap ! Save trap state
|
|
|
|
1: rd %pc, %g7 ! ...
|
2006-02-01 09:34:21 +07:00
|
|
|
stb %l4, [%g6 + TI_FAULT_CODE] ! Save fault code
|
|
|
|
stx %l5, [%g6 + TI_FAULT_ADDR] ! Save fault address
|
2006-02-01 09:29:18 +07:00
|
|
|
call do_sparc64_fault ! Call fault handler
|
|
|
|
add %sp, PTREGS_OFF, %o0 ! Compute pt_regs arg
|
2008-04-24 17:15:22 +07:00
|
|
|
ba,pt %xcc, rtrap ! Restore cpu state
|
2006-02-01 09:29:18 +07:00
|
|
|
nop ! Delay slot (fill me)
|
|
|
|
|
|
|
|
winfix_trampoline:
|
|
|
|
rdpr %tpc, %g3 ! Prepare winfixup TNPC
|
|
|
|
or %g3, 0x7c, %g3 ! Compute branch offset
|
|
|
|
wrpr %g3, %tnpc ! Write it into TNPC
|
|
|
|
done ! Trap return
|
|
|
|
|
2006-02-01 09:32:04 +07:00
|
|
|
/* Insert an entry into the TSB.
|
|
|
|
*
|
2006-02-02 06:55:21 +07:00
|
|
|
* %o0: TSB entry pointer (virt or phys address)
|
2006-02-01 09:32:04 +07:00
|
|
|
* %o1: tag
|
|
|
|
* %o2: pte
|
|
|
|
*/
|
|
|
|
.align 32
|
2006-02-02 06:55:21 +07:00
|
|
|
.globl __tsb_insert
|
|
|
|
__tsb_insert:
|
2006-02-01 09:32:04 +07:00
|
|
|
rdpr %pstate, %o5
|
|
|
|
wrpr %o5, PSTATE_IE, %pstate
|
|
|
|
TSB_LOCK_TAG(%o0, %g2, %g3)
|
|
|
|
TSB_WRITE(%o0, %o2, %o1)
|
|
|
|
wrpr %o5, %pstate
|
|
|
|
retl
|
|
|
|
nop
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.size __tsb_insert, .-__tsb_insert
|
2006-02-01 09:32:04 +07:00
|
|
|
|
2006-02-02 06:55:21 +07:00
|
|
|
/* Flush the given TSB entry if it has the matching
|
|
|
|
* tag.
|
|
|
|
*
|
|
|
|
* %o0: TSB entry pointer (virt or phys address)
|
|
|
|
* %o1: tag
|
|
|
|
*/
|
|
|
|
.align 32
|
|
|
|
.globl tsb_flush
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.type tsb_flush,#function
|
2006-02-02 06:55:21 +07:00
|
|
|
tsb_flush:
|
|
|
|
sethi %hi(TSB_TAG_LOCK_HIGH), %g2
|
|
|
|
1: TSB_LOAD_TAG(%o0, %g1)
|
|
|
|
srlx %g1, 32, %o3
|
|
|
|
andcc %o3, %g2, %g0
|
|
|
|
bne,pn %icc, 1b
|
2008-11-16 04:33:25 +07:00
|
|
|
nop
|
2006-02-02 06:55:21 +07:00
|
|
|
cmp %g1, %o1
|
2006-02-18 09:01:02 +07:00
|
|
|
mov 1, %o3
|
2006-02-02 06:55:21 +07:00
|
|
|
bne,pt %xcc, 2f
|
2006-02-18 09:01:02 +07:00
|
|
|
sllx %o3, TSB_TAG_INVALID_BIT, %o3
|
2006-02-02 06:55:21 +07:00
|
|
|
TSB_CAS_TAG(%o0, %g1, %o3)
|
|
|
|
cmp %g1, %o3
|
|
|
|
bne,pn %xcc, 1b
|
|
|
|
nop
|
|
|
|
2: retl
|
2008-11-16 04:33:25 +07:00
|
|
|
nop
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.size tsb_flush, .-tsb_flush
|
2006-02-02 06:55:21 +07:00
|
|
|
|
2006-02-01 09:29:18 +07:00
|
|
|
/* Reload MMU related context switch state at
|
|
|
|
* schedule() time.
|
|
|
|
*
|
|
|
|
* %o0: page table physical address
|
2006-03-22 15:49:59 +07:00
|
|
|
* %o1: TSB base config pointer
|
|
|
|
* %o2: TSB huge config pointer, or NULL if none
|
|
|
|
* %o3: Hypervisor TSB descriptor physical address
|
sparc64: Prevent perf from running during super critical sections
This fixes another cause of random segfaults and bus errors that may
occur while running perf with the callgraph option.
Critical sections beginning with spin_lock_irqsave() raise the interrupt
level to PIL_NORMAL_MAX (14) and intentionally do not block performance
counter interrupts, which arrive at PIL_NMI (15).
But some sections of code are "super critical" with respect to perf
because the perf_callchain_user() path accesses user space and may cause
TLB activity as well as faults as it unwinds the user stack.
One particular critical section occurs in switch_mm:
spin_lock_irqsave(&mm->context.lock, flags);
...
load_secondary_context(mm);
tsb_context_switch(mm);
...
spin_unlock_irqrestore(&mm->context.lock, flags);
If a perf interrupt arrives in between load_secondary_context() and
tsb_context_switch(), then perf_callchain_user() could execute with
the context ID of one process, but with an active TSB for a different
process. When the user stack is accessed, it is very likely to
incur a TLB miss, since the h/w context ID has been changed. The TLB
will then be reloaded with a translation from the TSB for one process,
but using a context ID for another process. This exposes memory from
one process to another, and since it is a mapping for stack memory,
this usually causes the new process to crash quickly.
This super critical section needs more protection than is provided
by spin_lock_irqsave() since perf interrupts must not be allowed in.
Since __tsb_context_switch already goes through the trouble of
disabling interrupts completely, we fix this by moving the secondary
context load down into this better protected region.
Orabug: 25577560
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-17 22:22:27 +07:00
|
|
|
* %o4: Secondary context to load, if non-zero
|
2006-02-01 09:31:20 +07:00
|
|
|
*
|
|
|
|
* We have to run this whole thing with interrupts
|
|
|
|
* disabled so that the current cpu doesn't change
|
|
|
|
* due to preemption.
|
2006-02-01 09:29:18 +07:00
|
|
|
*/
|
2006-02-27 14:24:22 +07:00
|
|
|
.align 32
|
2006-02-01 09:31:20 +07:00
|
|
|
.globl __tsb_context_switch
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.type __tsb_context_switch,#function
|
2006-02-01 09:31:20 +07:00
|
|
|
__tsb_context_switch:
|
2006-03-22 15:49:59 +07:00
|
|
|
rdpr %pstate, %g1
|
|
|
|
wrpr %g1, PSTATE_IE, %pstate
|
|
|
|
|
sparc64: Prevent perf from running during super critical sections
This fixes another cause of random segfaults and bus errors that may
occur while running perf with the callgraph option.
Critical sections beginning with spin_lock_irqsave() raise the interrupt
level to PIL_NORMAL_MAX (14) and intentionally do not block performance
counter interrupts, which arrive at PIL_NMI (15).
But some sections of code are "super critical" with respect to perf
because the perf_callchain_user() path accesses user space and may cause
TLB activity as well as faults as it unwinds the user stack.
One particular critical section occurs in switch_mm:
spin_lock_irqsave(&mm->context.lock, flags);
...
load_secondary_context(mm);
tsb_context_switch(mm);
...
spin_unlock_irqrestore(&mm->context.lock, flags);
If a perf interrupt arrives in between load_secondary_context() and
tsb_context_switch(), then perf_callchain_user() could execute with
the context ID of one process, but with an active TSB for a different
process. When the user stack is accessed, it is very likely to
incur a TLB miss, since the h/w context ID has been changed. The TLB
will then be reloaded with a translation from the TSB for one process,
but using a context ID for another process. This exposes memory from
one process to another, and since it is a mapping for stack memory,
this usually causes the new process to crash quickly.
This super critical section needs more protection than is provided
by spin_lock_irqsave() since perf interrupts must not be allowed in.
Since __tsb_context_switch already goes through the trouble of
disabling interrupts completely, we fix this by moving the secondary
context load down into this better protected region.
Orabug: 25577560
Signed-off-by: Dave Aldridge <david.j.aldridge@oracle.com>
Signed-off-by: Rob Gardner <rob.gardner@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-17 22:22:27 +07:00
|
|
|
brz,pn %o4, 1f
|
|
|
|
mov SECONDARY_CONTEXT, %o5
|
|
|
|
|
|
|
|
661: stxa %o4, [%o5] ASI_DMMU
|
|
|
|
.section .sun4v_1insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
stxa %o4, [%o5] ASI_MMU
|
|
|
|
.previous
|
|
|
|
flush %g6
|
|
|
|
|
|
|
|
1:
|
2006-03-22 15:49:59 +07:00
|
|
|
TRAP_LOAD_TRAP_BLOCK(%g2, %g3)
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-02-01 09:31:20 +07:00
|
|
|
stx %o0, [%g2 + TRAP_PER_CPU_PGD_PADDR]
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
ldx [%o1 + TSB_CONFIG_REG_VAL], %o0
|
|
|
|
brz,pt %o2, 1f
|
|
|
|
mov -1, %g3
|
|
|
|
|
|
|
|
ldx [%o2 + TSB_CONFIG_REG_VAL], %g3
|
|
|
|
|
|
|
|
1: stx %g3, [%g2 + TRAP_PER_CPU_TSB_HUGE]
|
|
|
|
|
|
|
|
sethi %hi(tlb_type), %g2
|
|
|
|
lduw [%g2 + %lo(tlb_type)], %g2
|
|
|
|
cmp %g2, 3
|
|
|
|
bne,pt %icc, 50f
|
2006-02-10 08:21:53 +07:00
|
|
|
nop
|
|
|
|
|
|
|
|
/* Hypervisor TSB switch. */
|
2006-03-22 15:49:59 +07:00
|
|
|
mov SCRATCHPAD_UTSBREG1, %o5
|
|
|
|
stxa %o0, [%o5] ASI_SCRATCHPAD
|
|
|
|
mov SCRATCHPAD_UTSBREG2, %o5
|
|
|
|
stxa %g3, [%o5] ASI_SCRATCHPAD
|
|
|
|
|
|
|
|
mov 2, %o0
|
|
|
|
cmp %g3, -1
|
|
|
|
move %xcc, 1, %o0
|
2006-02-16 12:16:42 +07:00
|
|
|
|
2006-02-10 13:57:21 +07:00
|
|
|
mov HV_FAST_MMU_TSB_CTXNON0, %o5
|
2006-03-22 15:49:59 +07:00
|
|
|
mov %o3, %o1
|
2006-02-10 08:21:53 +07:00
|
|
|
ta HV_FAST_TRAP
|
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
/* Finish up. */
|
2006-02-10 08:21:53 +07:00
|
|
|
ba,pt %xcc, 9f
|
2006-03-22 15:49:59 +07:00
|
|
|
nop
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-02-10 08:21:53 +07:00
|
|
|
/* SUN4U TSB switch. */
|
2006-03-22 15:49:59 +07:00
|
|
|
50: mov TSB_REG, %o5
|
|
|
|
stxa %o0, [%o5] ASI_DMMU
|
2006-02-10 08:21:53 +07:00
|
|
|
membar #Sync
|
2006-03-22 15:49:59 +07:00
|
|
|
stxa %o0, [%o5] ASI_IMMU
|
2006-02-01 09:29:18 +07:00
|
|
|
membar #Sync
|
|
|
|
|
2006-03-22 15:49:59 +07:00
|
|
|
2: ldx [%o1 + TSB_CONFIG_MAP_VADDR], %o4
|
|
|
|
brz %o4, 9f
|
|
|
|
ldx [%o1 + TSB_CONFIG_MAP_PTE], %o5
|
2006-02-01 09:29:18 +07:00
|
|
|
|
2006-02-10 08:21:53 +07:00
|
|
|
sethi %hi(sparc64_highest_unlocked_tlb_ent), %g2
|
2006-03-22 15:49:59 +07:00
|
|
|
mov TLB_TAG_ACCESS, %g3
|
2006-02-10 08:21:53 +07:00
|
|
|
lduw [%g2 + %lo(sparc64_highest_unlocked_tlb_ent)], %g2
|
2006-03-22 15:49:59 +07:00
|
|
|
stxa %o4, [%g3] ASI_DMMU
|
2006-02-01 09:33:12 +07:00
|
|
|
membar #Sync
|
|
|
|
sllx %g2, 3, %g2
|
2006-03-22 15:49:59 +07:00
|
|
|
stxa %o5, [%g2] ASI_DTLB_DATA_ACCESS
|
|
|
|
membar #Sync
|
|
|
|
|
|
|
|
brz,pt %o2, 9f
|
|
|
|
nop
|
|
|
|
|
|
|
|
ldx [%o2 + TSB_CONFIG_MAP_VADDR], %o4
|
|
|
|
ldx [%o2 + TSB_CONFIG_MAP_PTE], %o5
|
|
|
|
mov TLB_TAG_ACCESS, %g3
|
|
|
|
stxa %o4, [%g3] ASI_DMMU
|
|
|
|
membar #Sync
|
|
|
|
sub %g2, (1 << 3), %g2
|
|
|
|
stxa %o5, [%g2] ASI_DTLB_DATA_ACCESS
|
2006-02-01 09:33:12 +07:00
|
|
|
membar #Sync
|
2006-03-22 15:49:59 +07:00
|
|
|
|
2006-02-01 09:29:18 +07:00
|
|
|
9:
|
2006-03-22 15:49:59 +07:00
|
|
|
wrpr %g1, %pstate
|
2006-02-01 09:29:18 +07:00
|
|
|
|
|
|
|
retl
|
2006-02-01 09:31:20 +07:00
|
|
|
nop
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.size __tsb_context_switch, .-__tsb_context_switch
|
|
|
|
|
|
|
|
#define TSB_PASS_BITS ((1 << TSB_TAG_LOCK_BIT) | \
|
|
|
|
(1 << TSB_TAG_INVALID_BIT))
|
|
|
|
|
|
|
|
.align 32
|
|
|
|
.globl copy_tsb
|
|
|
|
.type copy_tsb,#function
|
|
|
|
copy_tsb: /* %o0=old_tsb_base, %o1=old_tsb_size
|
|
|
|
* %o2=new_tsb_base, %o3=new_tsb_size
|
2017-06-03 04:51:12 +07:00
|
|
|
* %o4=page_size_shift
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
*/
|
|
|
|
sethi %uhi(TSB_PASS_BITS), %g7
|
|
|
|
srlx %o3, 4, %o3
|
2017-06-03 04:51:12 +07:00
|
|
|
add %o0, %o1, %o1 /* end of old tsb */
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
sllx %g7, 32, %g7
|
|
|
|
sub %o3, 1, %o3 /* %o3 == new tsb hash mask */
|
|
|
|
|
2017-06-03 04:51:12 +07:00
|
|
|
mov %o4, %g1 /* page_size_shift */
|
|
|
|
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
661: prefetcha [%o0] ASI_N, #one_read
|
|
|
|
.section .tsb_phys_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
prefetcha [%o0] ASI_PHYS_USE_EC, #one_read
|
|
|
|
.previous
|
|
|
|
|
|
|
|
90: andcc %o0, (64 - 1), %g0
|
|
|
|
bne 1f
|
|
|
|
add %o0, 64, %o5
|
|
|
|
|
|
|
|
661: prefetcha [%o5] ASI_N, #one_read
|
|
|
|
.section .tsb_phys_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
prefetcha [%o5] ASI_PHYS_USE_EC, #one_read
|
|
|
|
.previous
|
|
|
|
|
|
|
|
1: TSB_LOAD_QUAD(%o0, %g2) /* %g2/%g3 == TSB entry */
|
|
|
|
andcc %g2, %g7, %g0 /* LOCK or INVALID set? */
|
|
|
|
bne,pn %xcc, 80f /* Skip it */
|
|
|
|
sllx %g2, 22, %o4 /* TAG --> VADDR */
|
|
|
|
|
|
|
|
/* This can definitely be computed faster... */
|
|
|
|
srlx %o0, 4, %o5 /* Build index */
|
|
|
|
and %o5, 511, %o5 /* Mask index */
|
2017-06-03 04:51:12 +07:00
|
|
|
sllx %o5, %g1, %o5 /* Put into vaddr position */
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
or %o4, %o5, %o4 /* Full VADDR. */
|
2017-06-03 04:51:12 +07:00
|
|
|
srlx %o4, %g1, %o4 /* Shift down to create index */
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
and %o4, %o3, %o4 /* Mask with new_tsb_nents-1 */
|
|
|
|
sllx %o4, 4, %o4 /* Shift back up into tsb ent offset */
|
|
|
|
TSB_STORE(%o2 + %o4, %g2) /* Store TAG */
|
|
|
|
add %o4, 0x8, %o4 /* Advance to TTE */
|
|
|
|
TSB_STORE(%o2 + %o4, %g3) /* Store TTE */
|
|
|
|
|
|
|
|
80: add %o0, 16, %o0
|
2017-06-03 04:51:12 +07:00
|
|
|
cmp %o0, %o1
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
bne,pt %xcc, 90b
|
|
|
|
nop
|
|
|
|
|
|
|
|
retl
|
2008-11-16 04:33:25 +07:00
|
|
|
nop
|
[SPARC64]: Fix and re-enable dynamic TSB sizing.
This is good for up to %50 performance improvement of some test cases.
The problem has been the race conditions, and hopefully I've plugged
them all up here.
1) There was a serious race in switch_mm() wrt. lazy TLB
switching to and from kernel threads.
We could erroneously skip a tsb_context_switch() and thus
use a stale TSB across a TSB grow event.
There is a big comment now in that function describing
exactly how it can happen.
2) All code paths that do something with the TSB need to be
guarded with the mm->context.lock spinlock. This makes
page table flushing paths properly synchronize with both
TSB growing and TLB context changes.
3) TSB growing events are moved to the end of successful fault
processing. Previously it was in update_mmu_cache() but
that is deadlock prone. At the end of do_sparc64_fault()
we hold no spinlocks that could deadlock the TSB grow
sequence. We also have dropped the address space semaphore.
While we're here, add prefetching to the copy_tsb() routine
and put it in assembler into the tsb.S file. This piece of
code is quite time critical.
There are some small negative side effects to this code which
can be improved upon. In particular we grab the mm->context.lock
even for the tsb insert done by update_mmu_cache() now and that's
a bit excessive. We can get rid of that locking, and the same
lock taking in flush_tsb_user(), by disabling PSTATE_IE around
the whole operation including the capturing of the tsb pointer
and tsb_nentries value. That would work because anyone growing
the TSB won't free up the old TSB until all cpus respond to the
TSB change cross call.
I'm not quite so confident in that optimization to put it in
right now, but eventually we might be able to and the description
is here for reference.
This code seems very solid now. It passes several parallel GCC
bootstrap builds, and our favorite "nut cruncher" stress test which is
a full "make -j8192" build of a "make allmodconfig" kernel. That puts
about 256 processes on each cpu's run queue, makes lots of process cpu
migrations occur, causes lots of page table and TLB flushing activity,
incurs many context version number changes, and it swaps the machine
real far out to disk even though there is 16GB of ram on this test
system. :-)
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-03-16 17:02:32 +07:00
|
|
|
.size copy_tsb, .-copy_tsb
|
2006-03-19 14:55:11 +07:00
|
|
|
|
|
|
|
/* Set the invalid bit in all TSB entries. */
|
|
|
|
.align 32
|
|
|
|
.globl tsb_init
|
|
|
|
.type tsb_init,#function
|
|
|
|
tsb_init: /* %o0 = TSB vaddr, %o1 = size in bytes */
|
|
|
|
prefetch [%o0 + 0x000], #n_writes
|
|
|
|
mov 1, %g1
|
|
|
|
prefetch [%o0 + 0x040], #n_writes
|
|
|
|
sllx %g1, TSB_TAG_INVALID_BIT, %g1
|
|
|
|
prefetch [%o0 + 0x080], #n_writes
|
|
|
|
1: prefetch [%o0 + 0x0c0], #n_writes
|
|
|
|
stx %g1, [%o0 + 0x00]
|
|
|
|
stx %g1, [%o0 + 0x10]
|
|
|
|
stx %g1, [%o0 + 0x20]
|
|
|
|
stx %g1, [%o0 + 0x30]
|
|
|
|
prefetch [%o0 + 0x100], #n_writes
|
|
|
|
stx %g1, [%o0 + 0x40]
|
|
|
|
stx %g1, [%o0 + 0x50]
|
|
|
|
stx %g1, [%o0 + 0x60]
|
|
|
|
stx %g1, [%o0 + 0x70]
|
|
|
|
prefetch [%o0 + 0x140], #n_writes
|
|
|
|
stx %g1, [%o0 + 0x80]
|
|
|
|
stx %g1, [%o0 + 0x90]
|
|
|
|
stx %g1, [%o0 + 0xa0]
|
|
|
|
stx %g1, [%o0 + 0xb0]
|
|
|
|
prefetch [%o0 + 0x180], #n_writes
|
|
|
|
stx %g1, [%o0 + 0xc0]
|
|
|
|
stx %g1, [%o0 + 0xd0]
|
|
|
|
stx %g1, [%o0 + 0xe0]
|
|
|
|
stx %g1, [%o0 + 0xf0]
|
|
|
|
subcc %o1, 0x100, %o1
|
|
|
|
bne,pt %xcc, 1b
|
|
|
|
add %o0, 0x100, %o0
|
|
|
|
retl
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.size tsb_init, .-tsb_init
|
|
|
|
|
|
|
|
.globl NGtsb_init
|
|
|
|
.type NGtsb_init,#function
|
|
|
|
NGtsb_init:
|
|
|
|
rd %asi, %g2
|
|
|
|
mov 1, %g1
|
|
|
|
wr %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
|
|
|
|
sllx %g1, TSB_TAG_INVALID_BIT, %g1
|
|
|
|
1: stxa %g1, [%o0 + 0x00] %asi
|
|
|
|
stxa %g1, [%o0 + 0x10] %asi
|
|
|
|
stxa %g1, [%o0 + 0x20] %asi
|
|
|
|
stxa %g1, [%o0 + 0x30] %asi
|
|
|
|
stxa %g1, [%o0 + 0x40] %asi
|
|
|
|
stxa %g1, [%o0 + 0x50] %asi
|
|
|
|
stxa %g1, [%o0 + 0x60] %asi
|
|
|
|
stxa %g1, [%o0 + 0x70] %asi
|
|
|
|
stxa %g1, [%o0 + 0x80] %asi
|
|
|
|
stxa %g1, [%o0 + 0x90] %asi
|
|
|
|
stxa %g1, [%o0 + 0xa0] %asi
|
|
|
|
stxa %g1, [%o0 + 0xb0] %asi
|
|
|
|
stxa %g1, [%o0 + 0xc0] %asi
|
|
|
|
stxa %g1, [%o0 + 0xd0] %asi
|
|
|
|
stxa %g1, [%o0 + 0xe0] %asi
|
|
|
|
stxa %g1, [%o0 + 0xf0] %asi
|
|
|
|
subcc %o1, 0x100, %o1
|
|
|
|
bne,pt %xcc, 1b
|
|
|
|
add %o0, 0x100, %o0
|
2007-03-20 03:27:33 +07:00
|
|
|
membar #Sync
|
2006-03-19 14:55:11 +07:00
|
|
|
retl
|
|
|
|
wr %g2, 0x0, %asi
|
|
|
|
.size NGtsb_init, .-NGtsb_init
|