KVM: add support for SVM Nested Paging

Joerg Roedel
2008-02-07T12:49:58Z

Hi,

here is the improved patchset which adds support for the Nested Paging
feature of the AMD Barcelona and Phenom processors to KVM. The patch set
was successfully install- and runtime-tested with various guest
operating systems (64 bit, 32 bit legacy and 32 bit PAE Linux,
Windows 64 bit and 32 bit versions too).

To the previous post of these patches they were extended with support
for KVM on 32 bit PAE hosts. Live migration is also implemented and
tested in various situations (migration between 32 bit and 64 bit host,
Non-NPT to/from NPT migration, NPT to NPT migration, all with various
kinds of guests, including Windows). After all these tests I am pretty
sure that these patches don't introduce any regression to KVM and
therefore the NPT feature is enabled per default.

Some new performance numbers are also available. For this test I started
an Ubuntu 7.10 guest with 4 vcpus and 3G of RAM on a dual socket Opteron
box and ran kernbench -M in it with a 2.6.24 kernel as the source tree.
The test was done with traditional Shadow Paging and using Nested
Paging. The tests ran on the text console with GDM stopped. Here are the
results:

-----------------------------------------------------------------------
Average Half load -j 3 Run:
-----------------+-------------------------+---------------------------
| Nested Paging | Shadow Paging
-----------------+-------------------------+---------------------------
| Time (std deviation) | Time (std deviation)
-----------------+-------------------------+---------------------------
Elapsed Time | 147.574 (0.642168) | 211.73 (0.802963)
User Time | 382.036 (1.14742) | 416.254 (1.91732)
System Time | 48.29 (0.261151) | 221.608 (0.706307)
Percent CPU | 291 (0.707107) | 300.8 (0.447214)
Context Switches | 33605.4 (148.788) | 34901 (434.318)
Sleeps | 47351 (98.2395) | 47017.8 (378.582)
-----------------+-------------------------+---------------------------
Average Half load -j 16 Run:
-----------------+-------------------------+---------------------------
| Nested Paging | Shadow Paging
-----------------+-------------------------+---------------------------
| Time (std deviation) | Time (std deviation)
-----------------+-------------------------+---------------------------
Elapsed Time | 120.156 (0.337757) | 179.162 (1.49999)
User Time | 385.318 (3.57206) | 421.624 (5.82785)
System Time | 48.959 (0.811411) | 230.8 (9.70806)
Percent CPU | 327.6 (38.5982) | 336.2 (37.3655)
Context Switches | 42435.5 (9312.09) | 46190.7 (11909.6)
Sleeps | 50297.5 (3111.73) | 50688 (3882.49)
-----------------+-------------------------+---------------------------

In other words, Nested Paging gave 30% performance improvement in the
'make -j 3' run and a 33% improvement in the 'make -j 16' run for this
benchmark.

I think these patches are ready for merging into the KVM tree. Please
consider for inclusion.

Joerg Roedel