Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4414159ybb; Tue, 14 Apr 2020 06:54:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIbWzhE+5FEJIkvl8N5XDkuKjRRMnKzWBpGk/ODbIym6o8naEnxFLtjkx1l6YtvlXmoOG2K X-Received: by 2002:a50:c0ce:: with SMTP id r14mr7018746edf.298.1586872463846; Tue, 14 Apr 2020 06:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586872463; cv=none; d=google.com; s=arc-20160816; b=wzKFmkDW+1MzHPYx1YsjqleggIiH8G+lPa/yUUB2mp705DRboinsj6o+j1d79RIfR2 0xqNzyBUCiDPYNYvrst2tTReYq+mKQer+uc5OBdFTRFQhndWQsVr7N/ddR2Y6wn231Os MYvhPTgImGX5IrmY4O3f6GoohqaMiEgBRD75xUY8d47B08QWTbDtpmqrSW/Uyj+6XpN+ 8Wb3C0E4NPlutOqgA3H5s91/Bx/buiMV1PUPtCbrJpcniPLPWseulcTyW9XKxHYIbmSY qXoRy3yMsfsGJsqFnIdXSlPiTzvxoLv3Sf2m2G1ejxXE1apYbGjdgrHur4a0sqX1ObuO EEXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=vbBbfSDlZ4irmUlssYxWADDQ+G4iwhFUm2SgxM7XG38=; b=yjA2tbQz02rnLGwe14Umbb2S6MBNzWE31ccRsgnaQKZPUsexKbwXc9VYw+p4lnQlcT zl4jHqimVTLyOd8yycbx0fiIS2+l+NkbzyuXIcgzc0Mmb9VmKOZ70bKK1NyGIQB87f8g RU6MsBhUwlq74pPhhJoYwvuy5eQlfutJd4pupUdcSDQKs0u/WHLUdL7j8SLxn41cqJgv iuI3Y1ElFs5pXJ3BbKVq7/ZOU1hkf/AdM2J9bm4mm99aj7I7qVZTsjYuO8bJ2yyd3euv oNYKJGxhGJz6AVEaammgXq7On7+sE9zbDQoIjF9XDGI6iFgcbaGwHdiPvhM3CmD2Rvch hc5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iv3CEqU1; 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 s4si8374304ejx.332.2020.04.14.06.53.59; Tue, 14 Apr 2020 06:54:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=iv3CEqU1; 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 S2404036AbgDNCPg (ORCPT + 99 others); Mon, 13 Apr 2020 22:15:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:34602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403967AbgDNCPd (ORCPT ); Mon, 13 Apr 2020 22:15:33 -0400 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. _