Re: [RFC PATCHv2 2/2] Change khugepaged to respect MMF_THP_DISABLEflag

From: Alex Thorlton
Date: Mon Jan 20 2014 - 15:41:06 EST


On Mon, Jan 20, 2014 at 09:15:25PM +0100, Oleg Nesterov wrote:
> On 01/20, Alex Thorlton wrote:
> >
> > No, definitely not. Upon review, khugepaged_test_exit is the wrong
> > place to do this check. I think I need to move it up to
> > khugepaged_scan_mm_slot for this to work correctly.
>
> Why? unless a MMF_THP_DISABLE task does madvise(MADV_HUGEPAGE)
> khugepaged_scan_mm_slot() should never see its ->mm ?
>
> Although I got lost a bit, and probably misunderstood... but it
> seems to me that whatever you do this patch should not touch
> khugepaged_scan_mm_slot.

Maybe I've gotten myself confused as well :) After looking through the
code some more, my understanding is that khugepaged_test_exit is used to
make sure that __khugepaged_exit isn't running from underneath at certain
times, so to have khugepaged_test_exit return true when __khugepaged_exit
is not necessarily running, seems incorrect to me.

I think the check for MMF_THP_DISABLE should occur at the same time as
we check khugepaged_test_exit, but should occur separately, since I
don't really believe the two checks are related. Something like this in
khugepaged_scan_mm_slot:

mm = mm_slot->mm;
down_read(&mm->mmap_sem);
- if (unlikely(khugepaged_test_exit(mm)))
+ if (unlikely(khugepaged_test_exit(mm) || check_mmf_thp_disable(mm)))
vma = NULL;
else
vma = find_vma(mm, khugepaged_scan.address);

progress++;

I think this makes more sense, but I may not be looking at this
correctly. Thoughts?

- Alex
--
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/