Skip to content

Commit 3c13a5c

Browse files
committed
fix(core/remio): number of objects in the OBJPOOL_ALLOC
Signed-off-by: João Peixoto <[email protected]>
1 parent e08c491 commit 3c13a5c

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

scripts/config_defs_gen.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
#include <stdio.h>
77
#include <config.h>
88

9+
static size_t remio_dev_num(void)
10+
{
11+
size_t dev_num = 0;
12+
for (size_t vm_id = 0; vm_id < config.vmlist_size; vm_id++) {
13+
struct vm_config* vm_config = &config.vmlist[vm_id];
14+
for (size_t i = 0; i < vm_config->platform.remio_dev_num; i++) {
15+
struct remio_dev* dev = &vm_config->platform.remio_devs[i];
16+
if (dev->type == REMIO_DEV_BACKEND) {
17+
dev_num++;
18+
}
19+
}
20+
}
21+
return dev_num;
22+
}
23+
924
int main() {
1025
size_t vcpu_num = 0;
1126
for (size_t i = 0; i < config.vmlist_size; i++) {
@@ -21,5 +36,7 @@ int main() {
2136
printf("#define CONFIG_HYP_BASE_ADDR PLAT_BASE_ADDR\n");
2237
}
2338

39+
printf("#define CONFIG_REMIO_DEV_NUM %ld\n", remio_dev_num());
40+
2441
return 0;
2542
}

src/core/inc/config_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define CONFIG_VCPU_NUM 1
1212
#define CONFIG_VM_NUM 1
1313
#define CONFIG_HYP_BASE_ADDR 0
14+
#define CONFIG_REMIO_DEV_NUM 0
1415

1516
#else /* GENERATING_DEFS */
1617

src/core/remio.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ static void remio_cpu_handler(uint32_t event, uint64_t data);
142142
CPU_MSG_HANDLER(remio_cpu_handler, REMIO_CPUMSG_ID)
143143

144144
/** Object pool to allocate Remote I/O devices */
145-
OBJPOOL_ALLOC(remio_device_pool, struct remio_device, sizeof(struct remio_device));
145+
OBJPOOL_ALLOC(remio_device_pool, struct remio_device, CONFIG_REMIO_DEV_NUM);
146146

147147
/** Object pool to allocate pending Remote I/O requests events */
148-
OBJPOOL_ALLOC(remio_request_event_pool, struct remio_request_event,
149-
sizeof(struct remio_request_event));
148+
OBJPOOL_ALLOC(remio_request_event_pool, struct remio_request_event, REMIO_VCPU_NUM);
150149

151150
/**
152151
* @brief Creates a new Remote I/O request based on the MMIO access information

src/core/vm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <shmem.h>
1212
#include <objpool.h>
1313

14-
OBJPOOL_ALLOC(emul_cache, struct emul_mem, sizeof(struct emul_mem));
14+
OBJPOOL_ALLOC(emul_cache, struct emul_mem, CONFIG_REMIO_DEV_NUM);
1515

1616
static void vm_master_init(struct vm* vm, const struct vm_config* vm_config, vmid_t vm_id)
1717
{

0 commit comments

Comments
 (0)