From dffd6149be852c731125ec549c3a96467c4dffc2 Mon Sep 17 00:00:00 2001 From: MidAutumnMoon Date: Tue, 20 Aug 2024 19:37:43 +0800 Subject: [PATCH] a-tale-of-nohz-full-and-throttled-cpu: delete --- .envrc | 1 + .../index.mdx | 45 ----- .../topo.svg | 182 ------------------ 3 files changed, 1 insertion(+), 227 deletions(-) create mode 100644 .envrc delete mode 100644 src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/index.mdx delete mode 100755 src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/topo.svg diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1c13b80 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export LUME_DRAFTS="true" diff --git a/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/index.mdx b/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/index.mdx deleted file mode 100644 index 3f05548..0000000 --- a/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/index.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: A Tale of NOHZ_FULL and Throttled CPU -date: '2023-09-11' -updated: '2023-09-11' -tags: - - linux -incomplete: true ---- - -> For some background knowledge on Linux dynticks and NOHZ_FULL, checkout the wonderful [*CPU Isolation*](https://www.suse.com/c/cpu-isolation-introduction-part-1/) series from SUSE Labs. - -The CPU my laptop equipped is a lovely [R7-4800HS](https://www.amd.com/en/products/apu/amd-ryzen-7-4800h) which has a base frequency of 2.9GHz and can boost up to 4GHz, while only consuming few watts when sitting idle, quite a nice workhorse. - -One day I came upon the topic of Linux dynticks and found words on the potential of NOHZ_FULL for saving energy and increasing performance. I decided to yolo a try then *forgot* about it, ...and later found my CPU can't boost past 2.9GHz anymore. - -What? Why?? Is my motherboard busted? Is my beloved NixOS betraying me? Is my custom built Kernel punishing me for not RTFM? Frustratingly the situation was beyond what I can debug. - -Until, for some miracle, I noticed the two cores specified for housekeeping sparkled 3.8GHz while monitoring high system load. - -*Whaaet a coincident*. - -Suspicion raised, is NOHZ_FULL the cause of CPU throttling? Several Web searching later, I found this [LWN thread](https://lwn.net/Articles/816801/) which basically confirmed this theory. After reverting the config, I can do compile at full speed[^1] once again. - -[^1]: Ehh, I mean my laptop, not...me myself. - -Probably, *NOHZ_FULL* is best suited for beefy server boxes whose four 512-core CPUs constantly runs at the maximum frequency with no dynamic scaling at all. But on a PC, this isn't something worth the attention of typical users, my thought. - -
- -By the way, here's a quick note on how to active NOHZ_FULL. - -1. Build kernel with option `CONFIG_NO_HZ_FULL=y` - -2. Use `lstopo` from `hwloc` package to find the topology of the CPU - - - - This is the topology of my 4800HS. Each hyper-thread is counted a *core* from kernel's point of view, and notice labels start from 0 instead of 1. - -3. Set kernel parameter `nohz_full` to include desired CPUs, for example `nohz_full=2-15`. - - Cores *not included in* the list will *housekeeping* interrupts for the others which could potentially stay in deeper C-State longer because of less interrupts, resulting "energy saving". - - One tricky part is that hyper-thread "cores" in the same physical core need to be specified altogether, otherwise it will defeat the purpose of dynticks. - diff --git a/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/topo.svg b/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/topo.svg deleted file mode 100755 index c5a8a7a..0000000 --- a/src/posts/2023/09/a-tale-of-nohz-full-and-throttled-cpu/topo.svg +++ /dev/null @@ -1,182 +0,0 @@ - - - - Machine (15GB total) - - Package L#0 - - L3 (4096KB) - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#0 - - PU L#0 - P#0 - - PU L#1 - P#1 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#1 - - PU L#2 - P#2 - - PU L#3 - P#3 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#2 - - PU L#4 - P#4 - - PU L#5 - P#5 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#3 - - PU L#6 - P#6 - - PU L#7 - P#7 - - L3 (4096KB) - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#4 - - PU L#8 - P#8 - - PU L#9 - P#9 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#5 - - PU L#10 - P#10 - - PU L#11 - P#11 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#6 - - PU L#12 - P#12 - - PU L#13 - P#13 - - L2 (512KB) - - L1d (32KB) - - L1i (32KB) - - Core L#7 - - PU L#14 - P#14 - - PU L#15 - P#15 - - NUMANode L#0 P#0 (15GB) - - - - 2.0 - - 0.6 - - 3.9 - - 32 - - 32 - - - - - 2.0 - - - PCI 01:00.0 - - - - 0.6 - - - PCI 02:00.0 - - Net wlp2s0 - - - - 3.9 - - - PCI 03:00.0 - - Block nvme0n1 - 476 GB - - - - 32 - - - PCI 04:00.0 - - - - 32 - - - - 2 x { PCI 05:00.0-1 } - - Host: lyfua - Date: Sun 25 Jun 2023 07:21:24 PM CST -