Re: [PATCH 7/7] mincore: apply page table walker on do_mincore()

From: Naoya Horiguchi
Date: Mon Jun 16 2014 - 12:45:10 EST


Hi Sasha,

Thanks for bug reporting.

On Mon, Jun 16, 2014 at 11:24:16AM -0400, Sasha Levin wrote:
> On 06/06/2014 06:58 PM, Naoya Horiguchi wrote:
> > This patch makes do_mincore() use walk_page_vma(), which reduces many lines
> > of code by using common page table walk code.
> >
> > Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
>
> Hi Naoya,
>
> This patch is causing a few issues on -next:
>
> [ 367.679282] BUG: sleeping function called from invalid context at mm/mincore.c:37

cond_resched() in mincore_hugetlb() triggered this. This is done in common
pagewalk code, so I should have removed it.

...
> And:
>
> [ 391.118663] BUG: unable to handle kernel paging request at ffff880142aca000
> [ 391.118663] IP: mincore_hole (mm/mincore.c:99 (discriminator 2))

walk->pte_hole cannot assume walk->vma != NULL, so I should've checked it
in mincore_hole() before using walk->vma.

Could you try the following fixes?

Thanks,
Naoya Horiguchi
---
diff --git a/mm/mincore.c b/mm/mincore.c
index d8a5e9f62268..3261788369bd 100644
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -34,7 +34,6 @@ static int mincore_hugetlb(pte_t *pte, unsigned long addr,
present = pte && !huge_pte_none(huge_ptep_get(pte));
for (; addr != end; vec++, addr += PAGE_SIZE)
*vec = present;
- cond_resched();
walk->private += (end - addr) >> PAGE_SHIFT;
#else
BUG();
@@ -91,7 +90,7 @@ static int mincore_hole(unsigned long addr, unsigned long end,
unsigned long nr = (end - addr) >> PAGE_SHIFT;
int i;

- if (vma->vm_file) {
+ if (vma && vma->vm_file) {
pgoff_t pgoff;

pgoff = linear_page_index(vma, addr);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/