On Tue 23-08-16 11:06:55, Michal Hocko wrote: > On Tue 23-08-16 09:55:55, Michal Hocko wrote: > > On Tue 23-08-16 00:01:23, Michael S. Tsirkin wrote: > > [...] > > > Actually, vhost net calls out to tun which does regular copy_from_iter. > > > Returning 0 there will cause corrupted packets in the network: not a > > > huge deal, but ugly. And I don't think we want to annotate run and > > > macvtap as well. > > > > Hmm, OK, I wasn't aware of that path and being consistent here matters. > > If the vhost driver can interact with other subsystems then there is > > really no other option than hooking into the page fault path. Ohh well. > > Here is a completely untested patch just for sanity check. OK, so I've tested the patch and it seems to work as expected. I didn't know how to configure vhost so I've just hacked up a quick kernel thread which picks on a task (I am always selecting a first task which is the OOM_SCORE_ADJ_MAX because that would be the selected victim - see the code attached) and then read through its address space in a loop. The oom victim then just mmaps and poppulates a private anon mapping which causes the oom killer. It properly notices that the memor could have been reaped. [ 628.559374] Out of memory: Kill process 3193 (oom_victim) score 1868 or sacrifice child [ 628.561713] Killed process 3193 (oom_victim) total-vm:1052540kB, anon-rss:782964kB, file-rss:12kB, shmem-rss:0kB [ 628.568120] Found a dead vma: ret:-14vma ffff88003c697000 start 00007f9227b33000 end 00007f9267b33000 next ffff88003d80d8a0 prev ffff88003d80d228 mm ffff88003d97b200 prot 8000000000000025 anon_vma ffff88003dbbc000 vm_ops (null) pgoff 7f9227b33 file (null) private_data (null) flags: 0x100073(read|write|mayread|maywrite|mayexec|account) [ 628.595684] oom_reaper: reaped process 3193 (oom_victim), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB [ 673.366282] Waiting for kthread to stop [ 673.367487] Done Are there any objections or suggestions to the apporach? -- Michal Hocko SUSE Labs