Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp301270ybb; Wed, 15 Apr 2020 01:33:03 -0700 (PDT) X-Google-Smtp-Source: APiQypKVZu5BoUqAedZExmpUz/QBZEtuFge7ZrBYEcBwoO5nI2QwVaFrsoEqGIGgm4+kEsTZGpK1 X-Received: by 2002:a17:906:6d83:: with SMTP id h3mr928835ejt.85.1586939583385; Wed, 15 Apr 2020 01:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586939583; cv=none; d=google.com; s=arc-20160816; b=iQk5oFRJttsq5HH5rXd+g+uc/LD96EJ9sydKHQaPQQu0EkCDNko10GpQpuN/szuyEc 2GNXtH6MjtAJ7FBr1ODN3KoV488N7rKR+Kf74YTzgjNuTTZQ1ouViUNVCzxQG/JlWA/r 931ajyGiMBqE12S0GAim4+iPk6IGsE+hDyDAs3wJHVPAZt+cHa4g0PlZvZM3XWOxDVCq zGnfOwfspFDoqzKkPN9tsaqcWcO4i/gJk6SYHrN2Rsj6CqhBX7mxm3DiIOVkDCCjCRTC Uc77zu97TJknHeI+AjI7xWphakwiiFoyvTRoAgQQW8G2OJb+EzXzxMzYstaBDuNe9wtr tVlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:references :in-reply-to:subject:cc:date:to:from; bh=rXerUiQaGSIWGimPV//zGwRAPy0jyqey/3nSuReJaJw=; b=PWq6FjGHISO9cBkH81qHF8DIHWxm/UNkvo2PjCOaBX/TdhggS80wfnyo7HEoNTepq2 dJtX/9pz5v3jg81/sMKv083/WPOT/6Zpr/squJx3Q6+Od/MY/FnJWh8XMQJOLU9gJzNb hW5KEGW/cxfa6HdHfxkVDltvksgMK27ta6n1WcPx9x5UMDKlP2iqZB+mJU9YM8Rv634X CHmxmatctsdHiIklIYDKve6TYgruzN/dO0nYbexpqTGO2OW/hUmrUWZQ49aN4aiYwLfo tuWHWyrceAA2e13LuWDxa4O2t4DD4s3q+wdH/BWHyCVVcEwXGdck/dy9IcscVUsa6VBT JEWw== 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 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw6si5032562edb.552.2020.04.15.01.32.40; Wed, 15 Apr 2020 01:33:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404962AbgDND4k (ORCPT + 99 others); Mon, 13 Apr 2020 23:56:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:46666 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728295AbgDND4h (ORCPT ); Mon, 13 Apr 2020 23:56:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A30A2ABB2; Tue, 14 Apr 2020 03:56:32 +0000 (UTC) From: NeilBrown To: Andrew Morton , John Hubbard Date: Tue, 14 Apr 2020 13:56:25 +1000 Cc: David Rientjes , Michal Hocko , Joel Fernandes , "Paul E. McKenney" , linux-mm@kvack.org, LKML Subject: Re: [PATCH 1/2] mm: clarify __GFP_MEMALLOC usage In-Reply-To: <20200413191532.6b234b50caea9134fb95a151@linux-foundation.org> References: <20200403083543.11552-1-mhocko@kernel.org> <20200403083543.11552-2-mhocko@kernel.org> <87blo8xnz2.fsf@notabene.neil.brown.name> <20200406070137.GC19426@dhcp22.suse.cz> <4f861f07-4b47-8ddc-f783-10201ea302d3@nvidia.com> <20200413191532.6b234b50caea9134fb95a151@linux-foundation.org> Message-ID: <87h7xmu3di.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain On Mon, Apr 13 2020, Andrew Morton wrote: > I've rather lost the plot with this little patch. Is the below > suitable, or do we think that changes are needed? > > > From: Michal Hocko > Subject: mm: clarify __GFP_MEMALLOC usage > > It seems that the existing documentation is not explicit about the > expected usage and potential risks enough. While it is calls out that > users have to free memory when using this flag it is not really apparent > that users have to careful to not deplete memory reserves and that they > should implement some sort of throttling wrt. freeing process. > > This is partly based on Neil's explanation [1]. > > Let's also call out that a pre allocated pool allocator should be > considered. > > [1] http://lkml.kernel.org/r/877dz0yxoa.fsf@notabene.neil.brown.name > > [akpm@linux-foundation.org: coding style fixes] > Link: http://lkml.kernel.org/r/20200403083543.11552-2-mhocko@kernel.org > Signed-off-by: Michal Hocko > Cc: David Rientjes > Cc: Joel Fernandes > Cc: Neil Brown > Cc: Paul E. McKenney > Cc: John Hubbard > [mhocko@kernel.org: update] > Link: http://lkml.kernel.org/r/20200406070137.GC19426@dhcp22.suse.cz > Signed-off-by: Andrew Morton > --- > > include/linux/gfp.h | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/include/linux/gfp.h~mm-clarify-__gfp_memalloc-usage > +++ a/include/linux/gfp.h > @@ -110,6 +110,11 @@ struct vm_area_struct; > * the caller guarantees the allocation will allow more memory to be freed > * very shortly e.g. process exiting or swapping. Users either should > * be the MM or co-ordinating closely with the VM (e.g. swap over NFS). > + * Users of this flag have to be extremely careful to not deplete the reserve > + * completely and implement a throttling mechanism which controls the > + * consumption of the reserve based on the amount of freed memory. > + * Usage of a pre-allocated pool (e.g. mempool) should be always considered > + * before using this flag. I particularly don't like the connection between the consumption and the amount freed. I don't think that say anything useful and it misses the main point which, I think, is having a bound on total usage. Nichal's previous proposal is, I think, the best concrete proposal so far. NeilBrown > * > * %__GFP_NOMEMALLOC is used to explicitly forbid access to emergency reserves. > * This takes precedence over the %__GFP_MEMALLOC flag if both are set. > _ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAl6VNGkACgkQOeye3VZi gbmUqw/+IOvlNMYdYcojRcEW8VsmDaByc7Fki5Jdl5TdAVpGjzkO5hvJmpJ/kegK Sp3MFIDL0ZKCSXLR5oMivlxj9fs3Kp0hSZKakT3HGb4rKOPtvrdOlEJwtK2n8QuZ WG3gUivxitP/jVra95l0YMjWdByaks1A2LUuCkSRFXTbXxNCbTtsejOSQZ1nHNmw aNDPza3HVLBTs/7C1ddI9yERlangq2OpTRneubVRA8b92naJ7eszVnree/U0C+YK LlhfsBoHe/VR6US2Ow5Z8O+d3S73+a71q+6RKfJFjwRRIkVih+j9aWMZS0kwvW5h zavZiWweRw9naOvm2i4VR+09Lyo3GJmMDLAAvgdGTE8wR7bzQ3dh2pKG5llhnWvB MFyyru3xl3kwcb7MnAU9wPTraK17P6IDzjHdIHfYv/hge5QvO6kvJUpYkOaRke1c ZTK9pzNsaFn16d0mbktyAadIXZ05md0DZ4uFr0Yz36RoOWL4YP7mo5TMM/ZXkTPc AXlAY2YnXrEhGazhNTv8cJFqgmpaydcYPDoFX6KbeUYXMtGlwDvTgN8O18bXruGr Z7C/M5C4Xbxr5y/ZST5VrgY61oYQeOSMzQ0TXpH0OCEx7luaFQYs+KMU1QynsWDS lS/vwruSb7QjUy5xSAUru2sOGgeEQe4tAALoCVaChEL0QU3e/RI= =6JJt -----END PGP SIGNATURE----- --=-=-=--