Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp254114pxb; Mon, 13 Sep 2021 18:28:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+wGQzC7V7kLaZGkJ8km7a2eAJy0/XelM1Hm0Sae0EaYHo6xO5wfmK77nyil+Yk98BRfPU X-Received: by 2002:a05:6e02:1906:: with SMTP id w6mr10560415ilu.295.1631582934328; Mon, 13 Sep 2021 18:28:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631582934; cv=none; d=google.com; s=arc-20160816; b=KIefB5BXMcMmJSABsxYqqFDQ21xplMTWwf522lZ8jmMXfOBMVRZyEvOpJ+EqsJT/PM OEypUDcandb0OLnDZqh9tEHD4FCzB4Wp8RPYnDsCcSDDDG41cIKOoyeozY3We5EgJ8J6 Gurc2mQFYlEP6Xa/1vksz2zONcMQJ7irUc1M1pkKdeRbC5AeOighIzxjyXqmZIYM34vA f4Thhk1KDGpHFzWjAplG53zv44fN8lRidu8Ls/iYto9QuW0MeMEu3D5ExuiOBPF/41Ab Z+z3Pg8yieAxPkoLG9ivr1I4tNPDsfYd//Hdu1nLqMEJUxB/UYlbo6KnECsxXwdnxr1G fGZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from:dkim-signature:dkim-signature; bh=g0SHCABpDWS99bZKx2dAHZNwjxnp06aPgrFMV26MaeI=; b=bKWwau5B/Rr8sRDiCrpsCyugfIReWqgYRD2+hJKTfJ170uA5ibGQoQiy3GBxuplX1j BXYL7JOQIZK2907u3AfOlF1DpjiS+4eqAkRM50VihLkN/59UKR253nF2+a+KEhO351FL YwqhOU0jv+FgTkZ6k6SOpIBUjr5Dy7adx8uL+1Z8IOkITnvrnRThXIGKe0aaR0EMugM2 9iOag+OQ3Y9y3D6CUKewkMIWsmBoLnkf4qWJGO6i3xY5rxn8KKFjopX6A85jxdbEwupq i2k9sQNODv1TJJ9NdWlo7yD2bGg+G1TOqXxBco2oH204KIv5XhuRFE7nM/C2QOGMTKHI H8sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vKluE2nO; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si9370672ilu.99.2021.09.13.18.28.42; Mon, 13 Sep 2021 18:28:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.de header.s=susede2_rsa header.b=vKluE2nO; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238200AbhINA3J (ORCPT + 99 others); Mon, 13 Sep 2021 20:29:09 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:55050 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238258AbhINA3H (ORCPT ); Mon, 13 Sep 2021 20:29:07 -0400 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org __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 --- 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)