Received: by 10.213.65.68 with SMTP id h4csp3823099imn; Tue, 3 Apr 2018 11:12:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/nplEpB2n3nUMnLKhIhS1DvqUybA4F1D0hcz1TW/EKPtbKmomH4wfPHnEgrskIwTBgXvJh X-Received: by 2002:a17:902:a612:: with SMTP id u18-v6mr15234955plq.10.1522779129686; Tue, 03 Apr 2018 11:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522779129; cv=none; d=google.com; s=arc-20160816; b=ONDjL2s0F7vnn28DLZ/F9V891GytsLGzGiv1u/6oh7Td7DEswZVXdJLbjtun5SnJJE 43pYBL8fJNE/eigHhL0y796mc4Gt29EUAru8fefwUL8B7KZEDjVoC6CWDx8r6VR9JANn HnEX8hMOwUtIpSspNntlBHmIzoQZA3TGoKTEYxwx+6zMQ1+W6Uf2pxg7kpnM4qtIaaQ8 RA0qSIO5IjS+ZVsn2j5U55j8lZLIKVonwmF1OdZch8pcV7HGeEoqTwNPhK0mvM/JrBMg WuJGAcQpRgRDqNNueQVkP555yqvfV4Y82CjqyCZe/2fZtqrpGoe7tbrR0eDwbkhRzmED 2J0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=W3YmsohFtF0xujXPcagf+5zSod17rRSiklA0vFM8LZU=; b=Ujgcw5lPQfPspnSZR9nspKo80M3MJ0TfRMVCwtDOiNH7ANsC28cIUMkEQ0rnHB/1zj yiQdDrOq8HLoe5+p6zPvcoAzsXkj8rpRXCOPKd9QL20vgYR+30DI757VG0NPe/H4hrbJ rOViBDR0bK+xL3zHTG509ig+wxey/wx2jHJV5Eqcu88dk0PjA6rS1owtoQmlmCynIP0y 4rAUpx01dXII3Akxc69cQGkSrjd5tg/0lAzCA4/RbhzgGYGa6asm5bZO4II4ZDQiEmDC VUymJPKolaELJhvE3avk9SuJvJncVfpFnPFHPVc2bLxV8QHmKOf9EMsLNbttmBTDjIXL ytmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@cmpxchg.org header.s=x header.b=hK/+x8Xm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si2388802pgc.381.2018.04.03.11.11.55; Tue, 03 Apr 2018 11:12:09 -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=fail header.i=@cmpxchg.org header.s=x header.b=hK/+x8Xm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751974AbeDCSKm (ORCPT + 99 others); Tue, 3 Apr 2018 14:10:42 -0400 Received: from gum.cmpxchg.org ([85.214.110.215]:49864 "EHLO gum.cmpxchg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbeDCSKl (ORCPT ); Tue, 3 Apr 2018 14:10:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cmpxchg.org ; s=x; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject: Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=W3YmsohFtF0xujXPcagf+5zSod17rRSiklA0vFM8LZU=; b=hK/+x8XmCREEjm+8xepf+0FfsK 6t/6OvB+w7pyIV2s2AS2AtY1rhy9TuF6Q9lwjAWNm8EqE2sdsvumoKT01K2msjVq2SFGuHCJSMf2Y BBvXX14M1iDg00+sB7sUjXiIflsCEuTZf66Ox2e505N1jlyAf1YOUIsTCgU7hA4zUYpk=; Date: Tue, 3 Apr 2018 14:11:57 -0400 From: Johannes Weiner To: Michal Hocko Cc: Andrew Morton , David Rientjes , "Kirill A. Shutemov" , Vlastimil Babka , linux-mm@kvack.org, LKML Subject: Re: [PATCH] memcg, thp: do not invoke oom killer on thp charges Message-ID: <20180403181157.GA23560@cmpxchg.org> References: <20180321205928.22240-1-mhocko@kernel.org> <20180403145853.GB21411@cmpxchg.org> <20180403155509.GD5501@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180403155509.GD5501@dhcp22.suse.cz> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 03, 2018 at 05:55:09PM +0200, Michal Hocko wrote: > On Tue 03-04-18 10:58:53, Johannes Weiner wrote: > > On Wed, Mar 21, 2018 at 09:59:28PM +0100, Michal Hocko wrote: > > > 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 > > > > I also prefer this fix over having separate OOM behaviors (which is > > user-visible, and not just about technical ability to satisfy the > > allocation) between the allocator and memcg. > > > > Acked-by: Johannes Weiner > > I will repost the patch with the currently merged THP specific handling > reverted (see below). While 9d3c3354bb85 might have been an appropriate > quick fix, we shouldn't keep it longterm for 4.17+ IMHO. > > Does you ack apply to that patch as well? Yep, looks good to me. > From: Michal Hocko > Date: Wed, 21 Mar 2018 10:10:37 +0100 > Subject: [PATCH] memcg, thp: do not invoke oom killer on thp charges > > 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. As soon > as we get a costly high order kmalloc user we even do not have any means > to tell the memcg specific gfp mask to prevent from OOM because the > charging is deep within guts of the slab allocator. > > The unexpected memcg OOM on THP has already been fixed upstream by > 9d3c3354bb85 ("mm, thp: do not cause memcg oom for thp") but this is > one-off fix rather than a generic solution. 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. > > Also revert 9d3c3354bb85 because special gfp for THP is no longer > needed. > > Fixes: 2516035499b9 ("mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations") > Reported-by: David Rientjes > Signed-off-by: Michal Hocko Acked-by: Johannes Weiner