0

I'm working on a project where I want to study the impact of process priority on system behavior.

I know that tools like nice, renice, and chrt can change the priority or scheduling policy (e.g., SCHED_FIFO, SCHED_RR, etc.) from user space using system calls.

However, I’m wondering:

Is there any technical or practical advantage to adjusting process priority using a kernel module instead of via user-space tools like nice or chrt?

Have you encountered cases where a kernel module offered more control or precision in setting scheduling parameters than user-space methods?

Any insights or examples would be appreciated!

Edit

More specifically:

Can setting the priority directly in the kernel (e.g., during process creation or in a module) reduce the chance of early interruptions or scheduling delays?

Is there any behavioral or performance gain from assigning SCHED_FIFO 99 at the earliest possible point, compared to launching the process with chrt -f 99 ?

I'm working in a forensics-related context where I want the memory acquisition process to be as undisturbed and deterministic as possible.

1 Answer 1

1

I'm assuming you're talking about Linux, because I know chrt only from there.

Have you encountered cases where a kernel module offered more control or precision in setting scheduling parameters than user-space methods?

Yeah, the cgroups v2 (which is part of the kernel, I'm not sure whether this is what you meant with "module", but my guess is "a control instance in the kernel, not in userspace") cpu controller, and cpuset controller are pretty much more useful than nice and setting realtime prios on processes; for example they allow for defining the share of CPU that a whole group of processes can get, instead of just allowing to rank processes according to an integer value with very little granularity, as niceness allows you to do.

Frankly, with cgroups v2's cpu kernel-side controller and its nice integration with userland tools, I've not used nice in a long time – "deprioritizing" individual processes is never what I want, if anything, I want to make a group of processes be constrained, and increasing "prioritizing" critical services is something I basically never have to care about.

chrt is orthogonal to this, and changes the only variables in the default Linux scheduler w.r.t. to its "scheduling-guarantee" RT aspect.

2
  • Thank you for your detailed response — the information about cgroups v2 is definitely useful for broader CPU management. To clarify my specific use case: I need to start a process with the highest possible priority, and ideally, it should not be interrupted or preempted by other processes during its execution. My question is whether it would give me any real advantage to implement this via a custom kernel module, rather than using standard userspace tools like nice, chrt, or sched_setscheduler(). Commented Jun 9 at 9:16
  • 1
    "it should not be interrupted or preempted by other processes during its execution" does it not do syscalls? if it does, it's interrupting itself :) But you might really want to look into cpuset if you need to reserve time. However, no, there's zero advantage to doing this in a module. as a module doesn't allow you to replace the scheduler, and all the things that you can adjust about a scheduler are already exposed to cgroups and to userland. Commented Jun 9 at 9:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.