android_kernel_motorola_sm6375/kernel
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Suren Baghdasaryan 74cf1bc3a2 FROMGIT: mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary
Currently __set_oom_adj loops through all processes in the system to
keep oom_score_adj and oom_score_adj_min in sync between processes
sharing their mm. This is done for any task with more that one mm_users,
which includes processes with multiple threads (sharing mm and signals).
However for such processes the loop is unnecessary because their signal
structure is shared as well.
Android updates oom_score_adj whenever a tasks changes its role
(background/foreground/...) or binds to/unbinds from a service, making
it more/less important. Such operation can happen frequently.
We noticed that updates to oom_score_adj became more expensive and after
further investigation found out that the patch mentioned in "Fixes"
introduced a regression. Using Pixel 4 with a typical Android workload,
write time to oom_score_adj increased from ~3.57us to ~362us. Moreover
this regression linearly depends on the number of multi-threaded
processes running on the system.
Mark the mm with a new MMF_MULTIPROCESS flag bit when task is created with
(CLONE_VM && !CLONE_THREAD && !CLONE_VFORK). Change __set_oom_adj to use
MMF_MULTIPROCESS instead of mm_users to decide whether oom_score_adj
update should be synchronized between multiple processes. To prevent
races between clone() and __set_oom_adj(), when oom_score_adj of the
process being cloned might be modified from userspace, we use
oom_adj_mutex. Its scope is changed to global. The combination of
(CLONE_VM && !CLONE_THREAD) is rarely used except for the case of vfork().
To prevent performance regressions of vfork(), we skip taking oom_adj_mutex
and setting MMF_MULTIPROCESS when CLONE_VFORK is specified. Clearing the
MMF_MULTIPROCESS flag (when the last process sharing the mm exits) is left
out of this patch to keep it simple and because it is believed that this
threading model is rare. Should there ever be a need for optimizing that
case as well, it can be done by hooking into the exit path, likely
following the mm_update_next_owner pattern.
With the combination of (CLONE_VM && !CLONE_THREAD && !CLONE_VFORK) being
quite rare, the regression is gone after the change is applied.

Fixes: 44a70adec9 ("mm, oom_adj: make sure processes sharing mm have same view of oom_score_adj")
Reported-by: Tim Murray <[email protected]>
Debugged-by: Minchan Kim <[email protected]>
Suggested-by: Michal Hocko <[email protected]>
Signed-off-by: Suren Baghdasaryan <[email protected]>
Bug: 168521639
Link: https://lore.kernel.org/linux-fsdevel/[email protected]/
[isaacm: upstream bound, no cherry-pick info because patch is in mm tree]
Change-Id: I20352a77815fbc358c36e686bb1503fdeea658ed
Signed-off-by: Isaac J. Manjarres <[email protected]>
Git-commit: 40f057fb2d
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Isaac J. Manjarres <[email protected]>
2020-09-16 09:56:55 -07:00
..
bpf This is the 5.4.57 stable release 2020-08-07 10:07:58 +02:00
cgroup ANDROID: kernel: cgroup: cpuset: Clear cpus_requested for empty buf 2020-08-27 02:50:39 +05:30
configs
debug kgdb: Avoid suspicious RCU usage warning 2020-07-09 09:37:51 +02:00
dma Merge android-5.4-stable.45 (a9a13ee) into msm-5.4 2020-07-09 17:51:24 -07:00
events Merge android11-5.4.61+ (0d36496) into msm-5.4 2020-09-02 16:54:52 -07:00
gcov kernel/gcov/fs.c: gcov_seq_next() should increase position index 2020-04-29 16:33:00 +02:00
irq Merge android11-5.4.60 (8ae87ad) into msm-5.4 2020-08-31 13:04:44 -07:00
livepatch ANDROID: kallsyms: increase KSYM_NAME_LEN 2020-08-04 19:33:41 +00:00
locking Merge android11-5.4.60 (8ae87ad) into msm-5.4 2020-08-31 13:04:44 -07:00
power Merge android11-5.4.61+ (0d36496) into msm-5.4 2020-09-02 16:54:52 -07:00
printk soc: qcom: Add support to dump initial bootup logs 2020-09-04 20:54:40 +05:30
rcu Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
sched Merge "sched/fair: Improve the scheduler" 2020-09-15 08:24:19 -07:00
time Merge "kernel: time: Fix accuracy for low resolution timer" 2020-08-17 01:14:51 -07:00
trace soc: qcom: Enable ftrace support in minidump 2020-09-07 17:36:17 +05:30
.gitignore
acct.c
async.c
audit.c audit: fix a net reference leak in audit_list_rules_send() 2020-06-22 09:30:59 +02:00
audit.h audit: fix a net reference leak in audit_list_rules_send() 2020-06-22 09:30:59 +02:00
audit_fsnotify.c
audit_tree.c
audit_watch.c
auditfilter.c audit: fix a net reference leak in audit_list_rules_send() 2020-06-22 09:30:59 +02:00
auditsc.c
backtracetest.c
bounds.c
capability.c
cfi.c ANDROID: cfi: fix export symbol types 2020-04-29 19:12:47 +02:00
compat.c
configs.c
context_tracking.c
cpu.c Merge android-5.4-stable.50 (a200ad5) into msm-5.4 2020-07-20 19:22:16 -07:00
cpu_pm.c kernel/cpu_pm: Fix uninitted local in cpu_pm 2020-06-22 09:31:22 +02:00
crash_core.c
crash_dump.c
cred.c keys: Fix request_key() cache 2020-01-17 19:48:42 +01:00
delayacct.c
dma.c
elfcore.c
exec_domain.c
exit.c Merge android-5.4-stable.50 (a200ad5) into msm-5.4 2020-07-20 19:22:16 -07:00
extable.c
fail_function.c
fork.c FROMGIT: mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary 2020-09-16 09:56:55 -07:00
freezer.c
futex.c ANDROID: futex: Add vendor hook for wait queue 2020-08-20 19:30:35 +00:00
gen_kheaders.sh
groups.c
hung_task.c hung task: check specific tasks for long uninterruptible sleep state 2020-03-23 15:44:56 -07:00
iomem.c
irq_work.c
jump_label.c
kallsyms.c Merge 5.4.52 into android11-5.4 2020-07-16 09:48:45 +02:00
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c UPSTREAM: kcov: remote coverage support 2020-01-13 18:54:56 +00:00
kexec.c
kexec_core.c
kexec_elf.c
kexec_file.c
kexec_internal.h
kheaders.c
kmod.c kmod: make request_module() return an error when autoloading is disabled 2020-04-17 10:50:22 +02:00
kprobes.c Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4" 2020-08-23 13:12:51 +02:00
ksysfs.c
kthread.c kthread: Do not preempt current task if it is going to call schedule() 2020-08-26 10:40:53 +02:00
latencytop.c
Makefile
module-internal.h
module.c Merge android11-5.4.61+ (54e6ca5) into msm-5.4 2020-09-04 15:09:32 -07:00
module_signature.c
module_signing.c
notifier.c x86/mm: split vmalloc_sync_all() 2020-03-25 08:25:58 +01:00
nsproxy.c
padata.c padata: add separate cpuhp node for CPUHP_PADATA_DEAD 2020-06-17 16:40:22 +02:00
panic.c
params.c
pid.c pid: move pidfd_get_pid() to pid.c 2020-06-18 18:01:49 +05:30
pid_namespace.c
profile.c
ptrace.c ptrace: reintroduce usage of subjective credentials in ptrace_has_cap() 2020-01-23 08:22:36 +01:00
range.c
reboot.c
relay.c kernel/relay.c: fix memleak on destroy relay channel 2020-08-26 10:40:51 +02:00
resource.c /dev/mem: Revoke mappings when a driver claims the region 2020-06-24 17:50:35 +02:00
rseq.c
scs.c ANDROID: scs: fix recursive spinlock in scs_check_usage 2020-06-09 23:39:55 -07:00
seccomp.c seccomp: Fix ioctl number for SECCOMP_IOCTL_NOTIF_ID_VALID 2020-08-19 08:15:58 +02:00
signal.c Merge android-5.4-stable.45 (a9a13ee) into msm-5.4 2020-07-09 17:51:24 -07:00
smp.c smp: Wake up all idle CPUs when suspending to idle 2020-01-15 14:35:44 -08:00
smpboot.c
smpboot.h
softirq.c trace: Add trace points for tasklet entry/exit 2020-02-25 07:37:13 -08:00
stackleak.c
stacktrace.c
stop_machine.c
sys.c
sys_ni.c mm/madvise: introduce process_madvise() syscall: an external memory hinting API 2020-06-18 17:55:54 +05:30
sysctl.c Merge "sched/fair: Improve the scheduler" 2020-09-13 18:52:20 -07:00
sysctl_binary.c
task_work.c
taskstats.c taskstats: extended taskstats2 with acct fields 2020-06-22 14:26:19 +05:30
test_kprobes.c
torture.c
tracepoint.c
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c umh: fix memory leak on execve failure 2020-05-20 08:20:13 +02:00
up.c
user-return-notifier.c
user.c Revert "ANDROID: proc: Add /proc/uid directory" 2020-03-06 20:23:08 +00:00
user_namespace.c
utsname.c
utsname_sysctl.c
watchdog.c Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
watchdog_hld.c
workqueue.c Merge android-5.4-stable.32 (724ffa0) into msm-5.4 2020-06-24 11:39:32 -07:00
workqueue_internal.h