Received: by 10.213.65.68 with SMTP id h4csp121452imn; Wed, 21 Mar 2018 14:01:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELsOo49B2fZgJfMAsyhCZSPmt+8AoLKzFVTSRnb9Xe2CT1qvjTUxYyO24y41iWrWn/Af6Nz1 X-Received: by 10.99.106.68 with SMTP id f65mr15899879pgc.343.1521666093846; Wed, 21 Mar 2018 14:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521666093; cv=none; d=google.com; s=arc-20160816; b=UNEvIhQHt57emET5S/fGNerO9ttMwNHYdNbLpTWD56+lG0wafVYQluhnqScw0ms3np s4g0wmYm/gojMDE6qgRhQXQIMEZ7kJR4/0mGAsor+kN9QXWqW0DJ6odSeD15VRJ7jO17 MTk6Gq8InMUlnWszz4Q++skS+YYdbIvbsW+Y9AqbjRBqmRZ7C/c+dKI3wmR1YJqAdfGN T6NERiP1QYxYY7pd2SVkPQccXkFa9Bfxv1mOO5TbubSCfo2WGJFGKQjWQGoMx8PTi72r lFvIzWPAw9gVSvgq06OFaZpBixAjW3XT+7uNJBckbnzztKLyKK+JO4YYDe3nkAkv5y4b bqbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7/oeDmU8fmhHti7vBQHuYA3F3KG00ANzI33N9XlHTHs=; b=YxZ57hry1NqDGxuurOfOHQEEGWAljacItSaNvUV64Rg+FS8gL95dG8YVkD20zjNvB6 stwt42ZtWm1SooKWhRWO1Dld9ivH1CawTfsBYwHdLWmu3coZVJU296hkeskwTotQGc7T YklWW58UENFqhtJZmFoepDNyh8FEW8e3QNhS6oAPH4RxkVKxV1AN2HR64BkDiPv0/YBF NrTwxDLItemClATrABwksyqMqdZOHG8jgPOKPHx3/jj5WP7rsvb+XKPLsd1DH3Ju+Uut sfjkftYIdLA0aZkLiPyn+aQmju36xicrqfUSND6lWH68wQLYPLBn6WyRghiF+TSbv+Q6 MAQA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o187si3285218pga.528.2018.03.21.14.01.15; Wed, 21 Mar 2018 14:01:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753433AbeCUU7x (ORCPT + 99 others); Wed, 21 Mar 2018 16:59:53 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36596 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753210AbeCUU7v (ORCPT ); Wed, 21 Mar 2018 16:59:51 -0400 Received: by mail-wm0-f67.google.com with SMTP id x82so12301556wmg.1 for ; Wed, 21 Mar 2018 13:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7/oeDmU8fmhHti7vBQHuYA3F3KG00ANzI33N9XlHTHs=; b=YcwCXBc4p6g+e/QbhPR+qO4Z3RML3yKiAnfiVbsdBSprBpLBBXOykIzVqtqS7RJfUj lUKBFMUOyh4BYr1Sfd65QiiOvrqmjXghNvqXfrxeRawJRPffFzyYyM3r45SRgI7c8un/ oiy8IOs5YkJzTNWz9eNiZQmVEvAr55LfYLX+ufJu4owe+v/LqhYn6A7IuDRqXrwce2K0 NEzpPqaq4dcpqOMhVdogh7gRF4aCSvD4YYMObGX79EnX4pmOPHUAhUHLeMdkxAPkEJ0H XDPUs6FQJ+t+GWHqgH7Cittao0OD94blNmQ9W5u8z/s61TQhddxuuaye+O9NJBeo53G4 AdpQ== X-Gm-Message-State: AElRT7GFbRTPGNi7onJwb16IBdSg/Jh+0+DOE43BfiunwEniQbgGvbqe Jr0HdxBu0br9eidTnvc7i08= X-Received: by 10.28.101.6 with SMTP id z6mr3315176wmb.110.1521665990317; Wed, 21 Mar 2018 13:59:50 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-225-246.eurotel.cz. [37.188.225.246]) by smtp.gmail.com with ESMTPSA id 142sm5825734wmq.47.2018.03.21.13.59.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 13:59:48 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: Johannes Weiner , David Rientjes , "Kirill A. Shutemov" , Vlastimil Babka , , LKML , Michal Hocko Subject: [PATCH] memcg, thp: do not invoke oom killer on thp charges Date: Wed, 21 Mar 2018 21:59:28 +0100 Message-Id: <20180321205928.22240-1-mhocko@kernel.org> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko David has noticed that THP memcg charge can trigger the oom killer since 2516035499b9 ("mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations"). We have used an explicit __GFP_NORETRY previously which ruled the OOM killer automagically. Memcg charge path should be semantically compliant with the allocation path and that means that if we do not trigger the OOM killer for costly orders which should do the same in the memcg charge path as well. Otherwise we are forcing callers to distinguish the two and use different gfp masks which is both non-intuitive and bug prone. Not to mention the maintenance burden. Teach mem_cgroup_oom to bail out on costly order requests to fix the THP issue as well as any other costly OOM eligible allocations to be added in future. Fixes: 2516035499b9 ("mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations") Reported-by: David Rientjes Signed-off-by: Michal Hocko --- Hi, this is an alternative patch to [1]. I strongly believe that using different gfp masks for the allocation and memcg charging is to be avoided as much as possible. There doesn't seem to be any good reason why THP charges should be an exception here. I would be tempted to mark this for stable even though we haven't seen any unexpected memcg OOM killer reports since 4.8 which is quite some time. [1] http://lkml.kernel.org/r/alpine.DEB.2.20.1803191409420.124411@chino.kir.corp.google.com mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d1a917b5b7b7..08accbcd1a18 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1493,7 +1493,7 @@ static void memcg_oom_recover(struct mem_cgroup *memcg) static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) { - if (!current->memcg_may_oom) + if (!current->memcg_may_oom || order > PAGE_ALLOC_COSTLY_ORDER) return; /* * We are in the middle of the charge context here, so we -- 2.16.2