When a page fault happens in user application, what is current pid when kernel handler this fault

294 views Asked by At

I run a user app simply like this:

char *buf = malloc(sizeof(int) * 100000);
int *a = (int *)buf;
int i = 0;
for(; i < 100000; i++)
{
    a[i] = i;
}

I think it surely triggers page fault since malloc will not alloc a real physical space until we touch this data.

And I modified the linux kernel(3.17.6) mm/memory.c : handle_pte_fault() like this

if (targetPid == current->pid)
    printk(KERN_ALERT "soso : targetPid : %d, current->pid : %d\n", targetPid, current->pid); 

Here "tartgetPid" is the user app pid that I passed into kernel, "current" is the macro of kernel

But this line never triggered, because when kernel handle page fault, it's current pid will not be the pid of that user app which trigger a page fault.

I'd like to ask When a page fault happens in user application, what is current pid when kernel handler this fault

0

There are 0 answers