The PartitionBucketNumSystemPages() seems odd in general especially in the way its results are consumed by PartitionBucketPartitionPages().
The calculation logic isn't super clear as to what it's doing and if it's correctly accounting for PTEs or what.
It's also odd that the main user seems to talk in units of PartitionPages where this function returns SystemPages. This causes an odd rounding in PartitionBucketPartitionPages() that may or may not undo part of the logic in this function.
Resolving this bug should be done by some subset of:
(a) Adding in clarifying comments
(b) Making everything use the same units
(c) Removing this function if it's unnecessary
(d) Fixing the PTE accounting logic.
Comment 1 by ajwong@chromium.org
, Oct 19 2017