Gentoo Archives: gentoo-user

From: Manuel McLure <manuel@××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Would constant max CPU speed cause lockups?
Date: Sun, 06 Jun 2021 18:04:25
Message-Id: CAGJrxsQj+oA_SK4-W8oXOZxv564JGBBZTmNzPYcP0vZxVAFQOQ@mail.gmail.com
In Reply to: [gentoo-user] Would constant max CPU speed cause lockups? by Walter Dnes
1 On Sat, Jun 5, 2021 at 10:18 AM Walter Dnes <waltdnes@××××××××.org> wrote:
2
3 > A few years ago, I cheaped out and bought a low-powered Atom desktop
4 > with 8 gigs of RAM. Looking back, that was a mistake. It would default
5 > to 480p or at best 720p on Youtube. But I wrote a nifty bash script
6 > that manually put the CPU into "userspace" mode, and selected the
7 > maximum available CPU speed. I finally got Youtube with steady playback
8 > at 1080p... YAY! I'd leave it at max speed during my waking hours, and
9 > drop it to min speed at night before going to bed.
10 >
11 > I saw the occasional mysterious lockups as I mentioned in recent
12 > threads. I wonder if pushing the CPU to max speed most of the day would
13 > cause overheating and lockups. I'm leaving my current, more powerfull,
14 > machine in "conservative" mode.
15 >
16 > Should I stay in conservative mode? Or forget about speed control
17 > entirely, and let "Intel Speed Step" handle things for me? Also, is
18 > there a way to enable CPU throttling based on temperature?
19 >
20 >
21 Depending on the specific generation of Atom/Celeron processor, there may
22 be some issues with processor power control (cstates) that can result in a
23 lockup. This is a processor bug that affects "Bay Trail" CPUs, including
24 several Atom processors:
25 https://ark.intel.com/content/www/us/en/ark/products/codename/55844/products-formerly-bay-trail.html
26 . I ran into this on a J1900 Celeron that I use to control my 3D printer.
27
28 There are a couple of workarounds:
29 - Disable all cstates >1 with the kernel command line option
30 "intel_idle.max_cstate=1". This will mean that the processor will not be
31 able to microsleep to save power.
32 - Disable cstate 6 (the one that causes the problem) and enable cstate 7
33 with a shell script like the following:
34
35 #!/bin/sh
36
37 #title: c6off+c7on.sh
38 #description: Disables all C6 and enables all C7 core states for Baytrail
39 CPUs
40 #author: Wolfgang Reimer <linuxball (at) gmail.com>
41 #date: 2016014
42 #version: 1.0
43 #usage: sudo <path>/c6off+c7on.sh
44 #notes: Intended as test script to verify whether erratum VLP52 (see
45 # [1]) is the root cause for kernel bug 109051 (see [2]). In
46 order
47 # for this to work you must _NOT_ use boot parameter
48 # intel_idle.max_cstate=<number>.
49 #
50 # [1]
51 http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/pentium-n3520-j2850-celeron-n2920-n2820-n2815-n2806-j1850-j1750-spec-update.pdf
52 # [2] https://bugzilla.kernel.org/show_bug.cgi?id=109051
53
54 # Disable ($1 == 1) or enable ($1 == 0) core state, if not yet done.
55 disable() {
56 local action
57 read disabled <disable
58 test "$disabled" = $1 && return
59 echo $1 >disable || return
60 action=ENABLED; test "$1" = 0 || action=DISABLED
61 printf "%-8s state %7s for %s.\n" $action "$name" $cpu
62 }
63
64 # Iterate through each core state and for Baytrail (BYT) disable all C6
65 # and enable all C7 states.
66 cd /sys/devices/system/cpu
67 for cpu in cpu[0-9]*; do
68 for dir in $cpu/cpuidle/state*; do
69 cd "$dir"
70 read name <name
71 case $name in
72 C6*) disable 1;;
73 C7*) disable 0;;
74 esac
75 cd ../../..
76 done
77 done
78
79 I have been using the above script successfully for over a year.
80
81 --
82 Manuel A. McLure WW1FA <manuel@××××××.org> <http://www.mclure.org>
83 ...for in Ulthar, according to an ancient and significant law,
84 no man may kill a cat. -- H.P. Lovecraft