get_user_pages() taking 100% CPU time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

I am trying to use get_user_pages to access the pages
of a user-space process. I wrote a system call for
this purpose so that whenever the process invokes this
system call the VM pages of the process are read.

My actual code is:

----snip------

int do_pagetest()
{
        struct task_struct *myTask;
        int retVal = 0, write = 0, mwrite = 0, len =
0;
        struct page *resPage;
        unsigned long startAddr, endAddr;

        myTask = current;
        startAddr = current->mm->mmap->vm_start;
        endAddr = current->mm->mmap->vm_end;

        printk(KERN_INFO "vm_start is :
%x\n",myTask->mm->mmap->vm_start);
        printk(KERN_INFO "vm_end is :
%x\n",myTask->mm->mmap->vm_end);
        printk(KERN_INFO "vm_flag is :
%x\n",myTask->mm->mmap->vm_flags);

        if(myTask->mm->mmap->vm_flags & VM_WRITE) {
                printk(KERN_INFO "VM_WRITE flag is set
\n");
                write = 1;
        }
        if((myTask->mm->mmap->vm_flags & VM_MAYWRITE)
&& write == 0) {
                printk(KERN_INFO "VM_MAYWRITE flag is
set \n");
                mwrite = 1;
        }

        len = (myTask->mm->mmap->vm_end -
myTask->mm->mmap->vm_start) / PAGE_SIZE;
        printk(KERN_INFO "len is : %d\n",len);
        resPage = kmalloc(len * sizeof(struct page *),
GFP_KERNEL);

        retVal = get_user_pages(myTask, myTask->mm,
startAddr, len, write, mwrite, &resPage, NULL);

        printk(KERN_INFO "Return value of
get_user_pages is : %d\n",retVal);
        kfree(resPage);
        return 0;
}
----snip------

The value of len is 3 but the system call uses up 100%
of CPU and does'nt even let me ssh into it from
another system. I am lost here and it would be really
helpful if someone can point me what am I doing wrong
here.

Also is there any other way to access the page
contents of a process.

TIA

Karthik

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux