Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1483147pxb; Wed, 20 Oct 2021 06:07:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwakQXFOWvfVhDDaKeM1H8Exp0fUP1XRgsNPcEOLGY4G5j5+AB+6En/CRTxvCg1pCz0vl4 X-Received: by 2002:a19:7506:: with SMTP id y6mr12305056lfe.31.1634735269104; Wed, 20 Oct 2021 06:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634735269; cv=none; d=google.com; s=arc-20160816; b=RL6I02SWhcooV/BL4Iedq8ffUajhrFcD8uMVvy1nUdIhtvrbO6wEKAu6/xBS75U/Q7 Fmlt/ldEEFlA6qDrdvI+FFSRei6YUwcFgKnnoY7bcDDDm025yIVFjzGAlrO+qno8E+1h CLfJ+r3Mb/y1BtfbFeipKhmTvxAx8ySg9qHlMO8FUMJdPrzc9e9cuWQHog4wa/Q+vKN5 UYl1diMS7FMKDU6s5oFP8e9A1NRvwNioUB79n+RH1ETx5oL4uGHTYm3Kb3fZnwJIJ6xE G0RUMQqzRVhd1Zdfujj7DDm8I3Tg1O2f03CdCsQmmSVZ0alku/gvI67i37Ex6JXK+QyW pC8w== 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=lHtiz45zVS7aEG3jw5dxC6PErBuqUS5lB4tXnXaQ6pg=; b=VmRpU6x4UKkPZyZcFSkzaYL2r05oGIzE7XFVf58rocNHenfVWJzYmXA0tNmPYpOCxy Rsna/JLi74i0fFpD8i+yuVNl4c2VZR7s5oc1VpFDir44Yi+oIG12PuXjr2o9EfuraDN5 5kLAtjMHzC5em5GQuDRRwhosFryM+n15R7fMY69Xl9Xq56Yn3MhAiFjkd4xAzuMR3a+2 UoxnPqgWVXf9CR6kB1MKd7VMjnx3S3dWQLQVJ1UTKHBujC6Na3wx7KH9rc6raJ+5Y0o6 MGTMjxYsGssPUqeEnj9+wH5aSRrHGt2Vu7A8DCuASmXuzh4jOnwW44HDckLVutzsZkJi NkEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="Y/I+Ce5a"; 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 5si3324914ejq.512.2021.10.20.06.07.23; Wed, 20 Oct 2021 06:07:49 -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="Y/I+Ce5a"; 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 S230164AbhJTNEf (ORCPT + 99 others); Wed, 20 Oct 2021 09:04:35 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:46044 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229817AbhJTNEf (ORCPT ); Wed, 20 Oct 2021 09:04:35 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id E60D121A87; Wed, 20 Oct 2021 13:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1634734939; 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=lHtiz45zVS7aEG3jw5dxC6PErBuqUS5lB4tXnXaQ6pg=; b=Y/I+Ce5axakhGBIRNKOegdQVHdI4YzYHQEIpdgO0UXNG8VzJ/LYJYwmJOdM6opVpOjv+9L FEfoascr1IWjpMCUhwxtd/BXj4wwJxLQ7Usqx/t/XNvQuA+jG11qL34rmbcJrfJoSQZlqL aCmzO/x/CQnYKUqQcQQjTuPUiYqW6QY= 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 96830A3B81; Wed, 20 Oct 2021 13:02:19 +0000 (UTC) Date: Wed, 20 Oct 2021 15:02:19 +0200 From: Michal Hocko To: Vasily Averin Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Roman Gushchin , Uladzislau Rezki , Vlastimil Babka , Shakeel Butt , Mel Gorman , Tetsuo Handa , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@openvz.org Subject: Re: [PATCH memcg 3/3] memcg: handle memcg oom failures 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 Wed 20-10-21 15:14:27, Vasily Averin wrote: > mem_cgroup_oom() can fail if current task was marked unkillable > and oom killer cannot find any victim. > > Currently we force memcg charge for such allocations, > however it allow memcg-limited userspace task in to overuse assigned limits > and potentially trigger the global memory shortage. You should really go into more details whether that is a practical problem to handle. OOM_FAILED means that the memcg oom killer couldn't find any oom victim so it cannot help with a forward progress. There are not that many situations when that can happen. Naming that would be really useful. > Let's fail the memory charge in such cases. > > This failure should be somehow recognised in #PF context, explain why > so let's use current->memcg_in_oom == (struct mem_cgroup *)OOM_FAILED > > ToDo: what is the best way to notify pagefault_out_of_memory() about > mem_cgroup_out_of_memory failure ? why don't you simply remove out_of_memory from pagefault_out_of_memory and leave it only with the blocking memcg OOM handling? Wouldn't that be a more generic solution? Your first patch already goes that way partially. This change is more risky than the first one. If somebody returns VM_FAULT_OOM without invoking allocator then it can loop for ever but invoking OOM killer in such a situation is equally wrong as the oom killer cannot really help, right? -- Michal Hocko SUSE Labs