Patch NPT on Ryzen for Better Performance | Level One Techs

Are you also the one that did the thing with ā€œlaptop gsync panels?ā€ if so I hexedited the driver and was able to confirm that. They shut that down so fast Iā€™m still reeling over it.

PM issue fixed.

Thanks :). And no, that one wasnā€™t me. PM sent.

Iā€™m not sure how this works, Wendell might know better.

I had the same experience when I realized my 3770k didnā€™t support IOMMU. Very sad.

Yeah, everyone in my department is running Linux with a windows VM and a 480 or a 580 passed through for proprietary windows stuff and games. When the NPT patch hit patchwork, one of my underlings came running into my office with a huge smile on. Youā€™re a hero in our office.

2 Likes

Wendel! You are my Hero again!

I compiled a patched Linux kernel just yet! Thanks alot for the guide! I never did it before (because there was no reason :wink: )

Tested yet 2 Benchmarks: Unigine Vally: DX11 (high preset, AA off) and Resident Evil 6 Bench Tool: DX9c (all High, AA off)
both on a passthroughed Sapphire RX 560 oc to 1434 MHz CPU and 2GHz VRAM.

Before the Patch:
Unigine ~52 FPS; 2170 Points (min FPS 18,5 / max FPS 103,8)
RE6 BT ~3700 Points

After the Patch:
Unigine ~ 58,4; 2443 Points (min FPS 28,0 / max FPS 107,2)
RE6 BT ~9600 Points

DirectX9c Games got a huuuuugh boost! DX11 Games where always playable but slightly choppy.

Now its veeeery smooth on my System.
Btw. Iā€™m rocking the following System:

Ryzen 5 1600x OC to 3.925Ghz
RAM: Corsair Vengeance 3200 @ 3200MHz of course
Board: Asus Crosshair 6 Hero BIOS 17.01
Host Disk: Crucial M500 m2 SSD
Guest Disk: QCow2 Image
GPU: Sapphire RX 560 Pulse 4GB + Arctic Accelero Xtreme IV 280x Custom Cooler

Im quite happy with the results :wink:

Mit freundlichen GrĆ¼ĆŸen
Marfi

Update 2017-11-02:
I have to add: in my case a crucial package was not installed on my Ubuntu to do the Kernel compile. Please take care the package libssl-dev is installed via apt or synpatic package-manager.

1 Like

Hi all,

I started yesterday a larger benchmark session with a wide varity of DX11, DX9c, DX12 and on Vulkan API Games. I want to compair NPT=1 vs NPT=0 vs Native Windows 10 performance and post my resultes (probably in a new Threadā€¦). I hope some one find it usefull or ā€œentertainingā€ :wink:
Here the list of Games/Benchmarks that i wanne to use (i.g. started to use):

Benchmarks

  • Unigine Vally (DX11)
  • Unigine Heaven (DX11)
  • Unigine Superposition (DX11)
  • Resident Evil 6 Bechmark Tool (DX9c)
  • Resident Evil 5 Benchmark 1 (DX9c)
  • Resident Evil 5 Benchmark 2 (DX9c)
  • Tomb Raider
  • Rise of Tomb Raider (DX12)
  • Steam VR Performance Test
  • Ashes of the Singularity: Escalation (DX12 and Vulkan)

Now I will not use my RX 560 card for the Passthrough, instead I pass my XFX R9 280x thru my VM. On earlier tests I noticed around 30% performance loss compaired to native use. My RX 560 ā€œonlyā€ lost around 10% Performance with the buggy Nested Page Tables (what was quite intresting).

I think I can post the NPT=1 numbers this evening (German Time)ā€¦

Viele GrĆ¼ĆŸe
Marf :slight_smile:

Edit 2017-11-03:
As promised, I created just yet a new Thread where I will post my benchmark numbers. Please understandā€¦ WIP ā€¦ :wink:
You will find the thread here: GPU Passthrough Performance Numbers: Ryzen NPT Patch vs Buggy NPT vs Native Windows

2 Likes

An update for anyone watching: I made 2 concurrent mistakes while testing the patch, causing me much confusion for an couple of hours. I both failed to apply the patch correctly (first time using a custom kernel) and failed to properly re-enable NPT. This explains why I was experiencing less-than-ideal performance. After remedying these 2 errors performance improved hugely, and I am (more or less :wink: ) officially done tinkering. This passthrough thing is now final the solution to all my woes! Benchmarks in this thread: GPU Passthrough Performance Numbers: Ryzen NPT Patch vs Buggy NPT vs Native Windows

2 Likes

Having trouble applying the patch on fedora 27 (trying kernel 4.13.11-301), and Iā€™m out of ideas for on how to fix it. Iā€™m able to compile the kernel on its own, or even just with a working Aur-acs patch. However adding the NTP patch on top of that causes rpmbuild to fail before I even start compiling.

Here are the commands I use to reproduce this

fedpkg clone -a kernel
git checkout -b my_kernel origin/f27
sudo dnf builddep kernel.spec
./scripts/newpatch.sh Aur-acs.patch
./scripts/newpatch.sh ryzen.patch
make release
sudo fedpkg local

pulled the patch from patchwork kernel, and I applied the aur-acs fixes (which compiled just fine on its own). I donā€™t think its required, but I installed my matching kernel-devel package just in case. (also util-linux)
Iā€™m going to assume Iā€™m missing something obvious, but if you need any more information I can provide it. Sorry if this is an inappropriate thread for this, at this point.

Iā€™m sorry I canā€™t be of more help - I found this stage challenging too. In the end I downloaded the kernel from kernel.org, applied the patch and built it using variations on Wendellā€™s commands with help from this page: https://fedoraproject.org/wiki/Building_a_custom_kernel

Perhaps itā€™s a missing dependency issue? I fear any advice of mine beyond here is likely to cause more harm than good. I recommend reading that Fedora wiki thoroughly though

1 Like

OK, I think I got it working. I had to use another method to apply the patch (We can pretend I used the ā€œcat | patchā€ method as described in the fedora wiki and not just gedit like the filthy casual I am). Iā€™ll run some tests tomorrow to see if I really got it working. Maybe Iā€™ll throw together a few benchmarks against the kernel without the ntp patch if I have the time. Thanks for your help.

1 Like

@dailan post the build log (use pastebin or something similar), itā€™s very unlikely that anyone here is going to replicate your steps to figure out the error you were getting.

Unless Iā€™m missing something, the build-log doesnā€™t seem to have any useful information. Here it is. It does, however, point to this code. The warning about unexpanded macros seems to be harmless.
AND just in case, my current ryzen.patch file. If anyone wants any more information, I would be happy to provide it.

Alright here are some quick and dirty benchmarks, the difference that this patch made was night and day.

In total war warhammer IIā€™s campaign benchmark at 1080p
Before: Min 10, Max 25, Average 16.9 FPS
After: Min 43, Max 86, Average 61.6 FPS

In total war warhammer IIā€™s battle benchmark at 1080p
Before: Min 6, Max 17, Average 10.8 FPS
After: Min 43, Max 61, Average 54.3 FPS

In Civ 6ā€™s graphics benchmark at 34440x1440
Before: 99th 65.95, Average 47.66 frame times in MS
After: 99th 24.16, Average 18.68 frame times in MS

Civ 6ā€™s AI benchmark at 3440x1440
Before: Average 33.2 second turns
After: Average 26.5 second turns

Skyrim (just eyeballing it) outside
Before: Min 1, Max 35, Average 20 FPS
After: Min 30, Max 50, Average 40 FPS

Skyrim (just eyeballing it) inside
Before: Min 30, Max 55, Average 40 FPS
After: Min 60, Max 60, Average 60 FPS

I am using my old card GTS 450 for passing through to my Ubuntu VM, but this card suffers from a reset bug. I have tried detaching the card via command line and then shutdown VM, tried rom dump and feed it in the config - nothing helps. Every time I shut down the VM or reboot, I get black screen and I need to reboot host PC.
Is there any way to power cycle PCIe from host command line in order to initialize it more than once?
BTW, I am on Ryzen 1600 and Asus X370-pro with the latest BIOS (1001).

This is a hardware bug that canā€™t be fixed. On some GPU that have dual-bios (my Fury Nitro for example) can be reset by switching to the other BIOS.

OK and what about that patch that Wendell is talking about in the stream starting @11:35? Kernel 4.15 patch with power cycle to the PCIe?

1 Like

Basically this (as I understand at least):

1 Like

Iā€™m not super up to date on it, because Iā€™m not using Vega or any other GPUs that suffer from this bug (at least, not for passthrough)

Iā€™m going to defer to @mihawk90 and Wendell since theyā€™re clearly following it more closely.

actually not really, just reading a bit :stuck_out_tongue:

Still following it more closely than I am. I just stay away from GPU with the issue.

So, for my issue it would be either to somehow reboot or shutdown Ubuntu VM with a some kind of script rather than sudo shutdown or to power cycle on the host system.
I have tried to run this from host OS:

virsh detach-device Ubuntu /mnt/user/system/gpudev.xml
virsh detach-device Ubuntu /mnt/user/system/audiodev.xml
virsh destroy Ubuntu

where xmls are:

GPU
gpudev.xml

  <hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
      <address domain='0x000' bus='0x29' slot='0x00' function='0x0'/>
    </source>
  </hostdev>

HDMI audio
audiodev.xml

  <hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
      <address domain='0x000' bus='0x15' slot='0x00' function='0x1'/>
    </source>
  </hostdev>

After that it says that device was successfully detached and vm was destroyed, but still I cannot use GPU for the second time without host OS reboot.
Any ideas?