linux-samsung-r9q2/include/linux/sched
Stefan Roesch 3c6f33b727 mm/ksm: support fork/exec for prctl
Patch series "mm/ksm: add fork-exec support for prctl", v4.

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 series addresses this problem.

1) Change the mask in coredump.h for execing a new process
2) Add a new test case in ksm_functional_tests


This patch (of 2):

Today we have two ways to enable KSM:

1) madvise system call
   This allows to enable KSM for a memory region for a long time.

2) prctl system call
   This is a recent addition to enable KSM for the complete process.
   In addition when a process is forked, the KSM setting is inherited.

This change only affects the second case.

One of the use cases for (2) was to support the ability to enable
KSM for cgroups. This allows systemd to enable KSM for the seed
process. By enabling it in the seed process all child processes inherit
the setting.

This works correctly when the process is forked. However it doesn't
support fork/exec workflow.

From the previous cover letter:

....
Use case 3:
With the madvise call sharing opportunities are only enabled for the
current process: it is a workload-local decision. A considerable number
of sharing opportunities may exist across multiple workloads or jobs
(if they are part of the same security domain). Only a higler level
entity like a job scheduler or container can know for certain if its
running one or more instances of a job. That job scheduler however
doesn't have the necessary internal workload knowledge to make targeted
madvise calls.
....

In addition it can also be a bit surprising that fork keeps the KSM
setting and fork/exec does not.

Link: https://lkml.kernel.org/r/20230922211141.320789-1-shr@devkernel.io
Link: https://lkml.kernel.org/r/20230922211141.320789-2-shr@devkernel.io
Signed-off-by: Stefan Roesch <shr@devkernel.io>
Fixes: d7597f59d1 ("mm: add new api to enable ksm per process")
Reviewed-by: David Hildenbrand <david@redhat.com>
Reported-by: Carl Klemm <carl@uvos.xyz>
Tested-by: Carl Klemm <carl@uvos.xyz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Rik van Riel <riel@surriel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-10-16 15:44:38 -07:00
..
affinity.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
autogroup.h
clock.h sched/clock: Provide local_clock_noinstr() 2023-06-05 21:11:09 +02:00
cond_resched.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
coredump.h mm/ksm: support fork/exec for prctl 2023-10-16 15:44:38 -07:00
cpufreq.h
cputime.h cputime: remove cputime_to_nsecs fallback 2022-12-27 12:52:17 +01:00
deadline.h sched/headers: Make the <linux/sched/deadline.h> header build standalone 2022-02-23 10:58:33 +01:00
debug.h
hotplug.h
idle.h cpuidle, sched: Remove instrumentation from TIF_{POLLING_NRFLAG,NEED_RESCHED} 2023-01-13 11:48:16 +01:00
init.h
isolation.h sched/isolation: add cpu_is_isolated() API 2023-04-18 16:29:43 -07:00
jobctl.h sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state 2022-05-11 14:37:06 -05:00
loadavg.h
mm.h IOMMU Updates for Linux 6.4 2023-04-30 13:00:38 -07:00
nohz.h
numa_balancing.h sched/numa, mm: make numa migrate functions to take a folio 2023-10-16 15:44:38 -07:00
posix-timers.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
prio.h
rseq_api.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
rt.h sched/core: Always flush pending blk_plug 2022-07-13 11:29:17 +02:00
sd_flags.h sched/topology: Remove SHARED_CHILD from ASYM_PACKING 2023-05-08 10:58:37 +02:00
signal.h document while_each_thread(), change first_tid() to use for_each_thread() 2023-08-24 16:25:15 -07:00
smt.h
stat.h
sysctl.h sched: Move numa_balancing sysctls to its own file 2022-11-20 20:55:26 -08:00
task.h sched: avoid false lockdep splat in put_task_struct() 2023-07-13 15:21:48 +02:00
task_flags.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
task_stack.h sched: Fix KCSAN noinstr violation 2023-04-14 16:08:26 +02:00
thread_info_api.h sched/headers: Add initial new headers as identity mappings 2022-02-23 10:58:28 +01:00
topology.h sched/topology: Mark set_sched_topology() __init 2023-06-16 17:08:01 +02:00
types.h
user.h kernel/user: Allow user_struct::locked_vm to be usable for iommufd 2022-11-30 20:16:49 -04:00
vhost_task.h fork, vhost: Use CLONE_THREAD to fix freezer/ps regression 2023-06-01 17:15:33 -04:00
wake_q.h
xacct.h