Latest commit 6c5ab65 May 8, 2017 Michal Hocko committed with mm: support __GFP_REPEAT in kvmalloc_node for >32kB
vhost code uses __GFP_REPEAT when allocating vhost_virtqueue resp.
vhost_vsock because it would really like to prefer kmalloc to the
vmalloc fallback - see 23cc5a9 ("vhost-net: extend device
allocation to vmalloc") for more context.  Michael Tsirkin has also

 "__GFP_REPEAT overhead is during allocation time. Using vmalloc means
  all accesses are slowed down. Allocation is not on data path, accesses

The similar applies to other vhost_kvzalloc users.

Let's teach kvmalloc_node to handle __GFP_REPEAT properly.  There are
two things to be careful about.  First we should prevent from the OOM
killer and so have to involve __GFP_NORETRY by default and secondly
override __GFP_REPEAT for !costly order requests as the __GFP_REPEAT is
ignored for !costly orders.

Supporting __GFP_REPEAT like semantic for !costly request is possible it
would require changes in the page allocator.  This is out of scope of
this patch.

This patch shouldn't introduce any functional change.

Signed-off-by: Michal Hocko <>
Acked-by: Vlastimil Babka <>
Acked-by: Michael S. Tsirkin <>
Cc: David Miller <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>