From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Hocko Subject: Re: [PATCH memcg 0/1] false global OOM triggered by memcg-limited task Date: Tue, 19 Oct 2021 14:04:22 +0200 Message-ID: References: <9d10df01-0127-fb40-81c3-cc53c9733c3e@virtuozzo.com> <6b751abe-aa52-d1d8-2631-ec471975cc3a@virtuozzo.com> <339ae4b5-6efd-8fc2-33f1-2eb3aee71cb2@virtuozzo.com> <687bf489-f7a7-5604-25c5-0c1a09e0905b@virtuozzo.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634645063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NdT24LAUAutNm+Pih0uGiiR7uabskUxPSt601z67+SE=; b=dOWfISbmKqjKcIIWPDiDT/HKyHQEifgRyk1Fo0q4HIN1Q60TmDn9RjjuHm+hx2KmjFLGUn F3pwhkqN1F8GCRcdeHtMHHE3mJIetVtGbDa69TURkNHoOtBvhk6XoygNxZv7XJfeROztmA qSbPaVR/8FaqXfFtNtuzcnh40mnrmc4= Content-Disposition: inline In-Reply-To: List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Vasily Averin Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Shakeel Butt , Mel Gorman , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, kernel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org On Tue 19-10-21 13:54:42, Michal Hocko wrote: > On Tue 19-10-21 13:30:06, Vasily Averin wrote: > > On 19.10.2021 11:49, Michal Hocko wrote: > > > On Tue 19-10-21 09:30:18, Vasily Averin wrote: > > > [...] > > >> With my patch ("memcg: prohibit unconditional exceeding the limit of dying tasks") try_charge_memcg() can fail: > > >> a) due to fatal signal > > >> b) when mem_cgroup_oom -> mem_cgroup_out_of_memory -> out_of_memory() returns false (when select_bad_process() found nothing) > > >> > > >> To handle a) we can follow to your suggestion and skip excution of out_of_memory() in pagefault_out_of memory() > > >> To handle b) we can go to retry: if mem_cgroup_oom() return OOM_FAILED. > > > > > How is b) possible without current being killed? Do we allow remote > > > charging? > > > > out_of_memory for memcg_oom > > select_bad_process > > mem_cgroup_scan_tasks > > oom_evaluate_task > > oom_badness > > > > /* > > * Do not even consider tasks which are explicitly marked oom > > * unkillable or have been already oom reaped or the are in > > * the middle of vfork > > */ > > adj = (long)p->signal->oom_score_adj; > > if (adj == OOM_SCORE_ADJ_MIN || > > test_bit(MMF_OOM_SKIP, &p->mm->flags) || > > in_vfork(p)) { > > task_unlock(p); > > return LONG_MIN; > > } > > > > This time we handle userspace page fault, so we cannot be kenrel thread, > > and cannot be in_vfork(). > > However task can be marked as oom unkillable, > > i.e. have p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN > > You are right. I am not sure there is a way out of this though. The task > can only retry for ever in this case. There is nothing actionable here. > We cannot kill the task and there is no other way to release the memory. Btw. don't we force the charge in that case? -- Michal Hocko SUSE Labs From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DB6C433EF for ; Tue, 19 Oct 2021 12:04:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F0F0F610E7 for ; Tue, 19 Oct 2021 12:04:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F0F0F610E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 804F96B006C; Tue, 19 Oct 2021 08:04:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78DC56B0071; Tue, 19 Oct 2021 08:04:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60794900002; Tue, 19 Oct 2021 08:04:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 4FCED6B006C for ; Tue, 19 Oct 2021 08:04:25 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03D1339479 for ; Tue, 19 Oct 2021 12:04:25 +0000 (UTC) X-FDA: 78713054490.22.14AA0FB Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf12.hostedemail.com (Postfix) with ESMTP id 88B9210000B3 for ; Tue, 19 Oct 2021 12:04:24 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 541161FCA1; Tue, 19 Oct 2021 12:04:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634645063; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NdT24LAUAutNm+Pih0uGiiR7uabskUxPSt601z67+SE=; b=dOWfISbmKqjKcIIWPDiDT/HKyHQEifgRyk1Fo0q4HIN1Q60TmDn9RjjuHm+hx2KmjFLGUn F3pwhkqN1F8GCRcdeHtMHHE3mJIetVtGbDa69TURkNHoOtBvhk6XoygNxZv7XJfeROztmA qSbPaVR/8FaqXfFtNtuzcnh40mnrmc4= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 21E34A3B83; Tue, 19 Oct 2021 12:04:23 +0000 (UTC) Date: Tue, 19 Oct 2021 14:04:22 +0200 From: Michal Hocko To: Vasily Averin Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Shakeel Butt , Mel Gorman , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH memcg 0/1] false global OOM triggered by memcg-limited task Message-ID: References: <9d10df01-0127-fb40-81c3-cc53c9733c3e@virtuozzo.com> <6b751abe-aa52-d1d8-2631-ec471975cc3a@virtuozzo.com> <339ae4b5-6efd-8fc2-33f1-2eb3aee71cb2@virtuozzo.com> <687bf489-f7a7-5604-25c5-0c1a09e0905b@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 88B9210000B3 X-Stat-Signature: qiccp4fnfgfaj6m5mnpahgi4a35wh15k Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=dOWfISbm; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf12.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com X-Rspamd-Server: rspam02 X-HE-Tag: 1634645064-838924 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue 19-10-21 13:54:42, Michal Hocko wrote: > On Tue 19-10-21 13:30:06, Vasily Averin wrote: > > On 19.10.2021 11:49, Michal Hocko wrote: > > > On Tue 19-10-21 09:30:18, Vasily Averin wrote: > > > [...] > > >> With my patch ("memcg: prohibit unconditional exceeding the limit of dying tasks") try_charge_memcg() can fail: > > >> a) due to fatal signal > > >> b) when mem_cgroup_oom -> mem_cgroup_out_of_memory -> out_of_memory() returns false (when select_bad_process() found nothing) > > >> > > >> To handle a) we can follow to your suggestion and skip excution of out_of_memory() in pagefault_out_of memory() > > >> To handle b) we can go to retry: if mem_cgroup_oom() return OOM_FAILED. > > > > > How is b) possible without current being killed? Do we allow remote > > > charging? > > > > out_of_memory for memcg_oom > > select_bad_process > > mem_cgroup_scan_tasks > > oom_evaluate_task > > oom_badness > > > > /* > > * Do not even consider tasks which are explicitly marked oom > > * unkillable or have been already oom reaped or the are in > > * the middle of vfork > > */ > > adj = (long)p->signal->oom_score_adj; > > if (adj == OOM_SCORE_ADJ_MIN || > > test_bit(MMF_OOM_SKIP, &p->mm->flags) || > > in_vfork(p)) { > > task_unlock(p); > > return LONG_MIN; > > } > > > > This time we handle userspace page fault, so we cannot be kenrel thread, > > and cannot be in_vfork(). > > However task can be marked as oom unkillable, > > i.e. have p->signal->oom_score_adj == OOM_SCORE_ADJ_MIN > > You are right. I am not sure there is a way out of this though. The task > can only retry for ever in this case. There is nothing actionable here. > We cannot kill the task and there is no other way to release the memory. Btw. don't we force the charge in that case? -- Michal Hocko SUSE Labs