From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF295C433F5 for ; Tue, 26 Apr 2022 07:26:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C7996B0073; Tue, 26 Apr 2022 03:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 476CD6B0074; Tue, 26 Apr 2022 03:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33F416B0075; Tue, 26 Apr 2022 03:26:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 20A516B0073 for ; Tue, 26 Apr 2022 03:26:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id CB1B78093E for ; Tue, 26 Apr 2022 07:26:16 +0000 (UTC) X-FDA: 79398196752.03.069583A Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 8D11040047 for ; Tue, 26 Apr 2022 07:26:09 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id o18so11993950qtk.7 for ; Tue, 26 Apr 2022 00:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yrE6/KgEQNtC6XhgTjcpn5HXwreHk+7lNm/A5Ylaexs=; b=MMOnHZll5VuB7PYy60Iysska6rZSf2D5NP4yAERa9ryhogeag6xqgyUSPbZb7bCeBK zbPmDR7lIYjgg0DO3yolNQW7Ogg07Z4TUMtWNedywiiUIx0jk/eaAtWyItzk/sxt+yed 4SRUSei87FUEuymIi/ktCyE2nuDCXqfJKyc2XXy53P716xjN7yKfexduMdDMsZiv4XEP 9vcmY1/aI/VVw/kLKbTXqZ/peUEm3mEvblkK9ttYNhxNT2YqT5nsVou+xnqP34ArGUw9 qdsC5WFU/Wo9Z2mZHsrZOr8pR4Yq89/4smKLo3zo3V05YP0f/XOv861ZQoTPtID7L4E2 0n8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yrE6/KgEQNtC6XhgTjcpn5HXwreHk+7lNm/A5Ylaexs=; b=6Thfl+AIs+r0B8m+GnxIas8ZTv9ay2dwgC2y54QQkqgvGk1mey8EmKZ4Wsn3e2TYdk JTM89aLXoRewZes2PuSDZ2b65iS0Qvpeamlc7EiKlccnxxfW1AY4KnOwoFZmU0HnDhHg g5FUUuimykP9KTWJTa19zoKVHiurKXQL+oxs2xvDAwZ08+DyfQdn73eijtbXCIXOpKDO J5K7oq298EbypWSBls3j/IpeRVg9l2G/sLYNHu1BiBAKAFvQn1RAYD9SDhDK3o6rtqhR OIIutG5I1Zj85GFRjZHUoFInUBzE2DERTYOtl/CtVAAx6Mx4HiaJzcoonyrtPhEtiDc1 tF6A== X-Gm-Message-State: AOAM532bG1ui2VphIU8NRVl28/OH/UKWdCe+5TA+zQFkU37TJSdGlxBs QU42fzEyUb+nGDlMKRMRsw== X-Google-Smtp-Source: ABdhPJzHLhUkK0sbZJ+wWcmBR8J6P7yXgVyWf0qd7Fln2lMBrwIRo1ub7hHecfTdSVOahkHtW1uTeA== X-Received: by 2002:a05:622a:34d:b0:2f3:44d9:41a8 with SMTP id r13-20020a05622a034d00b002f344d941a8mr14286734qtw.217.1650957975499; Tue, 26 Apr 2022 00:26:15 -0700 (PDT) Received: from moria.home.lan (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id f127-20020a379c85000000b0069c921d6576sm6308392qke.76.2022.04.26.00.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 00:26:14 -0700 (PDT) Date: Tue, 26 Apr 2022 03:26:12 -0400 From: Kent Overstreet To: Michal Hocko Cc: Roman Gushchin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, hch@lst.de, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-input@vger.kernel.org, rostedt@goodmis.org Subject: Re: [PATCH v2 8/8] mm: Centralize & improve oom reporting in show_mem.c Message-ID: <20220426072612.7wgpzndigr4ybrh4@moria.home.lan> References: <20220421234837.3629927-1-kent.overstreet@gmail.com> <20220421234837.3629927-14-kent.overstreet@gmail.com> <20220422234820.plusgyixgybebfmi@moria.home.lan> <20220423004607.q4lbz2mplkhlbyhm@moria.home.lan> <20220425152811.pg2dse4zybpnpaa4@moria.home.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 8D11040047 X-Stat-Signature: dgfjp1jifngyhjqokkqtk3bzi1o44exk X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MMOnHZll; spf=pass (imf17.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam09 X-HE-Tag: 1650957969-929849 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 26, 2022 at 09:17:39AM +0200, Michal Hocko wrote: > I have already touched on that but let me reiterate. Allocation context > called from the oom path will have an unbound access to memory reserves. > Those are a last resort emergency pools of memory that are not available > normally and there are areas which really depend on them to make a > further progress to release the memory pressure. > > Swap over NFS would be one such example. If some other code path messes > with those reserves the swap IO path could fail with all sorts of > fallouts. > > So to be really exact in my statement. You can allocate from the OOM > context but it is _strongly_ discouraged unless there is no other way > around that. > > I would even claim that the memory reclaim in general shouldn't rely on > memory allocations (other than mempools). If an allocation is really > necessary then an extra care has to prevent from complete memory > depletion. 100% agreement with this, I've always made sure IO paths I touched were fully mempool-ified (some of my early work was actually for making sure bio allocation underneath generic_make_request() won't deadlock - previously allocated bios won't make forward progress and be freed due to generic_make_request() turning recursion into iteration, but that's all ancient history). Anyways, the reason I think this allocation is fine is it's GFP_NOWAIT and it's completely fine if it fails - all we lose is some diagnostics, and also it's released right away. But there's also no need for it to be a point of contention, the way I'm going with printbufs it'll be trivial to mempool-ify this if we want. Before I get back to this I'm changing the approach I'm taking with printbufs and first using it to clean up vsnprintf() and all the related code, which is.. a bit of an undertaking. End result is going to be really cool though.