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

From: Alex Thorlton
Date: Fri Jan 17 2014 - 17:58:17 EST

On Fri, Jan 17, 2014 at 09:34:44PM +0100, Oleg Nesterov wrote:
> On 01/16, Alex Thorlton wrote:
> >
> > static inline int khugepaged_test_exit(struct mm_struct *mm)
> > {
> > - return atomic_read(&mm->mm_users) == 0;
> > + return atomic_read(&mm->mm_users) == 0 ||
> > + (mm->flags & MMF_THP_DISABLE_MASK);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> test_bit(MMF_THP_DISABLE) ?

Probably should just use the bitop here, good call.

> And I am not sure this and another check in transparent_hugepage_enabled
> is actually right...
> I think that MMF_THP_DISABLE_MASK should not disable thp if this
> vma has VM_HUGEPAGE set, iow perhaps madvise() should work even
> IOW, MMF_THP_DISABLE should act as khugepaged_req_madv().

I hadn't thought of this, but maybe that's a good idea. That way we can
turn off THP in general for an mm, but the places in code that
*specifically* request THP will still get it. I don't see why that
would be a problem, as long as we go with the assumption that, if
somebody is explicitly requesting THPs, they probably have a good reason
for doing so.

Thanks for the input!

- 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
Please read the FAQ at