]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
libkvm: Improve physical address lookup scaling.
authorWill Andrews <will@FreeBSD.org>
Mon, 18 Jul 2016 01:55:25 +0000 (01:55 +0000)
committerWill Andrews <will@FreeBSD.org>
Mon, 18 Jul 2016 01:55:25 +0000 (01:55 +0000)
commitffdeef3234496b79624f4ba34e3d0a6893f41404
treef3433c72f62be02adf456241724fa38f416ac461
parent8fb15a24ceb2fa5cfd4849466dd9ca2a27ce2bff
libkvm: Improve physical address lookup scaling.

Instead of using a hash table to convert physical page addresses to offsets
in the sparse page array, cache the number of bits set for each 4MB chunk of
physical pages.  Upon lookup, find the nearest cached population count, then
add/subtract the number of bits from that point to the page's PTE bit.
Then multiply by page size and add to the sparse page map's base offset.

This replaces O(n) worst-case lookup with O(1) (plus a small number of bits
to scan in the bitmap).  Also, for a 128GB system, a typical kernel core of
about 8GB will now only require ~4.5MB of RAM for this approach instead of
~48MB as with the hash table.

More concretely, /usr/sbin/crashinfo against the same core improves from a
max RSS of 188MB and wall time of 43.72s (33.25 user 2.94 sys) to 135MB and
9.43s (2.58 user 1.47 sys).  Running "thread apply all bt" in kgdb has a
similar RSS improvement, and wall time drops from 4.44s to 1.93s.

Reviewed by: jhb
Sponsored by: Backtrace I/O
lib/libkvm/kvm.c
lib/libkvm/kvm_minidump_aarch64.c
lib/libkvm/kvm_minidump_amd64.c
lib/libkvm/kvm_minidump_arm.c
lib/libkvm/kvm_minidump_i386.c
lib/libkvm/kvm_minidump_mips.c
lib/libkvm/kvm_private.c
lib/libkvm/kvm_private.h