Skip to content

Commit

Permalink
ON-16341: force 2MB huge page allocation to run on 1GB default systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Drinkwater committed Mar 7, 2025
1 parent 787182e commit 6c631cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/zf/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include <errno.h>
#include <sys/mman.h>
#include <linux/mman.h>

#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0x40000u
Expand Down Expand Up @@ -84,7 +85,7 @@ int zf_pool_alloc(struct zf_pool_res* pi, struct zf_pool* pool,
* to continue to use them as DMA buffers. */
pool->pkt_bufs =
(char*) zf_hal_mmap(NULL, alloc_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_SHARED | MAP_HUGETLB, -1, 0);
MAP_ANONYMOUS | MAP_SHARED | MAP_HUGETLB | MAP_HUGE_2MB, -1, 0);
pi->pkt_bufs_mmap_len = alloc_size;

/* Huge pages only */
Expand Down
3 changes: 2 additions & 1 deletion src/lib/zf/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/mman.h>

#include <ci/efhw/mc_driver_pcol.h>

Expand All @@ -36,7 +37,7 @@

void* __alloc_huge(size_t size)
{
unsigned mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB;
unsigned mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_HUGETLB | MAP_HUGE_2MB;
auto ptr = (char*) mmap(NULL, size, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
if( ptr == MAP_FAILED )
return NULL;
Expand Down

0 comments on commit 6c631cc

Please sign in to comment.