Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2950688ybg; Thu, 24 Oct 2019 18:31:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQk7dIribQ7y+hdBUpVG0vn7GgvtSCdUw+O8xQjA1SekduL5W5ZitzlTY9cZkX9+HgvpmY X-Received: by 2002:a17:906:19cf:: with SMTP id h15mr1107103ejd.184.1571967063214; Thu, 24 Oct 2019 18:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571967063; cv=none; d=google.com; s=arc-20160816; b=0R23l38HUKjHw/uOmUa3qNPZBN4Jj0hnOGZNWXPmd+/a6qKEqyZpW79OIsMbPJD7G5 /gid3XfsjnPj6Z4Mue8NygpJ/C6d2TRvYV9umU+DfxddU+RwI9HXi1iJLzbAOxo6ip6b oOrH8V3+5T/VhC9umVRqnZ2Ll48mhyt/c7n4coc90Q7ElHk6z5PAP4JTBIwjVvdPf0FA N/PCA0lEM3sVuJTrvD1R6NUUufFE2GMQvtxmHXje53fzcfL1E1fpZjXSt4n0YHl4Eu8U PhoBrzLP8JjJOIpgqm0vo0r7pOCuuicWYVj3y4ZOaA/5fQD9uaP0N7st/tMCfCbzc4BA 7rcw== 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; bh=IzcCFkzMIilamlQtV78ozgtYH+LTb6rEpEQEI3M9bEQ=; b=O+SR3Y8PUnmkHo9+9Eh0Q2ZTnZbcTFWEX8jbCiMvfDiItqzTWglEJXPTshjJI2HqZU Eah1Mh/ceeW4LhD38p7BTSDjrmV8nNsmvt288f2IzEt2qsKVN4qaAqIYQDoHSU49igWS cjnff3RQ92Q0VAiebXi2mCyFqX3nAJQVgXKGrITHVWPWoIinmOLvSf0iT5pQYimEs7he dwcCej/eh+PwvBHoDD1utgrlw+Qi4ikHWcZu6+0g7Cz7n6Cm6TKcRPQWtDzP83rQ11L6 VRlD2HyPvWzHk4eVlXNQoO3yVp9XDGPjPGJQjcD8q0Yyu64zc9OAvUQnXij+P+/o1/5V Nbmg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gj13si313746ejb.224.2019.10.24.18.30.39; Thu, 24 Oct 2019 18:31:03 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438052AbfJXIOt (ORCPT + 99 others); Thu, 24 Oct 2019 04:14:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:54914 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726395AbfJXIOs (ORCPT ); Thu, 24 Oct 2019 04:14:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 271B5B5F6; Thu, 24 Oct 2019 08:14:46 +0000 (UTC) Date: Thu, 24 Oct 2019 10:14:45 +0200 From: Michal Hocko To: Johannes Weiner Cc: Shakeel Butt , Andrew Morton , Linux MM , LKML , Cgroups , netdev@vger.kernel.org, Kernel Team Subject: Re: [PATCH] mm: memcontrol: fix network errors from failing __GFP_ATOMIC charges Message-ID: <20191024081445.GR17610@dhcp22.suse.cz> References: <20191022233708.365764-1-hannes@cmpxchg.org> <20191023064012.GB754@dhcp22.suse.cz> <20191023154618.GA366316@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 23-10-19 10:38:36, Shakeel Butt wrote: > On Wed, Oct 23, 2019 at 8:46 AM Johannes Weiner wrote: > > > > On Wed, Oct 23, 2019 at 08:40:12AM +0200, Michal Hocko wrote: [...] > > > On the other hand this would allow to break the isolation by an > > > unpredictable amount. Should we put a simple cap on how much we can go > > > over the limit. If the memcg limit reclaim is not able to keep up with > > > those overflows then even __GFP_ATOMIC allocations have to fail. What do > > > you think? > > > > I don't expect a big overrun in practice, and it appears that Google > > has been letting even NOWAIT allocations pass through without > > isolation issues. > > We have been overcharging for __GFP_HIGH allocations for couple of > years and see no isolation issues in the production. > > > Likewise, we have been force-charging the skmem for > > a while now and it hasn't been an issue for reclaim to keep up. > > > > My experience from production is that it's a whole lot easier to debug > > something like a memory.max overrun than it is to debug a machine that > > won't respond to networking. So that's the side I would err on. It is definitely good to hear that your production systems are working well. I was not really worried about normal workloads but rather malicious kind of (work)loads where memcg is used to contain a potentially untrusted entities. That's where an unbounded atomic charges escapes would be a much bigger deal. Maybe this is not the case now because we do not have that many accounted __GFP_ATOMIC requests (I have tried to audit but gave up very shortly afterwards because there are not that many using __GFP_ACCOUNT directly so they are likely hidden behind SLAB_ACCOUNT). But I do not really like that uncertainty. If you have a really strong opinion on an explicit limit then I would like to see at least some warning to the kernel log so that we learn when some workloads hit a pathological paths that and act upon that. Does that sound like something you would agree to? E.g. something like diff --git a/mm/page_counter.c b/mm/page_counter.c index de31470655f6..e6999f6cf79e 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c @@ -62,6 +62,8 @@ void page_counter_cancel(struct page_counter *counter, unsigned long nr_pages) WARN_ON_ONCE(new < 0); } +#define SAFE_OVERFLOW 1024 + /** * page_counter_charge - hierarchically charge pages * @counter: counter @@ -82,8 +84,14 @@ void page_counter_charge(struct page_counter *counter, unsigned long nr_pages) * This is indeed racy, but we can live with some * inaccuracy in the watermark. */ - if (new > c->watermark) + if (new > c->watermark) { c->watermark = new; + if (new > c->max + SAFE_OVERFLOW) { + pr_warn("Max limit %lu breached, usage:%lu. Please report.\n", + c->max, atomic_long_read(&c->usage); + dump_stack(); + } + } } } -- Michal Hocko SUSE Labs