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
..
9p
This is the 5.4.59 stable release
2020-08-19 08:40:57 +02:00
adfs
Merge branch 'work.adfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 11:33:22 -07:00
affs
affs: fix a memory leak in affs_remount
2020-01-17 19:48:50 +01:00
afs
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
autofs
autofs: fix a leak in autofs_expire_indirect()
2019-10-25 00:03:11 -04:00
befs
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
bfs
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
btrfs
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
cachefiles
cachefiles: Fix race between read_waiter and read_copier involving op->to_do
2020-06-03 08:21:11 +02:00
ceph
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
cifs
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
coda
y2038: add inode timestamp clamping
2019-09-19 09:42:37 -07:00
configfs
configfs: fix config_item refcnt leak in configfs_rmdir()
2020-05-27 17:46:30 +02:00
cramfs
cramfs: fix usage on non-MTD device
2019-11-23 21:44:49 -05:00
crypto
ANDROID: fscrypt: fix DUN contiguity with inline encryption + IV_INO_LBLK_32 policies
2020-07-14 15:48:10 +00:00
debugfs
debugfs: Check module state before warning in {full/open}_proxy_open()
2020-04-17 10:50:02 +02:00
devpts
devpts_pty_kill(): don't bother with d_delete()
2019-09-03 09:30:56 -04:00
dlm
dlm: Fix kobject memleak
2020-08-19 08:16:21 +02:00
ecryptfs
This is the 5.4.23 stable release
2020-03-01 10:17:44 +01:00
efivarfs
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
efs
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
erofs
This is the 5.4.59 stable release
2020-08-19 08:40:57 +02:00
exportfs
exportfs_decode_fh(): negative pinned may become positive without the parent locked
2019-11-10 11:56:05 -05:00
ext2
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
ext4
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
f2fs
Merge android11-5.4.52 ( c7725ae) into msm-5.4
2020-07-27 01:21:35 -07:00
fat
fat: don't allow to mount if the FAT length == 0
2020-06-17 16:40:36 +02:00
freevxfs
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
fscache
fuse
This is the 5.4.54 stable release
2020-07-29 13:27:01 +02:00
gfs2
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
hfs
FROMLIST: Add flags option to get xattr method paired to __vfs_getxattr
2019-11-05 13:50:57 -08:00
hfsplus
This is the 5.4.33 stable release
2020-04-17 11:26:58 +02:00
hostfs
hpfs
fs: hpfs: Initialize filesystem timestamp ranges
2019-08-30 08:11:25 -07:00
hugetlbfs
Merge android-5.4.24 ( ce5de62) into msm-5.4
2020-04-14 08:25:29 -07:00
incfs
ANDROID: Incremental fs: fix magic compatibility again
2020-08-26 14:05:41 +00:00
iomap
Merge android-5.4.8 ( de197c5) into msm-5.4
2020-03-06 19:19:20 -08:00
isofs
y2038: add inode timestamp clamping
2019-09-19 09:42:37 -07:00
jbd2
jbd2: add the missing unlock_buffer() in the error path of jbd2_write_superblock()
2020-08-26 10:40:52 +02:00
jffs2
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
jfs
FROMLIST: Add flags option to get xattr method paired to __vfs_getxattr
2019-11-05 13:50:57 -08:00
kernfs
This is the 5.4.59 stable release
2020-08-19 08:40:57 +02:00
lockd
minix
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
nfs
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
nfs_common
nfsd
nfsd: Fix NFSv4 READ on RDMA when using readv
2020-08-11 15:33:42 +02:00
nilfs2
nilfs2: fix null pointer dereference at nilfs_segctor_do_construct()
2020-06-17 16:40:29 +02:00
nls
notify
fanotify: fix ignore mask logic for events on child and on dir
2020-06-17 16:40:24 +02:00
ntfs
utimes: Clamp the timestamps in notify_change()
2020-02-11 04:35:12 -08:00
ocfs2
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
omfs
fs: omfs: Initialize filesystem timestamp ranges
2019-08-30 08:11:25 -07:00
openpromfs
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
orangefs
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
overlayfs
This is the 5.4.53 stable release
2020-07-23 12:36:54 +02:00
proc
FROMGIT: mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary
2020-09-16 09:56:55 -07:00
pstore
Merge "pstore: Register pstore reserved memory into Minidump"
2020-09-09 15:28:45 -07:00
qnx4
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
qnx6
fs: Fill in max and min timestamps in superblock
2019-08-30 07:27:17 -07:00
quota
fs: avoid softlockups in s_inodes iterators
2020-01-12 12:21:37 +01:00
ramfs
vfs: Convert ramfs, shmem, tmpfs, devtmpfs, rootfs to use the new mount API
2019-09-12 21:05:34 -04:00
reiserfs
This is the 5.4.22 stable release
2020-02-24 09:16:10 +01:00
romfs
romfs: fix uninitialized memory leak in romfs_dev_read()
2020-08-26 10:40:51 +02:00
squashfs
FROMLIST: Add flags option to get xattr method paired to __vfs_getxattr
2019-11-05 13:50:57 -08:00
sysfs
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
sysv
fs: sysv: Initialize filesystem timestamp ranges
2019-08-30 07:27:18 -07:00
tracefs
tracing: Do not create tracefs files if tracefs lockdown is in effect
2019-10-12 20:49:07 -04:00
ubifs
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
udf
udf: Fix free space reporting for metadata and virtual partitions
2020-02-24 08:36:44 +01:00
ufs
Revert "ANDROID: Revert: Merge 5.4.60 into android11-5.4"
2020-08-23 13:12:51 +02:00
unicode
FROMLIST: unicode: Add utf8_casefold_hash
2020-02-20 21:21:02 +00:00
verity
fs-verity: remove unnecessary extern keywords
2020-06-16 14:06:46 -07:00
xfs
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
aio.c
aio: fix async fsync creds
2020-06-17 16:40:24 +02:00
anon_inodes.c
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
attr.c
Revert "ANDROID: vfs: Add setattr2 for filesystems with per mount permissions"
2020-05-29 14:48:38 +02:00
bad_inode.c
binfmt_aout.c
binfmt_elf.c
fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info()
2020-06-03 08:21:27 +02:00
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
binfmt_script.c
block_dev.c
block: Fix use-after-free in blkdev_get()
2020-06-24 17:50:47 +02:00
buffer.c
Merge android-5.4-stable.45 ( a9a13ee) into msm-5.4
2020-07-09 17:51:24 -07:00
char_dev.c
chardev: Avoid potential use-after-free in 'chrdev_open()'
2020-01-14 20:08:18 +01:00
compat.c
compat_binfmt_elf.c
compat_ioctl.c
fix compat handling of FICLONERANGE, FIDEDUPERANGE and FS_IOC_FIEMAP
2020-01-09 10:20:05 +01:00
coredump.c
Revert "ANDROID: vfs: Add setattr2 for filesystems with per mount permissions"
2020-05-29 14:48:38 +02:00
d_path.c
[PATCH] fix d_absolute_path() interplay with fsmount()
2019-08-30 19:31:09 -04:00
dax.c
dax: pass NOWAIT flag to iomap_apply
2020-03-05 16:43:36 +01:00
dcache.c
Merge branch 'work.dcache2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-20 09:15:51 -07:00
dcookies.c
direct-io.c
ANDROID: fscrypt: handle direct I/O with IV_INO_LBLK_32
2020-05-21 11:52:18 -07:00
drop_caches.c
fs: avoid softlockups in s_inodes iterators
2020-01-12 12:21:37 +01:00
eventfd.c
eventfd: track eventfd_signal() recursion depth
2020-02-11 04:35:37 -08:00
eventpoll.c
This is the 5.4.61 stable release
2020-08-26 11:11:38 +02:00
exec.c
Revert "ANDROID: vfs: Add permission2 for filesystems with per mount permissions"
2020-05-29 14:48:37 +02:00
fcntl.c
fhandle.c
fs/handle.c - fix up kerneldoc
2019-08-07 21:51:47 -04:00
file.c
fix multiplication overflow in copy_fdtable()
2020-05-27 17:46:12 +02:00
file_table.c
vfs: Export flush_delayed_fput for use by knfsd.
2019-08-19 11:00:39 -04:00
filesystems.c
fs/filesystems.c: downgrade user-reachable WARN_ONCE() to pr_warn_once()
2020-04-17 10:50:21 +02:00
fs-writeback.c
Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.4.y' into android-5.4-stable
2020-06-24 11:13:19 -07:00
fs_context.c
vfs: subtype handling moved to fuse
2019-09-06 21:28:49 +02:00
fs_parser.c
vfs: Make fs_parse() handle fs_param_is_fd-type params better
2019-09-12 21:06:14 -04:00
fs_pin.c
fs_struct.c
Revert "ANDROID: sdcardfs: Enable modular sdcardfs"
2020-05-29 15:08:00 +02:00
fs_types.c
fsopen.c
Merge branch 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
2019-07-19 10:42:02 -07:00
inode.c
Revert "ANDROID: vfs: Add setattr2 for filesystems with per mount permissions"
2020-05-29 14:48:38 +02:00
internal.h
Revert "ANDROID: fs: Restore vfs_path_lookup() export"
2020-05-29 14:48:37 +02:00
io_uring.c
io_uring: Fix NULL pointer dereference in loop_rw_iter()
2020-08-19 08:16:29 +02:00
ioctl.c
compat_ioctl: add compat_ptr_ioctl()
2019-12-17 19:55:30 +01:00
Kconfig
ANDROID: sdcardfs: remove sdcardfs from system
2020-05-29 14:48:37 +02:00
Kconfig.binfmt
libfs.c
Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.4.y' into android-5.4-stable
2020-06-15 13:22:44 -07:00
locks.c
locks: reinstate locks_delete_block optimization
2020-03-25 08:25:41 +01:00
Makefile
ANDROID: GKI: set vfs-only exports into their own namespace
2020-07-07 18:07:10 +02:00
mbcache.c
mount.h
mpage.c
This is the 5.4.13 stable release
2020-01-17 23:38:39 +01:00
namei.c
ANDROID: GKI: set vfs-only exports into their own namespace
2020-07-07 18:07:10 +02:00
namespace.c
Linux 5.4-rc8
2019-11-18 08:31:11 +01:00
no-block.c
nsfs.c
open.c
ANDROID: GKI: set vfs-only exports into their own namespace
2020-07-07 18:07:10 +02:00
pipe.c
pnode.c
This is the 5.4.37 stable release
2020-05-02 09:01:51 +02:00
pnode.h
ANDROID: mnt: Add filesystem private data to mount points
2019-07-19 12:39:18 -07:00
posix_acl.c
FROMLIST: Add flags option to get xattr method paired to __vfs_getxattr
2019-11-05 13:50:57 -08:00
proc_namespace.c
Merge 5.4-rc1-prelrease into android-mainline
2019-10-02 17:58:47 +02:00
read_write.c
ANDROID: GKI: set vfs-only exports into their own namespace
2020-07-07 18:07:10 +02:00
readdir.c
readdir: be more conservative with directory entry names
2020-01-29 16:45:31 +01:00
select.c
seq_file.c
seq_file: fix problem when seeking mid-record
2019-08-13 16:06:52 -07:00
signalfd.c
fs/signalfd.c: fix inconsistent return codes for signalfd4
2020-08-26 10:40:58 +02:00
splice.c
splice: only read in as much information as there is pipe buffer space
2019-12-17 19:56:52 +01:00
stack.c
stat.c
ANDROID: GKI: set vfs-only exports into their own namespace
2020-07-07 18:07:10 +02:00
statfs.c
vfs: Fix EOVERFLOW testing in put_compat_statfs64
2019-10-03 14:21:35 -07:00
super.c
Fix use after free in get_tree_bdev()
2020-05-06 08:15:15 +02:00
sync.c
timerfd.c
timerfd: Prepare for PREEMPT_RT
2019-08-01 20:51:23 +02:00
userfaultfd.c
mm: protect VMA modifications using VMA sequence count
2020-06-09 10:55:00 +05:30
utimes.c
Revert "ANDROID: vfs: Add setattr2 for filesystems with per mount permissions"
2020-05-29 14:48:38 +02:00
xattr.c
This is the 5.4.58 stable release
2020-08-11 18:37:58 +02:00