Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp77309pxb; Mon, 25 Oct 2021 04:16:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRlB4tqmqNCR+ufmnetOvrPJA/ERjn2AUGI06kC3DWixtL77wh4v341VMjxzy6pKqBP0/2 X-Received: by 2002:aa7:c0d2:: with SMTP id j18mr3213601edp.149.1635160570109; Mon, 25 Oct 2021 04:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635160570; cv=none; d=google.com; s=arc-20160816; b=aQ3snwjmUjlNOhFzDlx3/6n7iNyESQCcKV5NOy7QQKWmfH6F6BVyb1DeydVE6yMqzJ RfzFyDlCGuLXTC/XXbfCHW4vTsev8SsK9l9lfNj2KN/dseeRn0WHrESS8V6R4+LiI8Ma 2cdo9Vbp5cybHbEoI5yZjTR0gDw0O8r4Z5Dw6qdBueP5ytDrgg5ceGSO7GXEqgOnVxTY rz51XEs4TL5lCjolH/jVjUKNeaF/wSYL9NqqLE1KjtPDSTj9A4VSvpQa6fx7FkgGtrWz +tH4UYUlmjdtYUkCP6zsQ0vp8wopVjpfma65Ql31BUa/frPnw2FXIqmodCSV2210N/tr x8pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l21SlX/9kh43Ic37AW53KRYg/QWXqmopDdPfmAH/kdc=; b=Kmp3OtCIdpBEraP+RmtOQn3b7j/YghoxJuD6LRRNp2e2z8YTsmWTMpH9i6nwQGe+cR BO/E1lGb6myD4ZW53ryHhLGgX5TPrhO28qdY+JoUirRPduf/UgGLvXaD2VpdWqFwvi8M RFYGt1JAgkYeaxbCvAn89wWkhh7P0MSkZKZ+y22L48yFTD8diOx4WdfHLV18bpLrDFhR J9aaKlFyi7rp8YDSBieh9EzarkvorMOQ7hoAW97qMeMj2c3nu141wUizwT94m3AFix0p cKaHUiqC4OwBq2LMZuogwr01+ucMe30e47lxzR6N1zBZCu0XGmQBSB0rJGEesizMmIN3 Tntg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eMrOCgSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qk12si1454694ejc.631.2021.10.25.04.15.42; Mon, 25 Oct 2021 04:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=eMrOCgSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230180AbhJYIG3 (ORCPT + 99 others); Mon, 25 Oct 2021 04:06:29 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:45486 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbhJYIG2 (ORCPT ); Mon, 25 Oct 2021 04:06:28 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AC29C1FD34; Mon, 25 Oct 2021 08:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1635149045; 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=l21SlX/9kh43Ic37AW53KRYg/QWXqmopDdPfmAH/kdc=; b=eMrOCgSaFdI3lzR7WkVsSne/0Whu14mXXOGHTE5EXC7LHFchVV5T3UBKFzMCbaDaY613w1 ikdq4RNXE7zyGDMnT3jKdP2gKvt6jH33g8ZZPjWfjj8njf3MaNH5I51wDnqQYTCASz7FRd r6Jz1WJWiRfnNmBh7Dku+xmZFCp0kl0= 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 09D93A3B81; Mon, 25 Oct 2021 08:04:04 +0000 (UTC) Date: Mon, 25 Oct 2021 10:04:04 +0200 From: Michal Hocko To: Tetsuo Handa Cc: Vasily Averin , 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, Johannes Weiner , Vladimir Davydov , Andrew Morton Subject: Re: [PATCH memcg v3 2/3] mm, oom: do not trigger out_of_memory from the #PF Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 24-10-21 00:01:07, Tetsuo Handa wrote: > On 2021/10/23 22:20, Vasily Averin wrote: > > /* > > - * The pagefault handler calls here because it is out of memory, so kill a > > - * memory-hogging task. If oom_lock is held by somebody else, a parallel oom > > - * killing is already in progress so do nothing. > > + * The pagefault handler calls here because some allocation has failed. We have > > + * to take care of the memcg OOM here because this is the only safe context without > > + * any locks held but let the oom killer triggered from the allocation context care > > + * about the global OOM. > > */ > > Excuse me for a stupid question. I consider > > if (!mutex_trylock(&oom_lock)) > return; > out_of_memory(&oc); > mutex_unlock(&oom_lock); > > here as the last resort (safeguard) when neither __alloc_pages_may_oom() > nor mem_cgroup_out_of_memory() can make progress. This patch says > > let the oom killer triggered from the allocation context care > about the global OOM. > > but what if the OOM killer cannot be invoked from the allocation context? > Is there a guarantee that all memory allocations which might result in > VM_FAULT_OOM can invoke the OOM killer? I do not think there is any guarantee. This code has meant to be a safeguard but it turns out to be adding more harm than a safety. There are several scenarios mentioned in this thread where this would be counter productive or outright wrong thing to do. On the other hand it is hard to imagine any legitimate situation where this would be a right thing to do. Maybe you have something more specific in mind? What would be the legit code to rely on OOM handling out of the line (where the details about the allocation scope is lost)? -- Michal Hocko SUSE Labs