2

I am writing a kernel module which tries to get the current task for a given cpu, for example,

for_each_possible_cpu(cpu)
{
     p = curr_task(cpu);
     printk("current task on cpu %d is %d\n", cpu, p->pid);
}

In our kernel module we could only used exported function symbols, or we could hard code the kernel func address from system map in our module then use it.

Now I only found curr_task function for IA64, what is the way to get the current task on given cpu for X86_32? Thank you.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

1 Answers1

0

You can do like:

struct task_struct *task;
task=per_cpu(current_task, cpu_id);

This one could get the “per_cpu##current_task” which represent the cur_task in specified cpu. This may fulfill your requirement.

GeneLiuST
  • 1
  • 1