1 #ifndef NDNDPDK_DISK_ALLOC_H
2 #define NDNDPDK_DISK_ALLOC_H
6 #include "../core/common.h"
7 #include <rte_bitmap.h>
21 static_assert(offsetof(
DiskAlloc, bmp[0]) % RTE_CACHE_LINE_SIZE == 0,
"");
27 __attribute__((nonnull))
static inline uint64_t
30 int found = rte_bitmap_scan(a->bmp, &a->
pos, &a->
slab);
31 if (unlikely(found == 0)) {
36 uint64_t offset = rte_bsf64(a->
slab);
37 a->
slab &= ~((uint64_t)1 << offset);
38 uint64_t pos = a->
pos + offset;
39 rte_bitmap_clear(a->bmp, pos);
44 __attribute__((nonnull))
static inline void
45 DiskAlloc_Free(
DiskAlloc* a, uint64_t slotID) {
47 uint32_t pos = slotID - a->
min;
49 rte_bitmap_set(a->bmp, pos);
61 __attribute__((returns_nonnull))
DiskAlloc*
struct DiskAlloc DiskAlloc
Disk slot allocator.
DiskAlloc * DiskAlloc_New(uint64_t min, uint64_t max, int numaSocket)
Create DiskAlloc.
Definition: alloc.c:4
#define NDNDPDK_ASSERT(x)
Definition: common.h:60
Disk slot allocator.
Definition: alloc.h:14
uint64_t min
Definition: alloc.h:15
struct rte_bitmap bmp[0] __rte_cache_aligned
Definition: alloc.h:19
uint64_t max
Definition: alloc.h:16
uint64_t slab
Definition: alloc.h:17
uint32_t pos
Definition: alloc.h:18