My *nix world

Gentoo AMD Ryzen stabilizator

It's been a while since my last post on this blog due to an overloaded working schedule. However, now I found a good reason to write a new one and to share my experience with the world.

Recently I've built a new system since my old system (which faithfully stayed besides me for the last 10 years) cannot handle my current projects anymore.

Since I am a computer programmer and as such my daily work is a mix of writing code, compiling and testing, I do not need a super powerful system. Not even a gaming-like system. So I set-up a budget of max 1000 USD for the new system although I was hoping to manage with less.

My old system has been upgraded gradually from a Intel Core2Duo with 4GB-DDR2 to an Intel Xenon X3330 (4 cores @2.66GHz), 8GB DDR2 and 120GB SSD and thus it would be sensible to assume that  my new system should be at least double as good as the previous one (my goal is to use it for the next 10 years).

In order to make my decision easier I've created two different hardware/budget profiles, one based on a Intel i7 CPU and one one an AMD CPU:

Part name Intel AMD
CPU  i7 8700 @3.2GHz (6/12 core/threads)  Ryzen 5 2400G @3.6GHz (4/8 core/threads, OC@3.9GHz)
Motherboard  Gigabyte GA-Z270-HD3P  ASUS Prime B350-Plus
 Memory Crucial Ballistix Sport LT DDR4 PC21300/2666MHz CL16 2x8GB
 CPU Fan  Intel stock AMD stock
GPU not provided built-in
Storage Adata XPG SX6000 256GB M.2 2280 form factor NVME
Seagate Barracuda ST2000DM006 64MB 2TB @7200rpm
PSU Corsair VS550 V3 550W
Case Cougar Solution 2
TOTAL 970 USD  737 USD

Since the Intel i7 8700 was ~344 USD while the AMD Ryzen 5 2400G which has also a built-in AMD Radeon Vega 11 GPU was only 166 USD  (less than half!) and since the Intel i7 CPU performs only with 16% better than AMD I thought that I should go with the AMD. And so I did.

Jumping from a 2.66GHz CPU to a 3.6GHz  CPU and from a DDR2 to a DDR4 we would expect some gain in speed, right? Well, I have to tell you, the speed gain is amazing. From the after POST stage to the full desktop stage it takes ~3-4 seconds. Let alone that the whole used memory is less than 200MB (out of 16GB) so I still could use a lot of those 16GB for my projects.

Since I am a Linux Gentoo fan(atic) I installed Gentoo without hesitation although, to be honest, I was little bit worried because this AMD Ryzen 5 2400G is pretty new on the market (not old enough to gain enough support within the Linux community) and you know, with its Radeon built-in GPU anything can happen. For instance a segmentation fault, the system freezing, etc.

Now let me share you few problems I've encountered and how I've tackled them.

The main problem I have encountered was that while the system was compiling the Linux kernel (or any of those 500 different software packages), the CPU - which used all its 4/8 cores/threads @ 100% - went from a 30C on idle to a +53C on full load. The temperature might be higher actually, these figures are from a lm_sensors configuration calibrated for another sensor but it was better than nothing, so...

When getting hot the CPU might become unstable (ie. random segmentation faults here and there). Sometimes by giving another try, by compiling a second or a third time the same package it finally succeeded without faults. I would like to emphasize that in general the segmentation fault situations were quite rare (Firefox, LibreOffice, Linux kernel, usually only the big packages which take more than 30minus with 100% load). The temporary quick fix was to set the compiler to use only half of its cores/threads and thus producing less heat. However this was just annoying since I was open to go through all this hell to get a better system, right?

Digging a little bit on the Internet I've found many people having more/less similar issues, each of them proposing one quick fix or another. However, what I did and it helped a lot (I've recompiled all 500+ packages and the Linux kernel with all 4/8 cores/threads at 100% full load without any segmentation fault or freeze) was to:

  1. disable the ALSR (more here and here)
  2. tweak the kernel's RCU subsystem for for Ryzen by enabling the Offload RCU callback processing from boot-selected CPUs kernel option:

CONFIG_RCU_NOCB_CPU:

Use this option to reduce OS jitter for aggressive HPC or real-time workloads. It can also be used to offload RCU callback invocation to energy-efficient CPUs in battery-powered asymmetric multiprocessors.

This option offloads callback invocation from the set of CPUs specified at boot time by the rcu_nocbs parameter. For each such CPU, a kthread ("rcuox/N") will be created to invoke callbacks, where the "N" is the CPU being offloaded, and where the "x" is "b" for RCU-bh, "p" for RCU-preempt, and "s" for RCU-sched. Nothing prevents this kthread from running on the specified CPUs, but (1) the kthreads may be preempted between each callback, and (2) affinity or cgroups can be used to force the kthreads to run on whatever set of CPUs is desired.

  1. add the rcu_nocbs=0-n (where n=number of threads -1) kernel boot parameter in the kernel command line (see CONFIG_CMDLINE_BOOL)

Since I've built this kernel (like one week ago) the system had no freeze or segmentation fault during compilation or normal usage anymore. In case you encountered some of the symptoms described earlier then I think it's worth trying the above quick-fix.

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
Gentoo AMD Ryzen stabilizator

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Gentoo AMD Ryzen stabilizator

Latest posts by Eugen Mihailescu (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *