pmalloc: don't iterate if there is no enough free space
[vpp.git] / 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: