Re: [PATCH] mm, oom_adj: avoid meaningless loop to find processes sharing mm
From: Tetsuo Handa
Date: Tue Oct 09 2018 - 08:52:26 EST
On 2018/10/09 20:10, Michal Hocko wrote:
> On Tue 09-10-18 19:00:44, Tetsuo Handa wrote:
>>> 2) add OOM_SCORE_ADJ_MIN and do not kill tasks sharing mm and do not
>>> reap the mm in the rare case of the race.
>>
>> That is no problem. The mistake we made in 4.6 was that we updated oom_score_adj
>> to -1000 (and allowed unprivileged users to OOM-lockup the system).
>
> I do not follow.
>
http://tomoyo.osdn.jp/cgi-bin/lxr/source/mm/oom_kill.c?v=linux-4.6.7#L493
[ 177.722853] a.out invoked oom-killer: gfp_mask=0x24280ca(GFP_HIGHUSER_MOVABLE|__GFP_ZERO), order=0, oom_score_adj=0
[ 177.724956] a.out cpuset=/ mems_allowed=0
[ 177.725735] CPU: 3 PID: 3962 Comm: a.out Not tainted 4.5.0-rc2-next-20160204 #291
(...snipped...)
[ 177.802889] [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
(...snipped...)
[ 177.872248] [ 3941] 1000 3941 28880 124 14 3 0 0 bash
[ 177.874279] [ 3962] 1000 3962 541717 395780 784 6 0 0 a.out
[ 177.876274] [ 3963] 1000 3963 1078 21 7 3 0 1000 a.out
[ 177.878261] [ 3964] 1000 3964 1078 21 7 3 0 1000 a.out
[ 177.880194] [ 3965] 1000 3965 1078 21 7 3 0 1000 a.out
[ 177.882262] Out of memory: Kill process 3963 (a.out) score 998 or sacrifice child
[ 177.884129] Killed process 3963 (a.out) total-vm:4312kB, anon-rss:84kB, file-rss:0kB, shmem-rss:0kB
[ 177.887100] oom_reaper: reaped process :3963 (a.out) anon-rss:0kB, file-rss:0kB, shmem-rss:0lB
[ 179.638399] crond invoked oom-killer: gfp_mask=0x24201ca(GFP_HIGHUSER_MOVABLE|__GFP_COLD), order=0, oom_score_adj=0
[ 179.647708] crond cpuset=/ mems_allowed=0
[ 179.652996] CPU: 3 PID: 742 Comm: crond Not tainted 4.5.0-rc2-next-20160204 #291
(...snipped...)
[ 179.771311] [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
(...snipped...)
[ 179.836221] [ 3941] 1000 3941 28880 124 14 3 0 0 bash
[ 179.838278] [ 3962] 1000 3962 541717 396308 785 6 0 0 a.out
[ 179.840328] [ 3963] 1000 3963 1078 0 7 3 0 -1000 a.out
[ 179.842443] [ 3965] 1000 3965 1078 0 7 3 0 1000 a.out
[ 179.844557] Out of memory: Kill process 3965 (a.out) score 998 or sacrifice child
[ 179.846404] Killed process 3965 (a.out) total-vm:4312kB, anon-rss:0kB, file-rss:0kB, shmem-rss:0kB