Ananicy-cpp.service isn't starting propperly and needs to be restarted manually for its cgroup settings to work

Hi, everyone

On my system, ananicy-cpp.service isn’t working as intended or more correctly it starts before the cgroups controller is available.

 ╰─λ systemctl status ananicy-cpp.service
● ananicy-cpp.service - Ananicy-Cpp - ANother Auto NICe daemon in C++
     Loaded: loaded (/usr/lib/systemd/system/ananicy-cpp.service; enabled; preset: disabled)
     Active: active (running) since Fri 2025-09-12 12:34:44 +08; 1 day 3h ago
 Invocation: db0ecf18c9204e65884aa5a8939f59cc
   Main PID: 684 (ananicy-cpp)
      Tasks: 4 (limit: 17698)
     Memory: 8.7M (high: 16M, max: 64M, available: 7.2M, peak: 11.9M)
        CPU: 21.634s
     CGroup: /system.slice/ananicy-cpp.service
             └─684 /usr/bin/ananicy-cpp start

Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: Ananicy Cpp
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.397] [info] Starting Ananicy
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [warning] cgroup2 at /sys/fs/cgroup/ananicy_test_cgro>
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [info] Creating Cgroups...
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [warning] Cgroups are not available on this platform >
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [warning] Cgroups are not available on this platform >
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [warning] Cgroups are not available on this platform >
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.400] [info] Finished creating Cgroups...
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.402] [info] Doing a full scan
Sep 12 12:34:44 wisejackal-laptop ananicy-cpp[684]: [2025-09-12 12:34:44.413] [info] Worker initialized with 1383 rules
lines 1-21/21 (END)

After a manual systemctl restart ananicy-cpp.service

╰─λ systemctl status ananicy-cpp.service
lines 1--1...skipping...
● ananicy-cpp.service - Ananicy-Cpp - ANother Auto NICe daemon in C++
     Loaded: loaded (/usr/lib/systemd/system/ananicy-cpp.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-09-13 15:46:26 +08; 26s ago
 Invocation: 46daba68c6bd4af6974489f7bc81c0eb
   Main PID: 141062 (ananicy-cpp)
      Tasks: 4 (limit: 17698)
     Memory: 7.6M (high: 16M, max: 64M, available: 8.3M, peak: 7.8M)
        CPU: 87ms
     CGroup: /system.slice/ananicy-cpp.service
             └─141062 /usr/bin/ananicy-cpp start

Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.317] [info] Config apply_ionice: true
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.317] [info] Config cgroup_load: true
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.317] [info] Config apply_sched: true
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.317] [info] Config apply_nice: true
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: Ananicy Cpp
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.329] [info] Starting Ananicy
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.330] [info] Creating Cgroups...
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.331] [info] Finished creating Cgroups...
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.332] [info] Doing a full scan
Sep 13 15:46:26 wisejackal-laptop ananicy-cpp[141062]: [2025-09-13 15:46:26.342] [info] Worker initialized with 1383 rules
~

Where is the correct place to report this, or what are the further steps from here?

I opened this issue, but that’s kinda the wrong place:

in time started:

ananicy-cpp.service - Ananicy-Cpp - ANother Auto NICe daemon in C++
     Loaded: loaded (/etc/systemd/system/ananicy-cpp.service; enabled; preset: disabled)
     Active: active (running) since Sat 2025-09-13 12:34:55 CEST; 2h 15min ago
 Invocation: ff5f1cb0343b4352b5f3982ae2aca3f4
   Main PID: 410 (ananicy-cpp)
      Tasks: 4 (limit: 18554)
     Memory: 15.1M (high: 16M, max: 64M, available: 896K, peak: 18.5M, swap: 728K, swap peak: 1.3M, zswap: 4.6K)
        CPU: 22.702s
     CGroup: /system.slice/ananicy-cpp.service
             └─410 /usr/bin/ananicy-cpp start

Sep 13 12:35:03 frija ananicy-cpp[410]: [2025-09-13 12:35:03.587] [info] Config apply_ionice: true
Sep 13 12:35:03 frija ananicy-cpp[410]: [2025-09-13 12:35:03.587] [info] Config cgroup_load: true
Sep 13 12:35:03 frija ananicy-cpp[410]: [2025-09-13 12:35:03.587] [info] Config apply_sched: true
Sep 13 12:35:03 frija ananicy-cpp[410]: [2025-09-13 12:35:03.587] [info] Config apply_nice: true
Sep 13 12:35:03 frija ananicy-cpp[410]: Ananicy Cpp
Sep 13 12:35:09 frija ananicy-cpp[410]: [2025-09-13 12:35:09.003] [info] Starting Ananicy
Sep 13 12:35:09 frija ananicy-cpp[410]: [2025-09-13 12:35:09.005] [info] Creating Cgroups...
Sep 13 12:35:09 frija ananicy-cpp[410]: [2025-09-13 12:35:09.005] [info] Finished creating Cgroups...
Sep 13 12:35:09 frija ananicy-cpp[410]: [2025-09-13 12:35:09.006] [info] Doing a full scan
Sep 13 12:35:09 frija ananicy-cpp[410]: [2025-09-13 12:35:09.011] [info] Worker initialized with 1383 rules

…maybe it depends on your system?

Probably, but given that I didn’t do anything to my system that would explain why mine behaves differently …

If you have any troubleshooting ideas tho, I’d love to get it to work as intend.

But nonetheless, it seems like something somewhere should check that cgroups are available before ananicy-ccp tries to start or otherwise catch that it didn’t start properly and try to restart it or something.

you can work around and start ananicy later with a path OR timer

sudo nano /etc/systemd/system/ananicy-cpp.timer

[Unit]Description=starts ananicy-cpp --auto-tune sec 20 after boot
[Timer]OnBootSec=20sec
[Install]WantedBy=timers.target

disable the service and enable the timer if you want a try

btw do you want to use cgroups? if not, you can ignore these errors :slight_smile:

edit

sudo nano /etc/systemd/system/ananicy-cpp.path

[Unit]Description=started ananicy-cppPartOf=ananicy-cpp.service
[Path]PathExists=/sys/fs/cgroup/
[Install]WantedBy=multi-user.target

HI!

Same issue here : using a systemd path as a workaround also fails, and the service is waiting a lot to start :

systemd-analyze blame
8.898s ananicy-cpp.service

Here is the output for the *.path :

systemctl status ananicy-cpp.path
× ananicy-cpp.path - Start ananicy-cpp when cgroups v2 is available
Loaded: loaded (/etc/systemd/system/ananicy-cpp.path; enabled; preset: disabled)
Active: failed (Result: resources) since Mon 2025-09-15 14:26:32 CEST; 49s ago
Duration: 8.926s
Invocation: 46d9bce40b604aa1bea093d5ffa6792d
Triggers: ● ananicy-cpp.service

sept. 15 14:26:23 cachyos-ogu systemd[1]: ananicy-cpp.path: Deactivated suc…lly.
sept. 15 14:26:23 cachyos-ogu systemd[1]: Stopped Start ananicy-cpp when cg…ble.
sept. 15 14:26:23 cachyos-ogu systemd[1]: Stopping Start ananicy-cpp when c…e…
sept. 15 14:26:23 cachyos-ogu systemd[1]: Started Start ananicy-cpp when cg…ble.
sept. 15 14:26:32 cachyos-ogu systemd[1]: ananicy-cpp.path: Failed to queue…ked.
sept. 15 14:26:32 cachyos-ogu systemd[1]: ananicy-cpp.path: Failed with res…es’.
Hint: Some lines were ellipsized, use -l to show in full.

journald is talking about cgroups issues / bpf troubles /segmentation faults

[warning] Cgroups are not available on this platform (or are not enabled)
[warning] cgroup2 at /sys/fs/cgroup/ananicy_test_cgroup2 doesn’t have a cpu controller available, skipping

********************************

failed to attach BPF programs

********************************

Main process exited, code=dumped, status=11/SEGV

However cgroups seem to work fine:

cat /sys/fs/cgroup/cgroup.controllers

cpuset cpu io memory hugetlb pids rdma misc dmem

*********************************************

mount | grep cgroup

cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime)
none on /run/bpftune/cgroupv2 type cgroup2 (rw,relatime)

So i tried to disable cgroups in the ananicy.conf file with apply_cgroup=false, but that didn’t help.

With these errors, ananicy-cpp does not seems to ionice at all.

Moreover i cannot uninstall it because of cachyos-settings depends on it. I had to delete *.path and then mask services.

I guess we shall wait for an update!

Thanks in advance!

Greetings from France

ogu

Hi, after a bunch of troubleshooting and trying to squeeze useful suggestions out of LLM’s I found the following solution:
sytemd drop-in file: for ananicy-cpp

## Fix ananicy-cpp not starting corectly                                                                                                                                                                           
## specifically complaining about Cgroups not being available or disabled                                                                                                                                          
                                                                                                                                                                                                                   
[Service]                                                                                                                                                                                                          
Delegate=yes                                                                                                                                                                                                       
                                                                                                                                                                                                                   
## ​Delegate=yes tells systemd to delegate management of the cgroup subtree to the service.                                                                                                                         
## This allows ananicy-cpp to create, modify, and manage its own cgroups for the processes it handles,                                                                                                             
## without conflicting with systemd’s overall cgroup management.                                                                                                                                                                                                                                        

Systemd override files are best created with sudo systemctl edit ananicy-cpp.service
This will create ‘/etc/systemd/system/ananicy-cpp.service.d/override.conf’

I like to rename it to tell me what it does, so if I ls the folder I already know what is going on, and it allows to easily have a file for each different reason I had to edit something.
Which also means it easy to delete again instead of finding what I edited in a convoluted file.

sudo mv /etc/systemd/system/ananicy-cpp.service.d/override.conf /etc/systemd/system/ananicy-cpp.service.d/override-fix_cgroup_not_available_by_adding_delegate-yes.conf


Do you all think this is a good solution?
Should I try and upstream it?


I don’t fully understand the impacts of Delegate=yes and the ramifications/the impact on ananicy-cpp and the whole system.

Hello @wisejackal and thanks for this workaround. Unfortunately, even with this override, ananicy-cpp systelmd service still fail at boot. Can you please add here the output of systemctl status ananicy-cpp.service, to compare with mine

Mine is just happy, what does yours say?
Anything in the journal?


Straight after a reboot …

systemctl status ananicy-cpp.service:

systemctl status ananicy-cpp.service
● ananicy-cpp.service - Ananicy-Cpp - ANother Auto NICe daemon in C++
     Loaded: loaded (/usr/lib/systemd/system/ananicy-cpp.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/ananicy-cpp.service.d
             └─override-fix_cgroup_not_available_by_adding_delegate-yes.conf
     Active: active (running) since Wed 2025-09-17 03:01:16 +08; 7min ago
 Invocation: 44ef8f47ee83439584f8e692c4bec8eb
   Main PID: 721 (ananicy-cpp)
      Tasks: 4 (limit: 17698)
     Memory: 11.3M (high: 16M, max: 64M, available: 4.6M, peak: 11.8M)
        CPU: 4.032s
     CGroup: /system.slice/ananicy-cpp.service
             └─721 /usr/bin/ananicy-cpp start

Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.424] [info] Config apply_ionice: true
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.424] [info] Config cgroup_load: true
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.424] [info] Config apply_sched: true
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.424] [info] Config apply_nice: true
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: Ananicy Cpp
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.440] [info] Starting Ananicy
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.447] [info] Creating Cgroups...
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.448] [info] Finished creating Cgroups...
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.450] [info] Doing a full scan
Sep 17 03:01:16 wisejackal-laptop ananicy-cpp[721]: [2025-09-17 03:01:16.460] [info] Worker initialized with 1383 rules

systemctl cat ananicy-cpp.service:

systemctl cat ananicy-cpp.service
# /usr/lib/systemd/system/ananicy-cpp.service
[Unit]
Description=Ananicy-Cpp - ANother Auto NICe daemon in C++
After=local-fs.target
StartLimitIntervalSec=0
StartLimitBurst=10

[Service]
Type=simple
ExecStart=/usr/bin/ananicy-cpp start
ExecReload=/usr/bin/ananicy-cpp --reload
Nice=-5
SuccessExitStatus=143
OOMScoreAdjust=-999
Restart=always
RestartSec=10
CPUAccounting=true
MemoryHigh=16M
MemoryMax=64M

# Hardening
ProtectSystem=true
ProtectHome=true
PrivateTmp=yes
PrivateDevices=true
ProtectClock=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true

CapabilityBoundingSet=~CAP_SYS_PTRACE CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP
ProcSubset=pid
RestrictAddressFamilies=AF_UNIX AF_NETLINK
NoNewPrivileges=true
lines 1-34...skipping...
# /usr/lib/systemd/system/ananicy-cpp.service
[Unit]
Description=Ananicy-Cpp - ANother Auto NICe daemon in C++
After=local-fs.target
StartLimitIntervalSec=0
StartLimitBurst=10

[Service]
Type=simple
ExecStart=/usr/bin/ananicy-cpp start
ExecReload=/usr/bin/ananicy-cpp --reload
Nice=-5
SuccessExitStatus=143
OOMScoreAdjust=-999
Restart=always
RestartSec=10
CPUAccounting=true
MemoryHigh=16M
MemoryMax=64M

# Hardening
ProtectSystem=true
ProtectHome=true
PrivateTmp=yes
PrivateDevices=true
ProtectClock=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true

CapabilityBoundingSet=~CAP_SYS_PTRACE CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP
ProcSubset=pid
RestrictAddressFamilies=AF_UNIX AF_NETLINK
NoNewPrivileges=true

RestrictSUIDSGID=true
RestrictNamespaces=cgroup
ProtectHostname=true
LockPersonality=true
MemoryDenyWriteExecute=true

# Filter system calls to those absolutely requrired for correct functioning.
#SystemCallErrorNumber=EPERM
#SystemCallFilter=@system-service
#SystemCallFilter=~@debug @module @mount @reboot @swap @clock @obsolete @cpu-emulation


# Required to see other processes
PrivateUsers=false
ProtectProc=default

# Required for the process-listener socket to work
PrivateNetwork=false


# Required for control groups (obviously)
ProtectControlGroups=false

# Required for future use.
RestrictRealtime=false

[Install]
WantedBy=local-fs.target

# /etc/systemd/system/ananicy-cpp.service.d/override-fix_cgroup_not_available_by_adding_delegate-yes.conf
## Fix ananicy-cpp not starting corectly
## specifically complaining about Cgroups not being available or disabled

[Service]
Delegate=yes

## ​Delegate=yes tells systemd to delegate management of the cgroup subtree to the service.
## This allows ananicy-cpp to create, modify, and manage its own cgroups for the processes it handles,
## without conflicting with systemd’s overall cgroup management.
lines 27-74/74 (END)

Thanks a lot!

Here is mine: ExecStart fails ( Process: 1945 ExecStart=/usr/bin/ananicy-cpp start (code=exited, status=1/FAILURE) Main PID: 1945 (code=exited, status=1/FAILURE) and i do not manage to understand why?

❯ systemctl status ananicy-cpp.service
● ananicy-cpp.service - Ananicy-Cpp - ANother Auto NICe daemon in C++
     Loaded: loaded (/usr/lib/systemd/system/ananicy-cpp.service; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/ananicy-cpp.service.d
             └─override-fix_cgroup_not_available_by_adding_delegate-yes.conf
     Active: activating (auto-restart) (Result: exit-code) since Wed 2025-09-17 16:38:33 CEST; 3s ago
 Invocation: cfa7acbef4e64fd3a35e235b4b167626
    Process: 1945 ExecStart=/usr/bin/ananicy-cpp start (code=exited, status=1/FAILURE)
   Main PID: 1945 (code=exited, status=1/FAILURE)
   Mem peak: 2.2M
        CPU: 20ms

~

❯ systemctl cat ananicy-cpp.service
# /usr/lib/systemd/system/ananicy-cpp.service
[Unit]
Description=Ananicy-Cpp - ANother Auto NICe daemon in C++
After=local-fs.target
StartLimitIntervalSec=0
StartLimitBurst=10

[Service]
Type=simple
ExecStart=/usr/bin/ananicy-cpp start
ExecReload=/usr/bin/ananicy-cpp --reload
Nice=-5
SuccessExitStatus=143
OOMScoreAdjust=-999
Restart=always
RestartSec=10
CPUAccounting=true
MemoryHigh=16M
MemoryMax=64M

# Hardening
ProtectSystem=true
ProtectHome=true
PrivateTmp=yes
PrivateDevices=true
ProtectClock=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true

CapabilityBoundingSet=~CAP_SYS_PTRACE CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_SETUID CAP_SETGID CAP_SETPCAP
ProcSubset=pid
RestrictAddressFamilies=AF_UNIX AF_NETLINK
NoNewPrivileges=true

RestrictSUIDSGID=true
RestrictNamespaces=cgroup
ProtectHostname=true
LockPersonality=true
MemoryDenyWriteExecute=true

# Filter system calls to those absolutely requrired for correct functioning.
#SystemCallErrorNumber=EPERM
#SystemCallFilter=@system-service
#SystemCallFilter=~@debug @module @mount @reboot @swap @clock @obsolete @cpu-emulation


# Required to see other processes
PrivateUsers=false
ProtectProc=default

# Required for the process-listener socket to work
PrivateNetwork=false


# Required for control groups (obviously)
ProtectControlGroups=false

# Required for future use.
RestrictRealtime=false

[Install]
WantedBy=local-fs.target

# /etc/systemd/system/ananicy-cpp.service.d/override-fix_cgroup_not_available_by_adding_delegate-yes.conf
                                                                                                                                                                                      
[Service]
Type=simple

~

Hey @Ugo,

Check your /etc/systemd/system/ananicy-cpp.service.d/override-fix_cgroup_not_available_by_adding_delegate-yes.conf

It looks like the content is wrong.

It should be:

Hi @wisejackal, i made an error copying the wrong output in the topic…

But the fail is still the same when override is good:

❯ systemctl cat ananicy-cpp.service


[Install]WantedBy=local-fs.target

/etc/systemd/system/ananicy-cpp.service.d/override.conf

Fix ananicy-cpp not starting corectly

specifically it complaining about Cgroups not being available or disabled

[Service]Delegate=yes

​Delegate=yes tells systemd to delegate management of the cgroup subtree to the service.

This allows ananicy-cpp to create, modify, and manage its own cgroups for the processes it handles,

without conflicting with systemd’s overall cgroup management.

~

Hey Ugo,

Sorry for the super late reply, I’m currently backpacking and didn’t spend much time on my laptop …

To me it looks like you are missing the # sign to make coments comments.

And gennerally your output of cat ananicy-cpp.service seems to be missing the whole contet of the main file, the drop in file is amending.