Re: [PATCH 1/3] vmalloc: Add __vmalloc_node_try_addr function

From: Matthew Wilcox
Date: Wed Jun 20 2018 - 18:27:03 EST


On Wed, Jun 20, 2018 at 03:09:28PM -0700, Rick Edgecombe wrote:
>
> /**
> + * __vmalloc_try_addr - try to alloc at a specific address
> + * @addr: address to try
> + * @size: size to try
> + * @gfp_mask: flags for the page level allocator
> + * @prot: protection mask for the allocated pages
> + * @vm_flags: additional vm area flags (e.g. %VM_NO_GUARD)
> + * @node: node to use for allocation or NUMA_NO_NODE
> + * @caller: caller's return address
> + *
> + * Try to allocate at the specific address. If it succeeds the address is
> + * returned. If it fails NULL is returned. It may trigger TLB flushes.

* Try to allocate memory at a specific address. May trigger TLB flushes.
*
* Context: Process context.
* Return: The allocated address if it succeeds. NULL if it fails.

> @@ -1759,8 +1795,9 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
> return addr;
>
> fail:
> - warn_alloc(gfp_mask, NULL,
> - "vmalloc: allocation failure: %lu bytes", real_size);
> + if (!(gfp_mask & __GFP_NOWARN))
> + warn_alloc(gfp_mask, NULL,
> + "vmalloc: allocation failure: %lu bytes", real_size);
> return NULL;

Not needed:

void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
{
...
if ((gfp_mask & __GFP_NOWARN) || !__ratelimit(&nopage_rs))
return;