What is max_cstate? And why is the default set to 9?
Welcome, Guest.
"When tyranny becomes law, rebellion becomes duty." -Thomas Jefferson

Author Topic: What is max_cstate? And why is the default set to 9?  (Read 628 times)

Offline gregorylock

  • Contributor
  • *******
  • Posts: 1178
What is max_cstate? And why is the default set to 9?
« on: January 03, 2021, 08:28:33 PM »
Recently I was messing around with PCLinuxOS.  The operating system seems to feel heavy.  But not just PCLinuxOS, I've noticed in some of my other installs that the web browsers and some of other applications seem heavier.  My plan is to lighten PClinuxOS by switching to icewm.  Another user got another idea.  He suggested I do this.

cat /sys/devices/system/cpu/cpuidle/current_driver

cat /sys/module/intel_idle/parameters/max_cstate

I did that of course and here was my results.

Code: [Select]
cat /sys/devices/system/cpu/cpuidle/current_driver
none

Code: [Select]
cat /sys/module/intel_idle/parameters/max_cstate
9

After that He wanted me to:

Code: [Select]
add -

GRUB_CMDLINE_LINUX_DEFAULT="splash quiet noiswmd intel_idle.max_cstate=1"

to the file /etc/default/grub and save, run update-grub, and reboot.

I don't know why but it didn't boot up correctly.  I forced it to shutdown and then it booted up correctly.

After that the system moved the line GRUB_CMDLINE_LINUX_DEFAULT="splash quiet noiswmd intel_idle.max_cstate=1" to the top of grub.

Code: [Select]
ls -1
bluetooth
grub*
grub.old*
sndiod
timeshift.json
useradd

Code: [Select]
cat grub.old
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet noiswmd nokmsboot resume=UUID=77894d14-fc4b-4535-b2f4-ad8e84d43f4b audit=0 vga=788"
GRUB_DEFAULT=saved
GRUB_DISABLE_OS_PROBER=false
GRUB_DISABLE_RECOVERY=false
GRUB_DISABLE_SUBMENU=y
GRUB_DISTRIBUTOR=PCLinuxOS
GRUB_GFXMODE=1024x768x32
GRUB_GFXPAYLOAD_LINUX=auto
GRUB_SAVEDEFAULT=true
GRUB_TERMINAL_OUTPUT=gfxterm
GRUB_THEME=/boot/grub2/themes/pclinuxos/theme.txt
GRUB_TIMEOUT=10
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet noiswmd intel_idle.max_cstate=1"

Code: [Select]
cat grub
GRUB_CMDLINE_LINUX_DEFAULT="splash quiet noiswmd nokmsboot intel_idle.max_cstate=1"
GRUB_DEFAULT=saved
GRUB_DISABLE_OS_PROBER=false
GRUB_DISABLE_RECOVERY=false
GRUB_DISABLE_SUBMENU=y
GRUB_DISTRIBUTOR=PCLinuxOS
GRUB_GFXMODE=1024x768x32
GRUB_GFXPAYLOAD_LINUX=auto
GRUB_SAVEDEFAULT=true
GRUB_TERMINAL_OUTPUT=gfxterm
GRUB_THEME=/boot/grub2/themes/pclinuxos/theme.txt
GRUB_TIMEOUT=10

Now when I run

cat /sys/devices/system/cpu/cpuidle/current_driver

cat /sys/module/intel_idle/parameters/max_cstate

I get these results.

Code: [Select]
cat /sys/devices/system/cpu/cpuidle/current_driver
none

Code: [Select]
cat /sys/module/intel_idle/parameters/max_cstate
1

So far the system SEEMS to be running better.  All of this got me wondering what is my other OSes set too?  I discovered that my Xubuntu 18.04 box is running at 9.  My Linux Mint 20 box is also running at 9.  9 seems to be the standard.  I was trying to search on google to see if I could find some documentation to explain to me me why the number 9 over using the number 1.  Maybe some of you could explain that me.  And how do you know when you need to use 1 instead of the default?
Real Hardware: Linux Mint 20.1 XFCE, PCLinuxOS XFCE
VirtualBox:  ArchLabs

Offline CwF

  • Elite Member
  • *****
  • Posts: 474
Re: What is max_cstate? And why is the default set to 9?
« Reply #1 on: January 09, 2021, 10:13:54 PM »
 You're basically disabling speedstep and forcing the cpu to never change state or idle. May help responsiveness for something underpowered, and is very situation specific. As such, it's not good as a general setting.

 The same thing can be accomplished in the bios, and when it's helpful would be the preferred place for such tweaks. Then you don't rely on software settings. Whether or not a particular bios exposes the settings and where varies, but are usually under some 'custom' profile for power settings. A few c-state settings, maybe power duration limits, clock rates and ratios...depends on generation, model, and board vendor.
Most OS's should be set to allow a driver take over, or with newer cpu's allow it to self manage bin state. There should be a good reason determined before changing this, and those are few.
You'd be better served  to install whatever utility is appropriate for the generation and write to sysfs to control minimal clock while you need it, then return to a default when your done. Assuming a locked out dumbed down bios...Sandy bridge is a dividing line for methods, before and after, and maybe not all newer ones yet?

Offline gregorylock

  • Contributor
  • *******
  • Posts: 1178
Re: What is max_cstate? And why is the default set to 9?
« Reply #2 on: January 10, 2021, 06:12:11 PM »
I don't know very much about BIOSes.  I don't have hours on end to study them.  I have always kept things at the defaults, except for a few things that I needed to change.
Real Hardware: Linux Mint 20.1 XFCE, PCLinuxOS XFCE
VirtualBox:  ArchLabs