pmalloc: don't iterate if there is no enough free space 08/17008/1
authorDamjan Marion <damarion@cisco.com>
Wed, 23 Jan 2019 11:50:24 +0000 (12:50 +0100)
committerDamjan Marion <damarion@cisco.com>
Wed, 23 Jan 2019 11:50:24 +0000 (12:50 +0100)
Change-Id: I975d46a82e9f884a9cd0ac2bd5f57181695f4124
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/pmalloc.c

index 41309dd..5662a36 100644 (file)
@@ -138,6 +138,9 @@ alloc_chunk_from_page (clib_pmalloc_main_t * pm, clib_pmalloc_page_t * pp,
       pp->n_free_chunks = a->subpages_per_page;
     }
 
+  if (pp->n_free_blocks < n_blocks)
+    return 0;
+
   alloc_chunk_index = pp->first_chunk_index;
 
 next_chunk: