[kernel][vm] Keep per cpu counts of vm_page states

The purpose of this change is to improve the performance of
ZX_INFO_KMEM_STATS.  By maintaining counters of vm_page states we no
longer need to walk all pages to compute ZX_INFO_KMEM_STATS.

A previous version of this change used global atomic integers, but
that proved to be too expensive (ZX-3916).  Instead, we use per cpu
counters and access them with preemption disabled.

Move vm_page_state to it's own file to prevent a cicular dependency
between page and percpu.

Add a couple static helper methods to Percpus to facilitate accessing
per cpu counters like vm_page_counts.

Ran zircon_benchmarks on a NUC to ensure this doesn't significantly
regress performance.  Looked at Channel/WriteRead/64bytes as it seems
to be a bellwether.

Before --

      Mean    Std dev        Min        Max     Median Unit         Mean Mbytes/sec Test case
       562         33        542       6403        555 nanoseconds          108.552 Channel/WriteRead/64bytes
       277         19        263       4391        272 nanoseconds              N/A Channel/WriteRead/64bytes.write
       285         17        274       2680        282 nanoseconds              N/A Channel/WriteRead/64bytes.read

After --

      Mean    Std dev        Min        Max     Median Unit         Mean Mbytes/sec Test case
       571         13        558       6263        569 nanoseconds          106.880 Channel/WriteRead/64bytes
       284         10        275       4458        282 nanoseconds              N/A Channel/WriteRead/64bytes.write
       287          7        279       1805        286 nanoseconds              N/A Channel/WriteRead/64bytes.read

Bug: ZX-833 #comment per cpu counts
Test: booted and ran 'kstats -m'
Change-Id: I18083c4dbc3d0423cc59cf3700a93dc72de8d2e3
11 files changed
tree: 67dc1839ccb9c8d1c11e217d9bc79017e6265604
  1. boards/
  2. build/
  3. buildtools/
  4. bundles/
  5. docs/
  6. examples/
  7. garnet/
  8. peridot/
  9. products/
  10. scripts/
  11. sdk/
  12. src/
  13. third_party/
  14. tools/
  15. zircon/
  16. .clang-format
  17. .dir-locals.el
  18. .gitattributes
  19. .gitignore
  20. .gn
  21. AUTHORS
  22. BUILD.gn
  23. CODE_OF_CONDUCT.md
  24. CONTRIBUTING.md
  25. LICENSE
  26. OWNERS
  27. PATENTS
  28. README.md
  29. rustfmt.toml
README.md

Fuchsia

Pink + Purple == Fuchsia (a new operating system)

What is Fuchsia?

Fuchsia is a modular, capability-based operating system. Fuchsia runs on modern 64-bit Intel and ARM processors.

Fuchsia is an open source project with a code of conduct that we expect everyone who interacts with the project to respect.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See the documentation.