mm->def_flags cleanups (Was: Change khugepaged to respect MMF_THP_DISABLE flag)
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 9 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | exec: kill the unnecessary mm->def_flags setting in load_elf_binary()fs/ | +0 | 0 replies | |
| 2/2 | mm: thp: kill the bogus ->def_flags check in hugepage_madvise()mm/ | +0 | 3 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] mm->def_flags cleanups (Was: Change khugepaged to respect MMF_THP_DISABLE flag)
Alex, Andrew, I think this simple series makes sense in any case, but _perhaps_ it can also help THP_DISABLE.
Quoted 7 lines · Alex Thorlton
Quoted 4 lines · Oleg Nesterov
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.
Quoted 5 lines
Maybe I've gotten myself confused as well :) After looking through the code some more, my understanding is that
khugepaged_test_exitis used to make sure that__khugepaged_exitisn't running from underneath at certain times, so to havekhugepaged_test_exitreturn true when__khugepaged_exitis not necessarily running, seems incorrect to me.
Still can't understand... probably I need to see v3.
But you know, I have another idea. Not sure you will like it, and probably I missed something.
Can't we simply add VM_NOHUGEPAGE into ->def_flags? See the (untested) patch below, on top of this series.
What do you think?
Oleg.
include/linux/mm.h +2 -0
@@ -167,6 +167,8 @@ extern unsigned int kobjsize(const void *objp);*/ #define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP) +#define VM_INIT_DEF_MASK VM_NOHUGEPAGE +/* * mapping from the currently active vm_flags protection bits (the * low four bits) to a page protection mask..
include/uapi/linux/prctl.h +3 -0
@@ -149,4 +149,7 @@#define PR_GET_TID_ADDRESS 40 +#define PR_SET_THP_DISABLE 41 +#define PR_GET_THP_DISABLE 42 +#endif /* _LINUX_PRCTL_H */
kernel/fork.c +8 -3
@@ -529,8 +529,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)atomic_set (&mm->mm_count,1 );init_rwsem (&mm->mmap_sem);INIT_LIST_HEAD (&mm->mmlist); - mm->flags = (current->mm) ? - (current->mm->flags &MMF_INIT_MASK ) : default_dump_filter; mm->core_state =NULL ;atomic_long_set (&mm->nr_ptes,0 );memset (&mm->rss_stat,0 ,sizeof (mm->rss_stat));
@@ -538,8 +536,15 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)mm_init_aio (mm);mm_init_owner (mm, p); -if (likely (!mm_alloc_pgd (mm))) { +if (current->mm) { + mm->flags = current->mm->flags &MMF_INIT_MASK ; + mm->def_flags = current->mm->def_flags &VM_INIT_DEF_MASK ; + }else { + mm->flags = default_dump_filter; mm->def_flags =0 ; + } + +if (likely (!mm_alloc_pgd (mm))) {mmu_notifier_mm_init (mm);return mm; }
kernel/sys.c +13 -0
@@ -2029,6 +2029,19 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,if (arg2 || arg3 || arg4 || arg5)return -EINVAL ;return current->no_new_privs ?1 :0 ; +case PR_SET_THP_DISABLE : +case PR_GET_THP_DISABLE : +down_write (&me->mm->mmap_sem); +if (option ==PR_SET_THP_DISABLE ) { +if (arg2) + me->mm->def_flags |=VM_NOHUGEPAGE ; +else + me->mm->def_flags &= ~VM_NOHUGEPAGE ; + }else { + error = !!(me->mm->flags &&VM_NOHUGEPAGE ); + } +up_write (&me->mm->mmap_sem); +break ;default : error = -EINVAL ;break ;