Hi, On Fri, 25 Apr 2025, Sheng Liu wrote: > > If an RT process needs to run in an interrupt-free environment on an > isolated CPU, how can it determine if the nohz_full conditions are met, > similar to how the kernel uses can_stop_full_tick()? > > Would it be feasible to add a variable in procfs, which can be read by > other programs and notify the RT process throught a shared memory flag. > This is overly-engineeded with no extra benefit. A simple cgroup setup and some basic /sys/fs/cgroup/ file reads should do the job just fine. Assuming a recent kernel, let's say you want to isolate the CPUs 0-1, right now, on your own laptop. Open a shell and do: CGROUP=rtisolated echo "+cpuset" > /sys/fs/cgroup/cgroup.subtree_control mkdir /sys/fs/cgroup/${CGROUP}.slice pushd /sys/fs/cgroup/${CGROUP}.slice echo 0-1 > cpuset.cpus echo isolated > cpuset.cpus.partition echo 0 > cpuset.mems cat cpuset.cpus.partition # should print "isolated" popd On the same shell, spawn a /bin/bash process in that 'rtisolated' cgroup: systemd-run \ --slice=${CGROUP} \ --unit=isolated-shell \ --pty \ /bin/bash Running as unit: isolated-shell.service Press ^] three times within 1s to disconnect TTY. Now, from that isolated shell, do: echo $$ # Bash own PID 302713 taskset --cpu-list --pid $$ # should print CPUs 0 and 1 pid 302713's current affinity list: 0,1 Now, also from that isolated shell, do: cat /proc/$$/cgroup cat /proc/self/cgroup Both "cat"s should print something like: 0::/rtisolated.slice/isolated-shell.service which can be easily done and verified from any C code as well, before starting the RT loop (where multiple initiatory steps need to be done anyway). Running systemd-cgls, from outside that isolated shell, should also print something like: CGroup /: -.slice ├─user.slice │ └─ ... ├─init.scope │ └─1 /sbin/init ├─system.slice │ └─ ... └─rtisolated.slice └─isolated-shell.service └─302713 /bin/bash ^^ ^^ Hope this helps a bit. Good luck, -- Ahmed S. Darwish Linutronix GmbH