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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BDFBC2BBC7 for ; Tue, 14 Apr 2020 02:15:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3B93F20768 for ; Tue, 14 Apr 2020 02:15:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="iv3CEqU1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B93F20768 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B519F8E0003; Mon, 13 Apr 2020 22:15:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B02268E0001; Mon, 13 Apr 2020 22:15:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A17E48E0003; Mon, 13 Apr 2020 22:15:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 870A18E0001 for ; Mon, 13 Apr 2020 22:15:34 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4B7388245571 for ; Tue, 14 Apr 2020 02:15:34 +0000 (UTC) X-FDA: 76704844188.27.burst83_4db2a79e4631a X-HE-Tag: burst83_4db2a79e4631a X-Filterd-Recvd-Size: 4257 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 02:15:33 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7AB2A2072D; Tue, 14 Apr 2020 02:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586830532; bh=jf+A5BOVOt2DrD15bo3uMAmUl8iVMb/SY+JfZlmUKnA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iv3CEqU1ivakHxCxU9TGDqQnv1OHMGi48YIRuRnWsPWVUKwVJjTmhfCvk3OVLkOtC ZWqG1ZckUNOqWjpjcJvcVAYnKucUZMBQKXORY0MtQPKOSudQYbj9sJWVpDt2/Zb0wL U8AXxbLZTa+CTIio8Ky1EpGdd1ulfgenE8C6Pe/M= Date: Mon, 13 Apr 2020 19:15:32 -0700 From: Andrew Morton To: John Hubbard Cc: David Rientjes , Michal Hocko , NeilBrown , Joel Fernandes , "Paul E. McKenney" , , LKML Subject: Re: [PATCH 1/2] mm: clarify __GFP_MEMALLOC usage Message-Id: <20200413191532.6b234b50caea9134fb95a151@linux-foundation.org> In-Reply-To: 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> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: 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. * * %__GFP_NOMEMALLOC is used to explicitly forbid access to emergency reserves. * This takes precedence over the %__GFP_MEMALLOC flag if both are set. _