Message ID | 20230919205158.1897353-2-shr@devkernel.io (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm/ksm: add fork-exec support for prctl | expand |
On Tue, 2023-09-19 at 13:51 -0700, Stefan Roesch wrote: > A process can enable KSM with the prctl system call. When the process > is > forked the KSM flag is inherited by the child process. However if the > process is executing an exec system call directly after the fork, the > KSM setting is cleared. This patch addresses this problem. > > Signed-off-by: Stefan Roesch <shr@devkernel.io> > Reported-by: Carl Klemm <carl@uvos.xyz> > --- > include/linux/sched/coredump.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/linux/sched/coredump.h > b/include/linux/sched/coredump.h > index 0ee96ea7a0e9..205aa9917394 100644 > --- a/include/linux/sched/coredump.h > +++ b/include/linux/sched/coredump.h > @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct > *mm) > > #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) > > +#define MMF_VM_MERGE_ANY 29 > +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) > + > #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | > MMF_DUMP_FILTER_MASK |\ > - MMF_DISABLE_THP_MASK | > MMF_HAS_MDWE_MASK) > + MMF_DISABLE_THP_MASK | > MMF_HAS_MDWE_MASK |\ > + MMF_VM_MERGE_ANY_MASK) > > -#define MMF_VM_MERGE_ANY 29 > #endif /* _LINUX_SCHED_COREDUMP_H */ I can confirm that this patch works as intended for my usecase, you can have my: Tested-by: Carl Klemm <carl@uvos.xyz>
On 19.09.23 22:51, Stefan Roesch wrote: > A process can enable KSM with the prctl system call. When the process is > forked the KSM flag is inherited by the child process. However if the > process is executing an exec system call directly after the fork, the > KSM setting is cleared. This patch addresses this problem. > > Signed-off-by: Stefan Roesch <shr@devkernel.io> > Reported-by: Carl Klemm <carl@uvos.xyz> > --- > include/linux/sched/coredump.h | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h > index 0ee96ea7a0e9..205aa9917394 100644 > --- a/include/linux/sched/coredump.h > +++ b/include/linux/sched/coredump.h > @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct *mm) > > #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) > > +#define MMF_VM_MERGE_ANY 29 > +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) > + > #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ > - MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK) > + MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\ > + MMF_VM_MERGE_ANY_MASK) > > -#define MMF_VM_MERGE_ANY 29 > #endif /* _LINUX_SCHED_COREDUMP_H */ Fixes: tag? Reviewed-by: David Hildenbrand <david@redhat.com>
David Hildenbrand <david@redhat.com> writes: > On 19.09.23 22:51, Stefan Roesch wrote: >> A process can enable KSM with the prctl system call. When the process is >> forked the KSM flag is inherited by the child process. However if the >> process is executing an exec system call directly after the fork, the >> KSM setting is cleared. This patch addresses this problem. >> Signed-off-by: Stefan Roesch <shr@devkernel.io> >> Reported-by: Carl Klemm <carl@uvos.xyz> >> --- >> include/linux/sched/coredump.h | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h >> index 0ee96ea7a0e9..205aa9917394 100644 >> --- a/include/linux/sched/coredump.h >> +++ b/include/linux/sched/coredump.h >> @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct *mm) >> #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) >> +#define MMF_VM_MERGE_ANY 29 >> +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) >> + >> #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ >> - MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK) >> + MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\ >> + MMF_VM_MERGE_ANY_MASK) >> -#define MMF_VM_MERGE_ANY 29 >> #endif /* _LINUX_SCHED_COREDUMP_H */ > > Fixes: tag? > Added fixes tag > Reviewed-by: David Hildenbrand <david@redhat.com>
diff --git a/include/linux/sched/coredump.h b/include/linux/sched/coredump.h index 0ee96ea7a0e9..205aa9917394 100644 --- a/include/linux/sched/coredump.h +++ b/include/linux/sched/coredump.h @@ -87,8 +87,11 @@ static inline int get_dumpable(struct mm_struct *mm) #define MMF_DISABLE_THP_MASK (1 << MMF_DISABLE_THP) +#define MMF_VM_MERGE_ANY 29 +#define MMF_VM_MERGE_ANY_MASK (1 << MMF_VM_MERGE_ANY) + #define MMF_INIT_MASK (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\ - MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK) + MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\ + MMF_VM_MERGE_ANY_MASK) -#define MMF_VM_MERGE_ANY 29 #endif /* _LINUX_SCHED_COREDUMP_H */
A process can enable KSM with the prctl system call. When the process is forked the KSM flag is inherited by the child process. However if the process is executing an exec system call directly after the fork, the KSM setting is cleared. This patch addresses this problem. Signed-off-by: Stefan Roesch <shr@devkernel.io> Reported-by: Carl Klemm <carl@uvos.xyz> --- include/linux/sched/coredump.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)