All of lore.kernel.org
 help / color / mirror / Atom feed
* question about nopage sample code
@ 2017-02-22 13:31 Ali Aminian
  0 siblings, 0 replies; only message in thread
From: Ali Aminian @ 2017-02-22 13:31 UTC (permalink / raw)
  To: kernelnewbies

in ldd3 no page is implemented as the code posted below (page 428).
can someone explain why should we subtract vma->vm_start?

struct page *simple_vma_nopage(struct vm_area_struct *vma,
                unsigned long address, int *type)
{
    struct page *pageptr;
    unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
    unsigned long physaddr = address - vma->vm_start + offset;  // why
should we subtract vma->vm_start ?
    unsigned long pageframe = physaddr >> PAGE_SHIFT;

    if (!pfn_valid(pageframe))
        return NOPAGE_SIGBUS;
    pageptr = pfn_to_page(pageframe);
    get_page(pageptr);
    if (type)
        *type = VM_FAULT_MINOR;
    return pageptr;

}

thank you
Ali Aminian.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-22 13:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 13:31 question about nopage sample code Ali Aminian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.