Bug 2053957 - Package c-states never go below C2
Summary: Package c-states never go below C2
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 35
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-02-13 15:53 UTC by bthomasz
Modified: 2022-12-13 16:38 UTC (History)
19 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-12-13 16:38:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
dmesg (103.47 KB, text/plain)
2022-02-13 15:53 UTC, bthomasz
no flags Details
turbostat output (36.25 KB, text/plain)
2022-02-13 15:54 UTC, bthomasz
no flags Details
tlp settings/stats (13.53 KB, patch)
2022-02-13 15:55 UTC, bthomasz
no flags Details | Diff

Description bthomasz 2022-02-13 15:53:49 UTC
Created attachment 1860878 [details]
dmesg

1. Please describe the problem:

On a freshly bought Dell Inspiron 16 Plus with 11th gen i7-11800H CPU the package c-states never go below c2(pc2).
Only the package, the cores nicely park in C7 on idle.
Consequently: on closing the lid the system does not go into deep sleep either (eating through 60% battery overnight). 

2. What is the Version-Release number of the kernel:

# uname -rv
5.16.8-200.fc35.x86_64 #1 SMP PREEMPT Tue Feb 8 20:58:59 UTC 2022

3. Did it work previously in Fedora? If so, what kernel version did the issue
   *first* appear?  Old kernels are available for download at
   https://koji.fedoraproject.org/koji/packageinfo?packageID=8 :

Not AFAICT. First install on the new hardware was with 5.15 and currently on latest update 5.16.8-200, same behaviour.

4. Can you reproduce this issue? If so, please provide the steps to reproduce
   the issue below:

Yes, always: install Fedora Workstation and run turbostat while idle.

Note 1.: to my untrained eyes this looks like an intel driver issue, because:
          * on windows it works (this is a dual boot with two ssd-s): in throttlestop i see package go below c2
          * doesn't work with tlp installed & configured to powersave settings
          * doesn't work with Fedora XFCE spin live
          * doesn't work with Ubuntu 20.04 live either
          * by looking at turbostat log (again, I'm not very experienced with this), could it be that c3++ states somehow not recognized?:  

# turbostat 2>&1 | grep PKG
cpu14: MSR_CONFIG_TDP_LEVEL_1: 0x00130118 (PKG_MIN_PWR_LVL1=0 PKG_MAX_PWR_LVL1=0 LVL1_RATIO=19 PKG_TDP_LVL1=280)
cpu14: MSR_PKG_CST_CONFIG_CONTROL: 0x74008008 (UNdemote-C1, demote-C1, locked, pkg-cstate-limit=8 (unlimited))
cpu0: MSR_HWP_REQUEST_PKG: 0x8000ff01 (min 1 max 255 des 0 epp 0x80 window 0x0)
cpu0: MSR_PKG_POWER_INFO: 0x00000168 (45 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
cpu0: MSR_PKG_POWER_LIMIT: 0x42036800dc8640 (UNlocked)
cpu0: PKG Limit #1: ENabled (200.000000 Watts, 28.000000 sec, clamp DISabled)
cpu0: PKG Limit #2: DISabled (109.000000 Watts, 0.002441* sec, clamp DISabled)
cpu14: MSR_PKGC3_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu14: MSR_PKGC6_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu14: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu14: MSR_PKGC8_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu14: MSR_PKGC9_IRTL: 0x00000000 (NOTvalid, 0 ns)
cpu14: MSR_PKGC10_IRTL: 0x00000000 (NOTvalid, 0 ns)

Note 2.: UEFI BIOS, deviations from manufacturer's setup:
          * turning off bluetooth (works with windows, see note 1.)
          * fan setting: from balanced to quiet

5. Does this problem occur with the latest Rawhide kernel? To install the
   Rawhide kernel, run ``sudo dnf install fedora-repos-rawhide`` followed by
   ``sudo dnf update --enablerepo=rawhide kernel``:

Did not try.

6. Are you running any modules that not shipped with directly Fedora's kernel?:

XFCE spin trials were as live usb comes out of the box.
Workstation trials done with tlp and rpmfusion nvidia drivers (dgpu disabled with envycontrol):
https://github.com/geminis3/envycontrol

7. Please attach the kernel logs. You can get the complete kernel log
   for a boot with ``journalctl --no-hostname -k > dmesg.txt``. If the
   issue occurred on a previous boot, use the journalctl ``-b`` flag.

Comment 1 bthomasz 2022-02-13 15:54:36 UTC
Created attachment 1860879 [details]
turbostat output

Comment 2 bthomasz 2022-02-13 15:55:14 UTC
Created attachment 1860880 [details]
tlp settings/stats

Comment 3 bthomasz 2022-02-21 10:55:29 UTC
Ok, I got this working after a bit too much fiddling for my taste.
It's the combination of the Nvidia card (what a surprise ;) ), the original SSD the laptop came with (looks like a Sandisk disguised as Western Digital) and the bluetooth module that don't want to play along with power management.

After trying out many thins, this is what worked:
* ASPM to powersupersave *OR* ASPM to powersave + SSD off in BIOS (using TLP). This is now a two SSD setup with the primary SSD (hosting Fedora) being a Seagate Firecuda: after a week of usage this one seems to be OK with powersupersave, so that's good.
* added kernel param: pcie_aspm=force
* turn off RAID in BIOS (for some reason it's on by default)
* bluetooth off from BIOS (fortunately I can afford this luxury because I am not using it, but this might not be an option for others)
* Nvidia off with envycontrol as already mentioned in the ticket (this is the same story with bluetooth: I am always on AC when turning on dGPU so it's not a compromise for me, but it may be for others)

Now the package goes down to C8, the idle power is around 5-6W, which translates to 14h (this is actually fantastic, way better than the mildly tweaked Win11 the laptop came with).

Boot occasionally freezes after kernel updates, but so far went away with a forced power cycle. Ah yes: and i915.enable_psr=0 otherwise the screen flickers.

Note 1.: in the long term I would like to keep the problematic SSD under low power mode so refresh will still maintain the data on the disk (i.e. to keep the Win11 functioning just in case).

Note 2.: the downside is losing temperature info about the devices turned off (SSD and dGPU in this case), this may or may not throw some surprises in the future (I am thinking of a firmware/BIOS update screwing up turned off state).
This is a worry because if I do: 
echo 1 > /sys/bus/pci/devices/<PROBLEMATIC_SSD_DEVICE_ID>/remove
... wait 15 mins ...
echo 1 > /sys/bus/pci/rescan
tlp-stat -d
Then this disk comes back hot (~55 Celsius). Even under power management it stabilizes around 49 Celsius (idle), while everything else (including the other SSD that Fedora actually runs from) is below 40Celsius.

Reading this: https://docs.kernel.org/power/pci.html I got the naive impression that power management on pci is standardized. I was wondering: would in theory be possible to write a device-agnostic driver that does nothing else but tries to put the device into sleep?

Comment 4 Hans de Goede 2022-02-21 12:31:44 UTC
(In reply to bthomasz from comment #3)
> Ok, I got this working after a bit too much fiddling for my taste.
> It's the combination of the Nvidia card (what a surprise ;) ), the original
> SSD the laptop came with (looks like a Sandisk disguised as Western Digital)
> and the bluetooth module that don't want to play along with power management.
> 
> After trying out many thins, this is what worked:
> * ASPM to powersupersave *OR* ASPM to powersave + SSD off in BIOS (using
> TLP). This is now a two SSD setup with the primary SSD (hosting Fedora)
> being a Seagate Firecuda: after a week of usage this one seems to be OK with
> powersupersave, so that's good.

Is either of the 2 SSDs a SATA SSD? If yes then it would be interesting to do:

cat /sys/class/scsi_host/host?/link_power_management_policy

And see what that says, you can also (as root) echo a different policy to that file and see if that helps combined with the regular ASPM powersave setting ?

> * bluetooth off from BIOS (fortunately I can afford this luxury because I am
> not using it, but this might not be an option for others)

Hmm, this should not be necessary. By default the Fedora kernels will enable autosuspend for USB attached BT HCIs. I assume that the bluetooth does show up in "lsusb" when enabled ?

Comment 5 bthomasz 2022-02-22 12:52:29 UTC
(In reply to Hans de Goede from comment #4)
> (In reply to bthomasz from comment #3)
> > Ok, I got this working after a bit too much fiddling for my taste.
> > It's the combination of the Nvidia card (what a surprise ;) ), the original
> > SSD the laptop came with (looks like a Sandisk disguised as Western Digital)
> > and the bluetooth module that don't want to play along with power management.
> > 
> > After trying out many thins, this is what worked:
> > * ASPM to powersupersave *OR* ASPM to powersave + SSD off in BIOS (using
> > TLP). This is now a two SSD setup with the primary SSD (hosting Fedora)
> > being a Seagate Firecuda: after a week of usage this one seems to be OK with
> > powersupersave, so that's good.
> 
> Is either of the 2 SSDs a SATA SSD? If yes then it would be interesting to
> do:
> 
> cat /sys/class/scsi_host/host?/link_power_management_policy
> 
> And see what that says, you can also (as root) echo a different policy to
> that file and see if that helps combined with the regular ASPM powersave
> setting ?

Can't check that, both SSD-s are on PCIe/NVME so this doesn't apply to my case.

> 
> > * bluetooth off from BIOS (fortunately I can afford this luxury because I am
> > not using it, but this might not be an option for others)
> 
> Hmm, this should not be necessary. By default the Fedora kernels will enable
> autosuspend for USB attached BT HCIs. I assume that the bluetooth does show
> up in "lsusb" when enabled ?

Yes it shows up, did some research on the power consumption (single terminal open with powertop, watching it for a minute after at least 5 min idle):

Bluetooth off from BIOS: ~4.9-5.1W
Bluetooth off from XFCE BT manager: ~5.2-5.6W
Bluetooth on: ~6.8-7.5W (IRQ/s goes up from ~250 to ~370, ?discoverability?)

Thanks for the tip, it's not bad indeed. I remembered more but this was the first thing I disabled when I got the laptop weeks ago.

(TBH I really don't use bluetooth so I'm still trading that extra 0.3-0.5W for 20% more screen brightness.)

Comment 6 Hans de Goede 2022-02-22 13:45:31 UTC
(In reply to bthomasz from comment #5)
> Can't check that, both SSD-s are on PCIe/NVME so this doesn't apply to my
> case.

Ok.

> > Hmm, this should not be necessary. By default the Fedora kernels will enable
> > autosuspend for USB attached BT HCIs. I assume that the bluetooth does show
> > up in "lsusb" when enabled ?
> 
> Yes it shows up, did some research on the power consumption (single terminal
> open with powertop, watching it for a minute after at least 5 min idle):
> 
> Bluetooth off from BIOS: ~4.9-5.1W
> Bluetooth off from XFCE BT manager: ~5.2-5.6W

That is worse then I would expect. Does this impact the PC-states in a negative manner, or do you still see mostly PC10 when the system is fully idle?

Can you do lsusb -t and then find the BT device? For me this looks like this:

/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/10p, 480M
    |__ Port 9: Dev 11, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 9: Dev 11, If 1, Class=Wireless, Driver=btusb, 12M


(with other devices omitted) then you can build a USB sysfs device path from that info which in this
case is just 1-9 since there are no hubs in between and then do:

cat /sys/bus/usb/devices/1-9/control
cat /sys/bus/usb/devices/1-9/power/runtime_status

This should output "auto" resp. "suspended" and if it does then the power-consumption impact really should not be this big.

> Bluetooth on: ~6.8-7.5W (IRQ/s goes up from ~250 to ~370, ?discoverability?)

Ugh, that is worse. Is that with the bluetooth control panel open? If yes what happens if you close the panel and then wait 10 seconds ?  Also again I wonder what PC-states you reach in this scenario ?

> (TBH I really don't use bluetooth so I'm still trading that extra 0.3-0.5W
> for 20% more screen brightness.)

I understand, but the impact when not in use really should be negligible, so something is not working as it should.

Comment 7 bthomasz 2022-02-22 20:39:35 UTC
Just to avoid confusion, the wattages are the total system consumptions reported by the battery.

# lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/8p, 20000M/x2
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
    |__ Port 5: Dev 2, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 5: Dev 2, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 9: Dev 3, If 0, Class=Vendor Specific Class, Driver=, 12M
    |__ Port 14: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 14: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/1p, 480M

# cat /sys/bus/usb/devices/3-14/power/control
auto
# cat /sys/bus/usb/devices/3-14/power/runtime_status
suspended

Yeah you're right, those in my previous reply were with the bluetooth control panel open and it shows on the consumption, sorry about that. 
With powertop --time=5 it actually shows the power consumption peaks at every 3rd-4th measurements.

Here are the udated values with control panel closed (2 min averages):
off from BIOS: 5.05W
off via control panel: 5.24W
on: 5.52W
systemctl disable bluetooth.service & reboot: 5.10W

Note 1.: once bluetooth.service is started, systemctl stop has no effect
Note 2.: if I turn off bluetooth through the control panel, it turns back on during reboot

Regarding the C-states (this is a Tiger Lake): I did not see noticable differences, typically this happens on idle:
package is 70% in C8 (pc8) and the rest is flipping between C2 & C3 
cores are 97-98% in C7 (cc7) 
threads are 99% in C3_ACPI

Comment 8 Hans de Goede 2022-03-09 16:30:48 UTC
Note this is a generic comment added to several bugs at once:

There have been quite a few different bug reports now about suspend/resume issues with kernel versions >= 5.16.10, there are some reports that this is caused by the patch titled "ACPI: PM: s2idle: Cancel wakeup before dispatching EC GPE".

So to help debugging this further I've done 2 Fedora test kernel builds with that patch reverted:

5.16.13: https://koji.fedoraproject.org/koji/taskinfo?taskID=83901424
5.17-rc7: https://koji.fedoraproject.org/koji/taskinfo?taskID=83901915

Note these are still building atm, this should be finished in a couple of hours. See here for some generic instructions for installing a kernel directly from koji (the Fedora build-system): https://fedorapeople.org/~jwrdegoede/kernel-test-instructions.txt

If you are seeing suspend/resume issues with the recent Fedora kernels, please give both these builds a try and report back how they work for you.

Comment 9 Ben Cotton 2022-11-29 17:52:58 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 10 Ben Cotton 2022-12-13 16:38:50 UTC
Fedora Linux 35 entered end-of-life (EOL) status on 2022-12-13.

Fedora Linux 35 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.