From: Mike Rapoport <rppt@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>
Cc: Michal Hocko <mhocko@suse.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Mike Rapoport <rppt@linux.ibm.com>
Subject: Re: [PATCH] docs/core-api: memory-allocation: describe reclaim behaviour
Date: Fri, 3 Jul 2020 00:54:59 +0300 [thread overview]
Message-ID: <20200702215459.GD2999148@kernel.org> (raw)
In-Reply-To: <20200626142950.135184-1-rppt@kernel.org>
Gentle ping.
On Fri, Jun 26, 2020 at 05:29:50PM +0300, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@linux.ibm.com>
>
> Changelog of commit dcda9b04713c ("mm, tree wide: replace __GFP_REPEAT by
> __GFP_RETRY_MAYFAIL with more useful semantic") has very nice description
> of GFP flags that affect reclaim behaviour of the page allocator.
>
> It would be pity to keep this description buried in the log so let's expose
> it in the Documentation/ as well.
>
> Cc: Michal Hocko <mhocko@suse.com>
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> Hi,
>
> I've been looking for something completely unrealated and found this
> really nice piece of documentation.
>
> Thanks Michal! ;-)
>
> Documentation/core-api/memory-allocation.rst | 44 ++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/Documentation/core-api/memory-allocation.rst b/Documentation/core-api/memory-allocation.rst
> index 4aa82ddd01b8..4446a1ac36cc 100644
> --- a/Documentation/core-api/memory-allocation.rst
> +++ b/Documentation/core-api/memory-allocation.rst
> @@ -84,6 +84,50 @@ driver for a device with such restrictions, avoid using these flags.
> And even with hardware with restrictions it is preferable to use
> `dma_alloc*` APIs.
>
> +GFP flags and reclaim behavior
> +------------------------------
> +Memory allocations may trigger direct or background reclaim and it is
> +useful to understand how hard the page allocator will try to satisfy that
> +or another request.
> +
> + * ``GFP_KERNEL & ~__GFP_RECLAIM`` - optimistic allocation without _any_
> + attempt to free memory at all. The most light weight mode which even
> + doesn't kick the background reclaim. Should be used carefully because it
> + might deplete the memory and the next user might hit the more aggressive
> + reclaim.
> +
> + * ``GFP_KERNEL & ~__GFP_DIRECT_RECLAIM`` (or ``GFP_NOWAIT``)- optimistic
> + allocation without any attempt to free memory from the current
> + context but can wake kswapd to reclaim memory if the zone is below
> + the low watermark. Can be used from either atomic contexts or when
> + the request is a performance optimization and there is another
> + fallback for a slow path.
> +
> + * ``(GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM`` (aka ``GFP_ATOMIC``) -
> + non sleeping allocation with an expensive fallback so it can access
> + some portion of memory reserves. Usually used from interrupt/bottom-half
> + context with an expensive slow path fallback.
> +
> + * ``GFP_KERNEL`` - both background and direct reclaim are allowed and the
> + **default** page allocator behavior is used. That means that not costly
> + allocation requests are basically no-fail but there is no guarantee of
> + that behavior so failures have to be checked properly by callers
> + (e.g. OOM killer victim is allowed to fail currently).
> +
> + * ``GFP_KERNEL | __GFP_NORETRY`` - overrides the default allocator behavior
> + and all allocation requests fail early rather than cause disruptive
> + reclaim (one round of reclaim in this implementation). The OOM killer
> + is not invoked.
> +
> + * ``GFP_KERNEL | __GFP_RETRY_MAYFAIL`` - overrides the default allocator
> + behavior and all allocation requests try really hard. The request
> + will fail if the reclaim cannot make any progress. The OOM killer
> + won't be triggered.
> +
> + * ``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.
> +
> Selecting memory allocator
> ==========================
>
> --
> 2.25.4
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2020-07-02 21:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 14:29 [PATCH] docs/core-api: memory-allocation: describe reclaim behaviour Mike Rapoport
2020-06-26 14:49 ` Michal Hocko
2020-07-02 21:54 ` Mike Rapoport [this message]
2020-07-12 8:21 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200702215459.GD2999148@kernel.org \
--to=rppt@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=rppt@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).