2

I'm facing a strange extreme load issue on idle conditions.

Is there a way to directly dump the linux process scheduler run queue?
E.g. when sar -q outputs 400 as runq-sz, to get those 400 PIDs?

ps, top and friends seems to be too "slow" to take an instant snapshot, because they're showing only a few processes in D or R state.

  • I'm not sure if the scheduler performs any logging (actually, i think it may not log any kernel messages and i'm talking crap) but you can try booting with log_level=6 (or maybe even 7). Just be prepared to get a lot of messages in dmesg. – grochmal Jul 29 '16 at 20:51
  • The run queue includes threads (a thread is defined as a "light weight process"). Use top -H and ps -eLf to show them. – Patrick Jul 30 '16 at 2:10
1

I don't know how to dump the run queue, but you might be able to get some other info using perf. Eg if a storm of new processes are being created, you can trace them with

perf record -e sched:sched_process_exec -a

Stop the recording with control-C, and look at the results with perf report. You might also look through the simple but powerful scripts based on perf that Brendan Gregg has gathered.

0

Looking straight at the kernel source code, you can browse tasks like the following.

struct task_struct *process, *thread;
int cnt = 0;

rcu_read_lock();
for_each_process_thread(process, thread) {
    task_lock(thread);

/* do something with the task properties:

     thread->state;
     thread->wake_cpu;
     thread->pid;
     thread->comm;
*/

    task_unlock(thread);
    cnt++;
}
rcu_read_unlock();

The most important part is to lock the tasks RCU at entry and unlock at exit. You will code this dump in a kernel module and provide a mean to retrieve the list in a user-space command.

I suggest you to read and enhance to your needs my example in the GitHub @ dumptask

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.