From patchwork Tue Sep 14 00:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12491095 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 914D8C433EF for ; Tue, 14 Sep 2021 00:27:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D16E60F4C for ; Tue, 14 Sep 2021 00:27:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4D16E60F4C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id D70D2940007; Mon, 13 Sep 2021 20:27:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D1FC46B0071; Mon, 13 Sep 2021 20:27:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0EC4940007; Mon, 13 Sep 2021 20:27:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id B45786B006C for ; Mon, 13 Sep 2021 20:27:51 -0400 (EDT) Received: from smtpin32.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7601718182898 for ; Tue, 14 Sep 2021 00:27:51 +0000 (UTC) X-FDA: 78584291142.32.9053B75 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf24.hostedemail.com (Postfix) with ESMTP id 1BE86B000099 for ; Tue, 14 Sep 2021 00:27:51 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 293F9200AB; Tue, 14 Sep 2021 00:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1631579270; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0SHCABpDWS99bZKx2dAHZNwjxnp06aPgrFMV26MaeI=; b=vKluE2nOK+k9zSBiBmELjziS/Je3Eb7ExMrDxZnQgF+C9Jlx6UUT2UchNrxrTG4opSHW5e CKXutZ33ekHMt2YOaXMYX4apmr9T8sIP9VrAD8dS5JEAhAtmV0vAgHwumYWtDsneQYQkTB UeLE85Mise3J1lrnNfUn35emK0UMcjc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1631579270; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0SHCABpDWS99bZKx2dAHZNwjxnp06aPgrFMV26MaeI=; b=KHVFdZ4dzTCRc/u9v2yXF/btQQFh1qUTgYDrabeG0U2Emc2V42uJV6/y0HDLdM8r95xM8U VRa1YzY4Iys9V4AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BDB7613ADE; Tue, 14 Sep 2021 00:27:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Ja8IH4LsP2EUawAAMHmgww (envelope-from ); Tue, 14 Sep 2021 00:27:46 +0000 From: NeilBrown To: Andrew Morton , Theodore Ts'o , Andreas Dilger , "Darrick J. Wong" , Matthew Wilcox , Mel Gorman Date: Tue, 14 Sep 2021 10:13:04 +1000 Subject: [PATCH 1/6] MM: improve documentation for __GFP_NOFAIL Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Message-ID: <163157838436.13293.8832201267053160346.stgit@noble.brown> In-Reply-To: <163157808321.13293.486682642188075090.stgit@noble.brown> References: <163157808321.13293.486682642188075090.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 X-Stat-Signature: chfbk3qowqde1nxwj9ysjfphtr18xfex Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=vKluE2nO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=KHVFdZ4d; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf24.hostedemail.com: domain of neilb@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=neilb@suse.de X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1BE86B000099 X-HE-Tag: 1631579271-118868 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: __GFP_NOFAIL is documented both in gfp.h and memory-allocation.rst. The details are not entirely consistent. This patch ensures both places state that: - there is a cost potentially imposed on other subsystems - it should only be used when there is no real alternative - it is preferable to an endless loop - it is strongly discourages for costly-order allocations. Signed-off-by: NeilBrown Acked-by: Michal Hocko --- Documentation/core-api/memory-allocation.rst | 9 ++++++++- include/linux/gfp.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst index 5954ddf6ee13..9458ce72d31c 100644 --- a/Documentation/core-api/memory-allocation.rst +++ b/Documentation/core-api/memory-allocation.rst @@ -126,7 +126,14 @@ or another request. * ``GFP_KERNEL | __GFP_NOFAIL`` - overrides the default allocator behavior and all allocation requests will loop endlessly until they succeed. - This might be really dangerous especially for larger orders. + The allocator may provide access to memory that would otherwise be + reserved in order to satisfy this allocation which might adversely + affect other subsystems. So it should only be used when there is no + reasonable failure policy and when the memory is likely to be freed + again in the near future. Its use is strong discourage (via a + WARN_ON) for allocations larger than ``PAGE_ALLOC_COSTLY_ORDER``. + While this flag is best avoided, it is still preferable to endless + loops around the allocator. Selecting memory allocator ========================== diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 55b2ec1f965a..101479373738 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -209,6 +209,10 @@ struct vm_area_struct; * used only when there is no reasonable failure policy) but it is * definitely preferable to use the flag rather than opencode endless * loop around allocator. + * Use of this flag may provide access to memory which would otherwise be + * reserved. As such it must be understood that there can be a cost imposed + * on other subsystems as well as the obvious cost of placing the calling + * thread in an uninterruptible indefinite wait. * Using this flag for costly allocations is _highly_ discouraged. */ #define __GFP_IO ((__force gfp_t)___GFP_IO)