snapd
snapd copied to clipboard
i/builtin/power-control: add paths for battery charging thresholds to power-control interface
auto-cpufreq project has had snap package for few years now, and with release of 2.2.0 which adds functionality to set battery charging thresholds, its snap package is in broken state since.
Reason for this is because hardware-observe interface doesn't have ability to write to /sys/class/power_supply/. This was discussion and this PR was suggested as part of Snapcraft forum: Request for kernel-module-control interface for auto-cpufreq by @alexmurray
Currently only 2 locations auto-cpufreq will need to write to are:
/sys/class/power_supply/BAT*/charge_start_threshold
/sys/class/power_supply/BAT*/charge_stop_threshold
but this list might extended in future.
Since this is my first contribution to snapd, I hope I've made the right changes, as this is how I interpreted where & how changes should be made. If not please let me know what I need to fix/improve.
Thanks!
Adnan
Everyone contributing to this PR have now signed the CLA. Thanks!
PR failed on CLA check, because I didn’t fill out the Contributor agreement form. Which I did do afterwards as individual contributor and since I didn’t know what to fill out in “Please add the Canonical Project Manager or contact” field I put your name here @alexmurray.
I see @kenvandine volunteered himself for this field in another (same) issue someone encountered, and could be someone I could refer to but I went with Alex :)
If I did this step right, is there to re-run this step or I need to re-create this PR?
@AdnanHodzic Thanks for this but it is the wrong interface -
hardware-observeshould not be granting write permission - instead can this please be added to thepower-controlinterface as I suggested previously? https://forum.snapcraft.io/t/request-for-kernel-module-control-interface-for-auto-cpufreq/38953/12 Thanks.
@alexmurray I apologize for misunderstanding, changes amended and pushed.
P.S: unfortunately, CLA check step is still failing.
I re-ran the CLA check but it failed again. I don't quite know how that works (how soon is the check able to see the data). Let's wait 24 hours, rebase on master and push - we've landed a bunch of fixes ahead of release so this will both give us another chance to see the data and give us a view of any impact / failures.
I re-ran the CLA check but it failed again. I don't quite know how that works (how soon is the check able to see the data). Let's wait 24 hours, rebase on master and push - we've landed a bunch of fixes ahead of release so this will both give us another chance to see the data and give us a view of any impact / failures.
@zyga today around 12CET I got an email that I got added to "contributor-agreement-canonical" and it gets past CLA check now.
Only thing that remains is a change @alexmurray requested, which I did.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 78.90%. Comparing base (
a5a6458) to head (8c76fc5). Report is 7 commits behind head on master.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## master #13722 +/- ##
==========================================
- Coverage 78.90% 78.90% -0.01%
==========================================
Files 1043 1043
Lines 134337 134345 +8
==========================================
+ Hits 106004 106010 +6
Misses 21721 21721
- Partials 6612 6614 +2
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 78.90% <ø> (-0.01%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The details above still don't necessarily convince me that this is working as expected - I think we really need to see the following:
- install the snap without any changes to the apparmor profile, run https://snapcraft.io/snappy-debug then run auto-cpufreq and capture the DENIALS which get logged.
- check that the DENIALS mention paths like
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1b/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/charge_stop_threshold - edit the apparmor profile to add the proposed rules:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
- reload the apparmor profile
- rerun auto-cpufreq and capture DENIALS via snappy-debug again and check that there is now no mention of any denial for the affected file
The details above still don't necessarily convince me that this is working as expected - I think we really need to see the following:
- install the snap without any changes to the apparmor profile, run https://snapcraft.io/snappy-debug then run auto-cpufreq and capture the DENIALS which get logged.
- check that the DENIALS mention paths like
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1b/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/charge_stop_threshold- edit the apparmor profile to add the proposed rules:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw, /sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
- reload the apparmor profile
- rerun auto-cpufreq and capture DENIALS via snappy-debug again and check that there is now no mention of any denial for the affected file
Agreed, something is still not right.
I'm at KubeCon ATM and don't have access to my private laptop, hence it'll take me some time to check this myself.
In meantime I'll ask one of the project contributors if they can check this. Just as heads up if any other names then mine start making comments to the PR.
@alexmurray I finally got to what was requested of me:
The details above still don't necessarily convince me that this is working as expected - I think we really need to see the following:
- install the snap without any changes to the apparmor profile, run https://snapcraft.io/snappy-debug then run auto-cpufreq and capture the DENIALS which get logged.
- check that the DENIALS mention paths like
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1b/PNP0C09:00/PNP0C0A:00/power_supply/BAT0/charge_stop_threshold
Example denial looks like:
= AppArmor =
Time: 2024-03-29T07:4
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type" pid=544772 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
File: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type (read)
Suggestions:
* adjust program to not access '/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type'
* adjust program to not access '/sys/devices/LNXSYSTM:[0-9]*/LNXSYBUS:[0-9]*/PNP[0-9]*A[0-9]*:[0-9]*/device:[0-9]*/PNP[0-9]*C[0-9]*:[0-9]*/ACPI[0-9]*:[0-9]*/power_supply/AC/type'
You can see the contents of whole file here.
- edit the apparmor profile to add the proposed rules:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw, /sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
- reload the apparmor profile
- rerun auto-cpufreq and capture DENIALS via snappy-debug again and check that there is now no mention of any denial for the affected file
Example denial looks like:
= AppArmor =
Time: 2024-03-29T07:5
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type" pid=550652 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
File: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type (read)
Suggestions:
* adjust program to not access '/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type'
* adjust program to not access '/sys/devices/LNXSYSTM:[0-9]*/LNXSYBUS:[0-9]*/PNP[0-9]*A[0-9]*:[0-9]*/device:[0-9]*/PNP[0-9]*C[0-9]*:[0-9]*/ACPI[0-9]*:[0-9]*/power_supply/AC/type'
Which looks the same to me as before apparmor profile changes? Hence I'm either doing something wrong or changes aren't applied accordingly.
You can see the contents of whole file here.
Hope this helps ...
Hi @AdnanHodzic
This line
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type" pid=544772 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
indicates that your application also need (at least read) access to
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type
which is not granted by the proposed apparmor rules
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
Could you give it a try also including (in addition to previous ones) following apparmor rule to see if anything changes?
/sys/devices/**/power_supply/AC/type r,
Thanks!
Hi @AdnanHodzic
This line
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/type" pid=544772 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=0indicates that your application also need (at least read) access to
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC/typewhich is not granted by the proposed apparmor rules
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw, /sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,Could you give it a try also including (in addition to previous ones) following apparmor rule to see if anything changes?
/sys/devices/**/power_supply/AC/type r,Thanks!
Hi @jslarraz!
I apologize for such delayed reply, I was travelling for work last few weeks and didn't have access to my private laptop.
Regardless, I did what you suggested here, I've appended /sys/devices/**/power_supply/AC/type r, line, but then I was facing following issue:
sudo auto-cpufreq --live
Using settings defined in /etc/auto-cpufreq.conf file
Note: You can quit live mode by pressing "ctrl+c"
----------------------------------- Warning -----------------------------------
Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer
Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled.
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable
Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
----------------------------------- Warning -----------------------------------
Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
-------------------------------------------------------------------------------
PermissionError(13, 'Permission denied')
Linux distro: UNKNOWN distro UNKNOWN version
Linux kernel: 6.8.0-31-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate
------------------------------ Current CPU stats ------------------------------
CPU max frequency: 4600 MHz
CPU min frequency: 400 MHz
Core Usage Temperature Frequency
CPU0 8.1% nan °C 2800 MHz
CPU1 21.2% nan °C 2800 MHz
CPU2 31.0% nan °C 2800 MHz
CPU3 20.2% nan °C 2801 MHz
CPU4 9.1% nan °C 400 MHz
CPU5 28.7% nan °C 2800 MHz
CPU6 13.0% nan °C 2800 MHz
CPU7 6.1% nan °C 2799 MHz
---------------------------- CPU frequency scaling ----------------------------
Traceback (most recent call last):
File "/snap/auto-cpufreq/x1/bin/auto-cpufreq", line 8, in <module>
sys.exit(main())
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/bin/auto_cpufreq.py", line 139, in main
set_autofreq()
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/core.py", line 1153, in set_autofreq
elif charging():
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/core.py", line 343, in charging
with open(Path(power_supply_path + supply + "/online")) as f:
PermissionError: [Errno 13] Permission denied: '/sys/class/power_supply/AC/online'
Which I fixed by appending /sys/devices/**/power_supply/AC/online r, line, so this was a full block of changes:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,·
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,·
/sys/devices/**/power_supply/AC/type r,
/sys/devices/**/power_supply/AC/online r,
that I made to:
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq-gtk
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.hook.configure
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.service
/var/lib/snapd/apparmor/profiles/snap-update-ns.auto-cpufreq
However, while now the app doesn't crash, I'm still facing permission issues, i.e:
sudo auto-cpufreq --live
Using settings defined in /etc/auto-cpufreq.conf file
Note: You can quit live mode by pressing "ctrl+c"
----------------------------------- Warning -----------------------------------
Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer
Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled.
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable
Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
----------------------------------- Warning -----------------------------------
Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
-------------------------------------------------------------------------------
PermissionError(13, 'Permission denied')
Linux distro: UNKNOWN distro UNKNOWN version
Linux kernel: 6.8.0-31-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate
------------------------------ Current CPU stats ------------------------------
CPU max frequency: 4600 MHz
CPU min frequency: 400 MHz
Core Usage Temperature Frequency
CPU0 12.1% nan °C 3100 MHz
CPU1 7.0% nan °C 3100 MHz
CPU2 22.8% nan °C 400 MHz
CPU3 8.1% nan °C 3104 MHz
CPU4 14.0% nan °C 400 MHz
CPU5 34.7% nan °C 3100 MHz
CPU6 4.0% nan °C 3100 MHz
CPU7 5.1% nan °C 3100 MHz
---------------------------- CPU frequency scaling ----------------------------
Battery is: charging
Setting to use: "performance" governor
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference: Permission denied
Setting to use: "balance_performance" EPP
Total CPU usage: 25.8 %
Total system load: 1.76
Average temp. of all cores: nan °C
High CPU load (load average: 1.76, 1.99, 2.09)
setting turbo boost: on
Warning: Changing CPU turbo is not supported. Skipping.
-------------------------------------------------------------------------------
"auto-cpufreq" is about to refresh ..
and "Temperatures" are being reported as nan °C. I tried appending /sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor rw, but that didn't result in getting rid of i.e:
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: Permission denied
Hence looking forward to hear if you have any other suggestions how to resolve this issue.
Could you please share DENIALS captured via snappy-debug when you running auto-cpufreq with the new set of app armor rules?
Could you please share DENIALS captured via snappy-debug when you running auto-cpufreq with the new set of app armor rules?
Most of the denials revolved around:
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/proc/389103/cmdline" pid=389560 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=1000
File: /proc/389103/cmdline (read)
Suggestion:
* adjust program to not access '@{PROC}/@{pid}/cmdline'
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/proc/389151/cmdline" pid=389560 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=1000
File: /proc/389151/cmdline (read)
Suggestion:
* adjust program to not access '@{PROC}/@{pid}/cmdline'
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=389560 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/proc/389234/cmdline" pid=389560 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=1000
File: /proc/389234/cmdline (read)
Suggestion:
* adjust program to not access '@{PROC}/@{pid}/cmdline'
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=389560 comm="python3" requested_mask="read" denied_mask="read" peer="snap.snappy-debug.snappy-debug"
Ptrace: peer=snap.snappy-debug.snappy-debug (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-01T10:0
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=389560 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
Which is weird since system-observe is already part of snapcraft.yaml.
So, I think that operation="ptrace" class="ptrace" are safe to ignore. However, cmdline related ones looks more interesting
Log: apparmor="DENIED" operation="open" class="file" profile="snap.auto-cpufreq.auto-cpufreq" name="/proc/389234/cmdline" pid=389560 comm="python3" requested_mask="r" denied_mask="r" fsuid=0 ouid=1000
File: /proc/389234/cmdline (read)
Those are certainly unexpected as it should be allowed by the template.
Could you please confirm that this rule effectively ended up in your application profile?
cat /var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq | grep cmdline
Output should contain owner @{PROC}/@{pid}/cmdline r,
The only thing that comes to my mind already is that the denial may be related to running the application as sudo. Could you please add the following rule (note it does not contain the owner prefix) to your application profile, reload it and rerun the application?
@{PROC}/@{pid}/cmdline r,
Thanks
Could you please confirm that this rule effectively ended up in your application profile?
cat /var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq | grep cmdlineOutput should contain
owner @{PROC}/@{pid}/cmdline r,
cat /var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq | grep cmdline
# LP: #1546825 for details). comm is a subset of cmdline, so allow it too.
owner @{PROC}/@{pid}/cmdline r,
@{PROC}/cmdline r,
The only thing that comes to my mind already is that the denial may be related to running the application as sudo. Could you please add the following rule (note it does not contain the
ownerprefix) to your application profile, reload it and rerun the application?
@{PROC}/@{pid}/cmdline r,
I've added following block:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
/sys/devices/**/power_supply/AC/type r,
/sys/devices/**/power_supply/AC/online r,
@{PROC}/@{pid}/cmdline r,
to following files:
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq-gtk
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.hook.configure
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.service
/var/lib/snapd/apparmor/profiles/snap-update-ns.auto-cpufreq
Reloaded each file with sudo apparmor_parser -r and output I still get is the same:
sudo auto-cpufreq --live
Using settings defined in /etc/auto-cpufreq.conf file
Note: You can quit live mode by pressing "ctrl+c"
----------------------------------- Warning -----------------------------------
Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer
Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled.
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable
Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
----------------------------------- Warning -----------------------------------
Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
-------------------------------------------------------------------------------
PermissionError(13, 'Permission denied')
Linux distro: UNKNOWN distro UNKNOWN version
Linux kernel: 6.8.0-31-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate
------------------------------ Current CPU stats ------------------------------
CPU max frequency: 800 MHz
CPU min frequency: 400 MHz
Core Usage Temperature Frequency
CPU0 8.0% nan °C 800 MHz
CPU1 6.1% nan °C 800 MHz
CPU2 10.1% nan °C 800 MHz
CPU3 3.1% nan °C 800 MHz
CPU4 7.1% nan °C 800 MHz
CPU5 5.1% nan °C 800 MHz
CPU6 29.7% nan °C 800 MHz
CPU7 2.0% nan °C 800 MHz
---------------------------- CPU frequency scaling ----------------------------
Traceback (most recent call last):
File "/snap/auto-cpufreq/x1/bin/auto-cpufreq", line 8, in <module>
sys.exit(main())
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/bin/auto_cpufreq.py", line 140, in main
set_autofreq()
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/core.py", line 1144, in set_autofreq
elif charging():
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/core.py", line 329, in charging
with open(Path(power_supply_path + supply + "/type")) as f:
PermissionError: [Errno 13] Permission denied: '/sys/class/power_supply/BAT0/type'
So it seems we are still missing at least the following rule
/sys/devices/**/power_supply/BAT[0-9]*/type r,
So it seems we are still missing at least the following rule
/sys/devices/**/power_supply/BAT[0-9]*/type r,
besides this one I also needed to add /sys/devices/**/power_supply/BAT[0-9]*/status r, otherwise it would fail with
File "/snap/auto-cpufreq/x1/lib/python3.10/site-packages/auto_cpufreq/core.py", line 345, in charging
with open(Path(power_supply_path + supply + "/status")) as f:
PermissionError: [Errno 13] Permission denied: '/sys/class/power_supply/BAT0/status'
Final list of all rules added is now:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/type r,
/sys/devices/**/power_supply/BAT[0-9]*/status r,
/sys/devices/**/power_supply/AC/type r,
/sys/devices/**/power_supply/AC/online r,
@{PROC}/@{pid}/cmdline r,
and with it I'll still end up getting a lot of "Permission denied"
sudo auto-cpufreq --live
Note: You can quit live mode by pressing "ctrl+c"
----------------------------------- Warning -----------------------------------
Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer
Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled.
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable
Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
----------------------------------- Warning -----------------------------------
Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
-------------------------------------------------------------------------------
PermissionError(13, 'Permission denied')
Linux distro: UNKNOWN distro UNKNOWN version
Linux kernel: 6.8.0-31-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate
------------------------------ Current CPU stats ------------------------------
CPU max frequency: 800 MHz
CPU min frequency: 400 MHz
Core Usage Temperature Frequency
CPU0 26.3% nan °C 800 MHz
CPU1 6.1% nan °C 800 MHz
CPU2 2.0% nan °C 800 MHz
CPU3 1.0% nan °C 800 MHz
CPU4 4.0% nan °C 800 MHz
CPU5 8.1% nan °C 800 MHz
CPU6 3.0% nan °C 800 MHz
CPU7 3.0% nan °C 800 MHz
---------------------------- CPU frequency scaling ----------------------------
Battery is: discharging
Setting to use: "powersave" governor
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu4/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu5/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu6/cpufreq/energy_performance_preference: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu7/cpufreq/energy_performance_preference: Permission denied
Setting to use: "balance_power" EPP
Setting maximum CPU frequency to 4600 Mhz
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq: Permission denied
/snap/auto-cpufreq/x1/usr/bin/cpufreqctl.auto-cpufreq: line 105: /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq: Permission denied
Total CPU usage: 19.9 %
Total system load: 2.28
Average temp. of all cores: nan °C
High CPU load (load average: 2.28, 1.69, 1.44)
setting turbo boost: off
Warning: Changing CPU turbo is not supported. Skipping.
-------------------------------------------------------------------------------
"auto-cpufreq" is about to refresh ..
List of of few snappy denials:
kernel.printk_ratelimit = 0
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.canonical-livepatch.canonical-livepatchd"
Ptrace: peer=snap.canonical-livepatch.canonical-livepatchd (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.multipass.multipassd"
Ptrace: peer=snap.multipass.multipassd (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="capable" class="cap" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" capability=19 capname="sys_ptrace"
Capability: sys_ptrace
Suggestions:
* adjust program to not require 'CAP_SYS_PTRACE' (see 'man 7 capabilities')
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="multipass.snapcraft-auto-cpufreq.qemu-system-x86_64"
Ptrace: peer=multipass.snapcraft-auto-cpufreq.qemu-system-x86_64 (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="/usr/sbin/cupsd"
Ptrace: peer=/usr/sbin/cupsd (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.cups.cupsd"
Ptrace: peer=snap.cups.cupsd (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.cups.cups-browsed"
Ptrace: peer=snap.cups.cups-browsed (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.cups.cupsd"
Ptrace: peer=snap.cups.cupsd (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="snap.cups.cups-browsed"
Ptrace: peer=snap.cups.cups-browsed (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
= AppArmor =
Time: 2024-05-03T09:5
Log: apparmor="DENIED" operation="ptrace" class="ptrace" profile="snap.auto-cpufreq.auto-cpufreq" pid=416906 comm="python3" requested_mask="read" denied_mask="read" peer="unconfined"
Ptrace: peer=unconfined (read)
Suggestions:
* add 'system-observe' to 'plugs'
* do nothing if program otherwise works properly
Is your snap plugging cpu-control interface? If not, could you please add that plug and give it another try?
Note that connecting a new interface will make snapd to recreate the apparmor profile, so you will need to add the rules in discussion afterward again
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/type r,
/sys/devices/**/power_supply/BAT[0-9]*/status r,
/sys/devices/**/power_supply/AC/type r,
/sys/devices/**/power_supply/AC/online r,
@{PROC}/@{pid}/cmdline r,
Is your snap plugging
cpu-controlinterface? If not, could you please add that plug and give it another try?
Yes it is, current snapcraft.yaml looks like:
name: auto-cpufreq
base: core22
summary: Automatic CPU speed & power optimizer for Linux
description: |
Automatic CPU speed & power optimizer for Linux based on active
monitoring of laptop's battery state, CPU usage and system load.
Ultimately allowing you to improve battery life without making
any compromises.
license: LGPL-3.0
grade: stable
confinement: strict
adopt-info: auto-cpufreq
compression: lzo
architectures:
- build-on: [amd64]
build-for: [amd64]
- build-on: [amd64]
build-for: [arm64]
parts:
auto-cpufreq:
plugin: python
python-packages:
- setuptools
- wheel
- requests
build-packages:
- gcc
- python3-dev
stage-packages:
- coreutils
- dmidecode
- pkexec
source: .
override-pull: |
snapcraftctl pull
snapcraftctl set-version `grep ^version $SNAPCRAFT_PART_SRC/pyproject.toml | sed 's/.*"\(.*\)"/\1/'`
deploy-scripts:
plugin: dump
source: scripts
organize:
cpufreqctl.sh: usr/bin/cpufreqctl.auto-cpufreq
snapdaemon.sh: usr/bin/snapdaemon
copy-image:
plugin: dump
source: images
plugs:
etc-auto-cpufreq-conf:
interface: system-files
write:
- /etc/auto-cpufreq.conf
apps:
auto-cpufreq:
command: bin/auto-cpufreq
environment:
PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
plugs:
- cpu-control
- system-observe
- hardware-observe
- etc-auto-cpufreq-conf
auto-cpufreq-gtk:
command: bin/auto-cpufreq-gtk
extensions: [gnome]
environment:
PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
plugs:
- cpu-control
- system-observe
- hardware-observe
- desktop
- desktop-legacy
- wayland
- x11
service:
command: usr/bin/snapdaemon
plugs:
- cpu-control
- system-observe
- hardware-observe
environment:
LC_ALL: C.UTF-8
LANG: C.UTF-8
PKG_MARKER: SNAP
daemon: simple
Could you also please confirm that the interface is effectively connect by issuing snap connections auto-cpufreq?
I'm asking because cpu-control seems to include rules for the permissions denied you are observing (/sys/devices/system/cpu/cpufreq/policy*/scaling_governor,energy_performance_preference,scaling_max_freq )
Could you also please confirm that the interface is effectively connect by issuing
snap connections auto-cpufreq?I'm asking because
cpu-controlseems to include rules for the permissions denied you are observing (/sys/devices/system/cpu/cpufreq/policy*/scaling_governor,energy_performance_preference,scaling_max_freq)
Yes cpu-control plug is connected:
snap connections auto-cpufreq
Interface Plug Slot Notes
content[gnome-42-2204] auto-cpufreq:gnome-42-2204 gnome-42-2204:gnome-42-2204 -
content[gtk-3-themes] auto-cpufreq:gtk-3-themes gtk-common-themes:gtk-3-themes -
content[icon-themes] auto-cpufreq:icon-themes gtk-common-themes:icon-themes -
content[sound-themes] auto-cpufreq:sound-themes gtk-common-themes:sound-themes -
cpu-control auto-cpufreq:cpu-control - -
desktop auto-cpufreq:desktop :desktop -
desktop-legacy auto-cpufreq:desktop-legacy :desktop-legacy -
gsettings auto-cpufreq:gsettings :gsettings -
hardware-observe auto-cpufreq:hardware-observe - -
opengl auto-cpufreq:opengl :opengl -
system-files auto-cpufreq:etc-auto-cpufreq-conf - -
system-observe auto-cpufreq:system-observe - -
wayland auto-cpufreq:wayland :wayland -
x11 auto-cpufreq:x11 :x11 -
@AdnanHodzic actually that output shows the interface is not connected - if it was it would look like
cpu-control auto-cpufreq:cpu-control :cpu-control manual
Can you please try running:
sudo snap connect auto-cpufreq:cpu-control
@AdnanHodzic actually that output shows the interface is not connected - if it was it would look like
cpu-control auto-cpufreq:cpu-control :cpu-control manualCan you please try running:
sudo snap connect auto-cpufreq:cpu-control
My bad, I misinterpreted it and I just went through all plugs that were in snapcraft.yaml and connected them manually:
snap connections auto-cpufreq
Interface Plug Slot Notes
content[gnome-42-2204] auto-cpufreq:gnome-42-2204 gnome-42-2204:gnome-42-2204 -
content[gtk-3-themes] auto-cpufreq:gtk-3-themes gtk-common-themes:gtk-3-themes -
content[icon-themes] auto-cpufreq:icon-themes gtk-common-themes:icon-themes -
content[sound-themes] auto-cpufreq:sound-themes gtk-common-themes:sound-themes -
cpu-control auto-cpufreq:cpu-control :cpu-control manual
desktop auto-cpufreq:desktop :desktop -
desktop-legacy auto-cpufreq:desktop-legacy :desktop-legacy -
gsettings auto-cpufreq:gsettings :gsettings -
hardware-observe auto-cpufreq:hardware-observe :hardware-observe manual
opengl auto-cpufreq:opengl :opengl -
system-files auto-cpufreq:etc-auto-cpufreq-conf :system-files manual
system-observe auto-cpufreq:system-observe :system-observe manual
wayland auto-cpufreq:wayland :wayland -
x11 auto-cpufreq:x11 :x11 -
Unfortunately, when I run sudo auto-cpufreq --live I get same errors as I did above ...
Hey @alexmurray @jslarraz, good news!
Today I made an auto-cpufreq v2.3.0 release and along with it pulled latest updates on my system (Ubuntu 24.04) that included some snapd changes. Rebuilt the .snap package, made necessary plug connections that are in my snapcraft.yaml, i.e:
sudo snap connect auto-cpufreq:cpu-control
sudo snap connect auto-cpufreq:system-observe
sudo snap connect auto-cpufreq:hardware-observe
sudo snap connect auto-cpufreq:etc-auto-cpufreq-conf
sudo snap connect auto-cpufreq:desktop
sudo snap connect auto-cpufreq:desktop-legacy
sudo snap connect auto-cpufreq:wayland
sudo snap connect auto-cpufreq:x11
sudo snap connections auto-cpufreq
Interface Plug Slot Notes
content[gnome-42-2204] auto-cpufreq:gnome-42-2204 gnome-42-2204:gnome-42-2204 -
content[gtk-3-themes] auto-cpufreq:gtk-3-themes gtk-common-themes:gtk-3-themes -
content[icon-themes] auto-cpufreq:icon-themes gtk-common-themes:icon-themes -
content[sound-themes] auto-cpufreq:sound-themes gtk-common-themes:sound-themes -
cpu-control auto-cpufreq:cpu-control :cpu-control manual
desktop auto-cpufreq:desktop :desktop -
desktop-legacy auto-cpufreq:desktop-legacy :desktop-legacy -
gsettings auto-cpufreq:gsettings :gsettings -
hardware-observe auto-cpufreq:hardware-observe :hardware-observe manual
opengl auto-cpufreq:opengl :opengl -
system-files auto-cpufreq:etc-auto-cpufreq-conf :system-files manual
system-observe auto-cpufreq:system-observe :system-observe manual
wayland auto-cpufreq:wayland :wayland -
x11 auto-cpufreq:x11 :x11 -
Along with proposed changes:
/sys/devices/**/power_supply/BAT[0-9]*/charge_start_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/charge_stop_threshold rw,
/sys/devices/**/power_supply/BAT[0-9]*/type r,
/sys/devices/**/power_supply/BAT[0-9]*/status r,
/sys/devices/**/power_supply/AC/type r,
/sys/devices/**/power_supply/AC/online r,
@{PROC}/@{pid}/cmdline r,
to all apparmor profile files:
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.auto-cpufreq-gtk
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.hook.configure
/var/lib/snapd/apparmor/profiles/snap.auto-cpufreq.service
/var/lib/snapd/apparmor/profiles/snap-update-ns.auto-cpufreq
and after reloading the changes with apparmor_parser -r on each file, I'm happy to report that everything works as expected!
sudo auto-cpufreq --live
Note: You can quit live mode by pressing "ctrl+c"
----------------------------------- Warning -----------------------------------
Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer
Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled.
Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable
Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq
----------------------------------- Warning -----------------------------------
Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
-------------------------------------------------------------------------------
Linux distro: Ubuntu 24.04 LTS (Noble Numbat)
Linux kernel: 6.8.0-31-generic
Processor: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Cores: 8
Architecture: x86_64
Driver: intel_pstate
------------------------------ Current CPU stats ------------------------------
CPU max frequency: 800 MHz
CPU min frequency: 400 MHz
Core Usage Temperature Frequency
CPU0 41.8% 46 °C 800 MHz
CPU1 21.6% 47 °C 800 MHz
CPU2 24.5% 46 °C 800 MHz
CPU3 34.3% 48 °C 800 MHz
CPU4 13.0% 46 °C 800 MHz
CPU5 20.2% 47 °C 800 MHz
CPU6 9.2% 46 °C 800 MHz
CPU7 11.3% 48 °C 800 MHz
CPU fan speed: 0 RPM
---------------------------- CPU frequency scaling ----------------------------
Battery is: discharging
Setting to use: "powersave" governor
Setting to use: "balance_power" EPP
Setting maximum CPU frequency to 4600 Mhz
Total CPU usage: 22.6 %
Total system load: 2.84
Average temp. of all cores: 46.75 °C
High CPU load (load average: 2.84, 3.24, 3.26)
setting turbo boost: on
-------------------------------------------------------------------------------
"auto-cpufreq" is about to refresh ...
I've pushed the changes to power_control interface, please let me know if any additional changes are needed, otherwise I hope this PR is ready to be merged.
Thanks @AdnanHodzic - LGTM!
@alexmurray I see merge is still blocked, is there anything else I can do to have it merged?
@AdnanHodzic I've just approved the GitHub actions to run, once they are complete then one of the snapd maintainers can choose to merge it (unfortunately I don't have that permission).
@AdnanHodzic I've just approved the GitHub actions to run, once they are complete then one of the snapd maintainers can choose to merge it (unfortunately I don't have that permission).
Thanks for the clarification, now that Github are complete I'll wait for one of snapd maintainers to merge it then.
Just did a last pass on this. The rules added to the power-control interface look consistent with the expected behavior of this interface and appropriate according to the discussion hold here. The resulting changes LGTM