title: Getting error when compiling kernel for page table walk
body: <p>I am doing a page table walk. When I am getting ready to update the kernel I get an error:</p>
  
  <pre><code>kernel/sys.c: In function ‘__do_sys_get_page_info’:
  kernel/sys.c:2745:23: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types]
        pud = pud_offset(pgd, vmpage);
                         ^
  In file included from ./include/linux/mm.h:99:0,
                   from kernel/sys.c:19:
  ./arch/x86/include/asm/pgtable.h:905:22: note: expected ‘p4d_t * {aka struct &lt;anonymous&gt; *}’ but argument is of type ‘pgd_t * {aka struct &lt;anonymous&gt; *}’
   static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
                        ^
  </code></pre>
  
  <p>This is where the code is being used:</p>
  
  <pre><code>....
  int loc, ref, dirty;
  struct vm_area_struct *vma;
  unsigned long vmpage;
  struct mm_struct *task_mm = task-&gt;mm;
  if ((task_mm &amp;&amp; task_mm-&gt;mmap))
  {
      int i;
      pgd_t *pgd;
      pud_t *pud;
      pmd_t *pmd;
      pte_t *ptep, pte;
  
      vma = task_mm-&gt;mmap;
  
      while (vma)
      {
          for (vmpage = vma-&gt;vm_start, i = 1; vmpage &lt; vma-&gt;vm_end; vmpage += PAGE_SIZE, i++)
          {
              pgd = pgd_offset(task_mm, vmpage);
              if (pgd_none(*pgd) || pgd_bad(*pgd))
                  return 0;
  
              pud = pud_offset(pgd, vmpage);
              if (pud_none(*pud) || pud_bad(*pud))
                  return 0;
  
              pmd = pmd_offset(pud, vmpage);
              if (pmd_none(*pmd) || pmd_bad(*pmd))
                  return 0;
  
              ptep = pte_offset_kernel(pmd, vmpage);
              if (!ptep)
                  return 0;
  
              pte = *ptep;
              ...
  }
  </code></pre>
  
  <p>I looked up the errors and notes but didn't find anything about resolving this problem. Is this a well known problem or am I doing something wrong?</p>
  
  <p>updated*</p>