Skip to content

Commit

Permalink
Revert "[kernel] Enable zero page scanning as default"
Browse files Browse the repository at this point in the history
This reverts commit a84ed3e.

Reason for revert: Appears to be causing kernel panics in CI/CQ on bringup.x64-asan-qemu_kvm
bot:

*** KERNEL PANIC (caller pc: 0xffffffff00250abf, stack frame: 0xffffff97deeb4e90):
*** ASSERT FAILED at (../../zircon/kernel/vm/vm_object_paged.cc:2612): status == ZX_OK
Tried to unpin an uncommitted page
platform_halt suggested_action 0 reason 4
Halting...
zx_system_get_version_string git-2642c26148d2c2339a2002f46e3127d2095eae14-dirty
 [[[ELF module #0x0 "kernel" BuildID=ce232edbed693ebc 0xffffffff00100000]]]
dso: id=ce232edbed693ebc base=0xffffffff00100000 name=zircon.elf
    #0    0xffffffff001bb2a7 in platform_specific_halt ../../out/default.zircon/../../zircon/kernel/platform/pc/power.cc:147 <kernel>+0xffffffff801bb2a7
    #1    0xffffffff002913b6 in platform_halt ../../out/default.zircon/../../zircon/kernel/platform/power.cc:59 <kernel>+0xffffffff802913b6
    #2    0xffffffff00101297 in panic ../../out/default.zircon/../../zircon/kernel/top/debug.cc:59 <kernel>+0xffffffff80101297
    #3    0xffffffff00250abf in VmObjectPaged::UnpinLocked(unsigned long, unsigned long) ../../out/default.zircon/../../zircon/kernel/vm/vm_object_paged.cc:2612 <kernel>+0xffffffff80250abf
    #4    0xffffffff00250ce7 in VmObjectPaged::Unpin(unsigned long, unsigned long) ../../out/default.zircon/../../zircon/kernel/vm/vm_object_paged.cc:2579 <kernel>+0xffffffff80250ce7
    #5    0xffffffff0025b0bb in vmo_multiple_pin_test() ../../out/default.zircon/../../zircon/kernel/vm/vm_unittest.cc:1103 <kernel>+0xffffffff8025b0bb
    #6.1  0xffffffff001397de in run_unittest(unitest_testcase_registration const*) ../../out/default.zircon/../../zircon/kernel/lib/unittest/unittest.cc:140 <kernel>+0xffffffff801397de
    #6    0xffffffff001397de in run_unittest_thread_entry(void*) ../../out/default.zircon/../../zircon/kernel/lib/unittest/unittest.cc:166 <kernel>+0xffffffff801397de
    #7    0xffffffff002838c9 in initial_thread_func() ../../out/default.zircon/../../zircon/kernel/kernel/thread.cc:0 <kernel>+0xffffffff802838c9
    #8    0x0000000000000000 in <>+0x0

Original change's description:
> [kernel] Enable zero page scanning as default
> 
> Zero page scanning is a useful memory saving tool across almost all of
> our targets. The exception being when running microbenchmarks, which
> explicitly disables the scanner.
> 
> Default values are now:
> kernel.page-scanner.start-at-boot=true
> kernel.page-scanner.zero-page-scans-per-second=20000
> 
> Having the scanner be enabled by default allows for consistent behavior
> and expectations across configurations, although any configuration is
> still able to tune, or completely turn off, scanning.
> 
> Bug: 49773
> 
> Change-Id: Id742f7729c6101a662c9330150ed20188528f890
> Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/385894
> Commit-Queue: Adrian Danis <[email protected]>
> Testability-Review: Adrian Danis <[email protected]>
> Reviewed-by: James Robinson <[email protected]>
> Reviewed-by: Carlos Pizano <[email protected]>

[email protected],[email protected],[email protected]

Change-Id: I348cb623627be3d6161d1c225d3fc85d933bfd9c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 49773
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/387033
Commit-Queue: David Greenaway <[email protected]>
Reviewed-by: David Greenaway <[email protected]>
  • Loading branch information
davidgreenaway authored and CQ bot account: [email protected] committed May 6, 2020
1 parent 2642c26 commit aa6df63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
7 changes: 0 additions & 7 deletions boards/x64-reduced-perf-variation.gni
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,4 @@ board_kernel_cmdline_args = [
# which should bring all devices to the same patch level, removing the
# performance differences when spectre mitigations are in place.
"kernel.x86.disable_spec_mitigations=true",

# Disable page scanning in all its forms. Page scanning is intended to
# provide a memory benefit to final systems, but the operation of the scanner
# and its unpredictable de-duplication or eviction of memory in use by
# benchmarks could cause noticable variation.
"kernel.page-scanner.start-at-boot=false",
"kernel.page-scanner.zero-page-scans-per-second=0",
]
13 changes: 4 additions & 9 deletions docs/reference/kernel/kernel_cmdline.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,16 @@ terminated, or has no jobs and no processes.

## kernel.page-scanner.start-at-boot=\<bool>

This option (true by default) causes the kernels active memory scanner to be
This option (false by default) causes the kernels active memory scanner to be
initially enabled on startup. You can also enable and disable it using the
kernel console. If you disable the scanner, you can have additional system
predictability since it removes time based and background memory eviction.

Every action the scanner performs can be individually configured and disabled.
If all actions are disabled then enabling the scanner has no effect.

## kernel.page-scanner.zero-page-scans-per-second=\<num>

This option, 20000 by default, configures the maximal number of candidate pages
the zero page scanner will consider every second.

Setting to zero means no zero page scanning will occur. This can provide
additional system predictability for benchmarking or other workloads.
This option, zero by default, configures the maximal number of candidate pages
the zero page scanner will consider every second. Setting to zero means no
zero page scanning will occur.

The page scanner must be running for this option to have any effect. It can be
enabled at boot with the `kernel.page-scanner.start-at-boot` option.
Expand Down
11 changes: 3 additions & 8 deletions zircon/kernel/vm/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ static constexpr uint32_t kScannerOpRotateQueues = 1u << 5;
// Amount of time between pager queue rotations.
static constexpr zx_duration_t kQueueRotateTime = ZX_SEC(10);

// If not set on the cmdline this becomes the default zero page scans per second to target. This
// value was chosen to consume, in the worst case, 5% CPU on a lower-end arm device. Individual
// configurations may wish to tune this higher (or lower) as needed.
constexpr uint64_t kDefaultZeroPageScansPerSecond = 20000;

// Number of pages to attempt to de-dupe back to zero every second. This not atomic as it is only
// set during init before the scanner thread starts up, at which point it becomes read only.
static uint64_t zero_page_scans_per_second = 0;
Expand Down Expand Up @@ -203,9 +198,9 @@ static void scanner_init_func(uint level) {
Thread *thread =
Thread::Create("scanner-request-thread", scanner_request_thread, nullptr, LOW_PRIORITY);
DEBUG_ASSERT(thread);
zero_page_scans_per_second = gCmdline.GetUInt64("kernel.page-scanner.zero-page-scans-per-second",
kDefaultZeroPageScansPerSecond);
if (!gCmdline.GetBool("kernel.page-scanner.start-at-boot", true)) {
zero_page_scans_per_second =
gCmdline.GetUInt64("kernel.page-scanner.zero-page-scans-per-second", 0);
if (!gCmdline.GetBool("kernel.page-scanner.start-at-boot", false)) {
Guard<Mutex> guard{scanner_disabled_lock::Get()};
scanner_disable_count++;
scanner_operation.fetch_or(kScannerOpDisable);
Expand Down

0 comments on commit aa6df63

Please sign in to comment.