Received: by 2002:a4a:3008:0:0:0:0:0 with SMTP id q8-v6csp3595485oof; Mon, 10 Sep 2018 17:41:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdabAmARcD5HNoL/Dn7gPLAIVqfiPb84PljkZOOZyM/apFqBghRr6IQ697Pdqt9ALQBpyLas X-Received: by 2002:a17:902:a716:: with SMTP id w22-v6mr24639032plq.334.1536626474383; Mon, 10 Sep 2018 17:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536626474; cv=none; d=google.com; s=arc-20160816; b=BaREV+A+WRJFOl8FSL/0MnOIq36WMOvgbzQwSKLAESqI/Q8QMSSrj6RXL1/+61jlgW sVlnUd+CWqSSQPdaprs7xuywUXHkFA+Xra8cbE67u9QXwkKo9+hcU4vchD3Br7pU6asv mlt8mp9JIaF6jMQ3VxTOz4FBsJ3D1+WFtbSeVmqv31EKDqe6y2g7s2rQGVutnvf5WIMv XLjBZHcWSpTaIsfnc8q2l2ypfFep9sxu8n2ea/xW/DvS6F9bJw+6NOX3wMX39sVfoOmd mQwdScgT0vkrsDDjqoDuZlwMiqGdmjjOzldlCLHukcGMl/Xnl5CgCkV7mQNk1P1CQx0c edIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=6fsiMTK8GBLceRgG5LCpstljI/UyOX3t1B3JZxYZiRI=; b=DU/3jfUIvprJXYM/3eWf2ZyI+XlDUsK2ifnBylZ76dN+ZCS258Ux/6wwJ/yqVCi7Cr t+tv2VPxNwAbVFR1ZvQjCHsrZvsstBLE5IlHnn3uR/UOrtSGRG6joga+jv9V4q/ebWrm bPx/N9E6t3JkrH5DKBVbvGQU5Wmt0kkN2xCdv0Og+Xydf7eWfK1JYfN196OIwz5pON3J Uv1tr8RnWpofgbDi1GhZhF3jAVaaNdA1zENKvUzdNSDS2t2IkAlhX5xqgqAKOSYaCFQe CIQx3qKsSLtGHseraK76TjZLG4hMa+P7oaWj4C+qjsm0/TR2y0fDvZI9082Gh7ERHUAg rr9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FX5Ujg+A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h23-v6si17021613pgv.356.2018.09.10.17.40.58; Mon, 10 Sep 2018 17:41:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FX5Ujg+A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726482AbeIKFg6 (ORCPT + 99 others); Tue, 11 Sep 2018 01:36:58 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33016 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbeIKFg6 (ORCPT ); Tue, 11 Sep 2018 01:36:58 -0400 Received: by mail-pf1-f193.google.com with SMTP id d4-v6so11318933pfn.0 for ; Mon, 10 Sep 2018 17:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=6fsiMTK8GBLceRgG5LCpstljI/UyOX3t1B3JZxYZiRI=; b=FX5Ujg+A+3oDAZjZCq0vcG0/78iEuHazAyozQKV2Ohysqru4pSyCrgJ86ND1PfqfNe dSE+BPbNfxwhb7K0RjLhDwxsMZA2+WPni98KsqPZ7EJYVYhZNTRDlPoFOgCnzUVw99A3 zxtFyqq1+qgxIrPJGkMts4RqE9dOBgy55OvrGuAb5yV+Oz+GbpyskW9nZtcUxseuhyX+ mH/TmNwA/rsqv+s53AaqCmZZ5DQqfKWkBqZlIraRmU7AusprfNXI7LuUH8VKc8c4TSVC D9KjW8KTGAk1UliWMsbummGVVqOu9wAgME282C6o4G1KyULY52fQUo5Fn6WcrNTi1lA/ kj6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=6fsiMTK8GBLceRgG5LCpstljI/UyOX3t1B3JZxYZiRI=; b=oL7o8Uplgb8hQ//BANsdRs7zHx3JnjxKx9OFL3KQWOJ7ivV1ZJiyd2JUsK/kJZ8rdf nq3Y3zN96/taoom248RmeQlZ38+/cRoZPFULssSrDRfolSuc5zmB77Ua5znNgimK893y sNyyG3e6sDA8uUwEuhKu0xi1D7tku79nZmhD3gIqh7eKuO7Jbf+9/EZfqv6BBhZHILo2 r6kKJiQ9ycKxDgfL2z8ghEQqariKxHWbVfCO5oaDwhOKH7LLtAq+jsad7k1SEk4HZxBN yiUdr82/Oercs4svdh6fKjkklPg+XN7ntr+Ta4lJJRVGb8o9d6qhQJnKJpBo2vq1iQKL GHqw== X-Gm-Message-State: APzg51DYKungIzsrzua8RJxZAcikb2L7aftw+T6zB3VA3SrzGTgJ0VuY V3L4wDPGoEDgZqB/OZWCxvjsSA== X-Received: by 2002:a63:3cc:: with SMTP id 195-v6mr24696881pgd.229.1536626421590; Mon, 10 Sep 2018 17:40:21 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id q25-v6sm22899340pfh.113.2018.09.10.17.40.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 17:40:20 -0700 (PDT) Date: Mon, 10 Sep 2018 17:40:20 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Roman Gushchin cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Johannes Weiner , Michal Hocko , Vladimir Davydov Subject: Re: [PATCH RFC] mm: don't raise MEMCG_OOM event due to failed high-order allocation In-Reply-To: <20180910215622.4428-1-guro@fb.com> Message-ID: References: <20180910215622.4428-1-guro@fb.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 Sep 2018, Roman Gushchin wrote: > The memcg OOM killer is never invoked due to a failed high-order > allocation, however the MEMCG_OOM event can be easily raised. > > Under some memory pressure it can happen easily because of a > concurrent allocation. Let's look at try_charge(). Even if we were > able to reclaim enough memory, this check can fail due to a race > with another allocation: > > if (mem_cgroup_margin(mem_over_limit) >= nr_pages) > goto retry; > > For regular pages the following condition will save us from triggering > the OOM: > > if (nr_reclaimed && nr_pages <= (1 << PAGE_ALLOC_COSTLY_ORDER)) > goto retry; > > But for high-order allocation this condition will intentionally fail. > The reason behind is that we'll likely fall to regular pages anyway, > so it's ok and even preferred to return ENOMEM. > > In this case the idea of raising the MEMCG_OOM event looks dubious. > > Fix this by moving MEMCG_OOM raising to mem_cgroup_oom() after > allocation order check, so that the event won't be raised for high > order allocations. > > Signed-off-by: Roman Gushchin > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Vladimir Davydov Acked-by: David Rientjes