Re: [PATCH v4 1/4] mm: cma: introduce gfp flag in cma_alloc instead of no_warn
From: Minchan Kim <minchan@kernel.org>
Date: 2021-01-27 20:23:03
Also in:
linux-devicetree, linux-media, lkml
On Tue, Jan 26, 2021 at 11:12:14AM -0800, Minchan Kim wrote:
On Tue, Jan 26, 2021 at 08:38:08AM +0100, Michal Hocko wrote:quoted
On Mon 25-01-21 11:42:34, Minchan Kim wrote:quoted
On Mon, Jan 25, 2021 at 02:07:01PM +0100, Michal Hocko wrote:quoted
On Thu 21-01-21 09:54:59, Minchan Kim wrote:quoted
The upcoming patch will introduce __GFP_NORETRY semantic in alloc_contig_range which is a failfast mode of the API. Instead of adding a additional parameter for gfp, replace no_warn with gfp flag. To keep old behaviors, it follows the rule below. no_warn gfp_flags false GFP_KERNEL true GFP_KERNEL|__GFP_NOWARN gfp & __GFP_NOWARN GFP_KERNEL | (gfp & __GFP_NOWARN) Reviewed-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Minchan Kim <minchan@kernel.org>[...]quoted
diff --git a/mm/cma.c b/mm/cma.c index 0ba69cd16aeb..d50627686fec 100644 --- a/mm/cma.c +++ b/mm/cma.c@@ -419,13 +419,13 @@ static inline void cma_debug_show_areas(struct cma *cma) { } * @cma: Contiguous memory region for which the allocation is performed. * @count: Requested number of pages. * @align: Requested alignment of pages (in PAGE_SIZE order). - * @no_warn: Avoid printing message about failed allocation + * @gfp_mask: GFP mask to use during the cma allocation.Call out supported gfp flags explicitly. Have a look at kvmalloc_node for a guidance.How about this?diff --git a/mm/cma.c b/mm/cma.c index d50627686fec..b94727b694d6 100644 --- a/mm/cma.c +++ b/mm/cma.c@@ -423,6 +423,10 @@ static inline void cma_debug_show_areas(struct cma *cma) { } * * This function allocates part of contiguous memory on specific * contiguous memory area. + * + * For gfp_mask, GFP_KERNEL and __GFP_NORETRY are supported. __GFP_NORETRY + * will avoid costly functions(e.g., waiting on page_writeback and locking) + * at current implementaion during the page migration.rather than explicitly mentioning what the flag implies I think it would be more useful to state the intended usecase. See how kvmalloc_node says "__GFP_RETRY_MAYFAIL is supported, and it should be used only if kmalloc is preferable to the vmalloc fallback, due to visible performance drawbacks. __GFP_NOWARN is also supported to suppress allocation failure messages." This would help people not familiar with internals to see whether this flag is a good fit for them. In this case I woul go with " @flags: gfp mask. Must be compatible (superset) with GFP_KERNEL. [...] Reclaim modifiers (__GFP_RETRY_MAYFAIL, __GFP_NOFAIL) are not supported. __GFP_NORETRY is supported, and it should be used for opportunistic allocation attempts that should rather fail quickly when the caller has a fallback strategy. " Obviously for this patch you will go with a simple statement that Reclaim modifiers are not supported at all.After more discussion for gfp_flags in thread of next patch, let me changes a bit more based on it. Thanks for the suggestion, Michal.
Based on the discussion in other thread, I want to go with __GFP_NORETRY to indicate "opportunistic-easy-to-fail attempt" so suggestion words Michal is valid so I will carry it on next version. Thank you.