Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1906114ybg; Thu, 24 Oct 2019 01:51:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqweP/H11rjG2iMLTl7YeaLRPjEoKDZCheQ55i6SqN9IG7R4Niz6/PxmZhBCJBgYk7TO06DW X-Received: by 2002:a17:906:7f94:: with SMTP id f20mr13391514ejr.333.1571907063398; Thu, 24 Oct 2019 01:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571907063; cv=none; d=google.com; s=arc-20160816; b=ghgoK6etuCWUbtMh9It/8C4nwBtnX5Bj8VCGTlpNzPzDUwAc8qGu61lzYDl5FCjFkW Zld+dpNYOg7yuMRiP7Q+GIOob/CYCj5BLZxUyAv+1T7erOhUL7TLUZLjR5L5LHOGF71T VdHBDymPEatHGjljipSOZfMs06jiTPBz+WOXpo6RDqnLwLJBdxS91iM4C2sJovrLCLB/ 45tve762t6g+OZjjbnlppVxegF6K0nm0yP1DRK+TI6lWfjg1YgvZx34wPXV8J2QSgPZt KBzuf4WOH8/KEbp5yDZHrTsdNbnoJfH7SJG+7CxyPwJr/JjUZe8TgG4n4jgEpeACwh/D 0Jzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6Bi+2W5kUDlO+k7pkd4SMkD58ATKfCEmQGZr4H+xJPM=; b=0b8gSC9CL8CyvHp1GtbAVpPyJ4WXCCRKDRCd98Aw/XskBhTf+1jhVArvBbOYJArlOh iv1dasrHeMJwIqwjPNEiMn2xlBPnyfw3PM8RayLKuN0ZirMACnY0zW8f2rWbKc4W9gET vIMaKrI9Zlmv55vCiC2/NiblyOpQFKC2AKF1+vN6h4Ho1VBvCMzC4Np/SG42xArZE5l0 TfHpjoCfHlVnpvUrZAHAPRZA/8AVQzT0B3MEsqftz0dHrz1ut7FXeTxTrd707whljE/O zzGk6iCpF4sdaZnFg2tAWgXeYwQt/R7gPlW8IFhch1dhwRImaZxNdytaLFNukjAXMDFJ 6AGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TQaMD3J9; 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 i12si16406055edb.133.2019.10.24.01.50.38; Thu, 24 Oct 2019 01:51: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; dkim=pass header.i=@google.com header.s=20161025 header.b=TQaMD3J9; 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 S1731062AbfJWRiw (ORCPT + 99 others); Wed, 23 Oct 2019 13:38:52 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:40536 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729203AbfJWRiv (ORCPT ); Wed, 23 Oct 2019 13:38:51 -0400 Received: by mail-yw1-f65.google.com with SMTP id a67so4038437ywg.7 for ; Wed, 23 Oct 2019 10:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6Bi+2W5kUDlO+k7pkd4SMkD58ATKfCEmQGZr4H+xJPM=; b=TQaMD3J9qnPc1FpDhFyVtjUhTMNNL4eoGM/FFuzByySHDayFX7hlHjG3Fz9+1iXoj7 OSLk63Z/3xqGbK5iWLOlBWZbCUQuMQLd62BFVUDDoOU93XB2PoCXJz+ObFhAkKauKZAR TEz2N1dDaGIwXJQJDQiIYriWtcMGAGJ3nvhlpLrHsISm0OcAK5PjeW7T9sXbWavkFXLX AbtGBs1jBnuyKV+DuHRbSfzxcdmZazlES7VYzWzxljxEXcmAsIOOaizkMbz5O8x7HK1y 36q1UaANoHSvv55XmitjKLEvggWvdQ4/OUwWQhg+HGzZRs0wJqlP+wH9fwcNpRtRAPjR A70w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6Bi+2W5kUDlO+k7pkd4SMkD58ATKfCEmQGZr4H+xJPM=; b=H+cA4tlrB3VQMYQzaMAGuBusPy8yFC9s8xB6rWVZUX7rMzdTiNXzqiWu9mFqyhgh6n Q9G2QPJsVckffytLmb6zAxAa9I4pFZPTe+0qF1KTq+t8IW7ZqWiLSQ9KFdFdVOyNPEHP j+8OPlVhoAHagbtTged0pJ8GpJZTi58QAFhx5RxryybQCQs99RLyBZoUJrouBkPUPa2n v8zFsnTdA/67E5NfaAhy6UwAFqfqCTHqVtSmIZlQaZzlm24f2TbjU5vZVWaeh2/COqPo oyrVpXvmk2shcLPlHRwcZ346WSdiphmWw2fC+OqXR4L8yY3Olj+UeierMpohzoi8AJXw QmGQ== X-Gm-Message-State: APjAAAWYsUhKIirTJN/VnECRdUfSCX+teAdPb2c8ZSIe9S4P9jRlvDIc oGWTJEkOZZm9WDdPScL0avoCaZkObTR3apVlWKWIc1pN X-Received: by 2002:a81:1189:: with SMTP id 131mr3897888ywr.308.1571852328225; Wed, 23 Oct 2019 10:38:48 -0700 (PDT) MIME-Version: 1.0 References: <20191022233708.365764-1-hannes@cmpxchg.org> <20191023064012.GB754@dhcp22.suse.cz> <20191023154618.GA366316@cmpxchg.org> In-Reply-To: <20191023154618.GA366316@cmpxchg.org> From: Shakeel Butt Date: Wed, 23 Oct 2019 10:38:36 -0700 Message-ID: Subject: Re: [PATCH] mm: memcontrol: fix network errors from failing __GFP_ATOMIC charges To: Johannes Weiner Cc: Michal Hocko , Andrew Morton , Linux MM , LKML , Cgroups , netdev@vger.kernel.org, Kernel Team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tue 22-10-19 19:37:08, Johannes Weiner wrote: > > > While upgrading from 4.16 to 5.2, we noticed these allocation errors > > > in the log of the new kernel: > > > > > > [ 8642.253395] SLUB: Unable to allocate memory on node -1, gfp=0xa20(GFP_ATOMIC) > > > [ 8642.269170] cache: tw_sock_TCPv6(960:helper-logs), object size: 232, buffer size: 240, default order: 1, min order: 0 > > > [ 8642.293009] node 0: slabs: 5, objs: 170, free: 0 > > > > > > slab_out_of_memory+1 > > > ___slab_alloc+969 > > > __slab_alloc+14 > > > kmem_cache_alloc+346 > > > inet_twsk_alloc+60 > > > tcp_time_wait+46 > > > tcp_fin+206 > > > tcp_data_queue+2034 > > > tcp_rcv_state_process+784 > > > tcp_v6_do_rcv+405 > > > __release_sock+118 > > > tcp_close+385 > > > inet_release+46 > > > __sock_release+55 > > > sock_close+17 > > > __fput+170 > > > task_work_run+127 > > > exit_to_usermode_loop+191 > > > do_syscall_64+212 > > > entry_SYSCALL_64_after_hwframe+68 > > > > > > accompanied by an increase in machines going completely radio silent > > > under memory pressure. > > > > This is really worrying because that suggests that something depends on > > GFP_ATOMIC allocation which is fragile and broken. > > I don't think that is true. You cannot rely on a *single instance* of > atomic allocations to succeed. But you have to be able to rely on that > failure is temporary and there is a chance of succeeding eventually. > > Network is a good example. It retries transmits, but within reason. If > you aren't able to process incoming packets for minutes, you might as > well be dead. > > > > One thing that changed since 4.16 is e699e2c6a654 ("net, mm: account > > > sock objects to kmemcg"), which made these slab caches subject to > > > cgroup memory accounting and control. > > > > > > The problem with that is that cgroups, unlike the page allocator, do > > > not maintain dedicated atomic reserves. As a cgroup's usage hovers at > > > its limit, atomic allocations - such as done during network rx - can > > > fail consistently for extended periods of time. The kernel is not able > > > to operate under these conditions. > > > > > > We don't want to revert the culprit patch, because it indeed tracks a > > > potentially substantial amount of memory used by a cgroup. > > > > > > We also don't want to implement dedicated atomic reserves for cgroups. > > > There is no point in keeping a fixed margin of unused bytes in the > > > cgroup's memory budget to accomodate a consumer that is impossible to > > > predict - we'd be wasting memory and get into configuration headaches, > > > not unlike what we have going with min_free_kbytes. We do this for > > > physical mem because we have to, but cgroups are an accounting game. > > > > > > Instead, account these privileged allocations to the cgroup, but let > > > them bypass the configured limit if they have to. This way, we get the > > > benefits of accounting the consumed memory and have it exert pressure > > > on the rest of the cgroup, but like with the page allocator, we shift > > > the burden of reclaimining on behalf of atomic allocations onto the > > > regular allocations that can block. > > > > 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.