summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2019-01-30 14:44:01 +0100
committerJonathan Ribas <jonathan.ribas@fraudbuster.mobi>2019-01-30 14:55:34 +0100
commitb8b81e28b75e59854c547caccb9dc386503b6b7c (patch)
tree899d4c14a2ddf27044be619e96891821d8e1fc06
parentc2b31e9997392390e1d20a539a3f95109b45c374 (diff)
downloaddpdk-burst-replay-b8b81e28b75e59854c547caccb9dc386503b6b7c.zip
dpdk-burst-replay-b8b81e28b75e59854c547caccb9dc386503b6b7c.tar.gz
dpdk-burst-replay-b8b81e28b75e59854c547caccb9dc386503b6b7c.tar.xz
Add a temporary --increase-hugepages-nb option to supply more hugepages for mempool creation if eneded.
(+ code cleanup)
-rw-r--r--src/dpdk.c36
-rw-r--r--src/main.c23
-rw-r--r--src/main.h1
3 files changed, 21 insertions, 39 deletions
diff --git a/src/dpdk.c b/src/dpdk.c
index f2b13aa..123eb7d 100644
--- a/src/dpdk.c
+++ b/src/dpdk.c
@@ -172,40 +172,6 @@ int dpdk_init_port(const struct cpus_bindings* cpus, int port)
return (0);
}
-int find_max_mempool_size(const struct cpus_bindings* cpus, struct dpdk_ctx* dpdk)
-{
- unsigned int nb_pkts = dpdk->nb_mbuf / 2;;
- unsigned int last_success = 0;
- unsigned int last_failed = dpdk->nb_mbuf;
-
- while (42) {
- dpdk->pktmbuf_pool = rte_mempool_create("dpdk_replay_mempool",
- nb_pkts,
- dpdk->mbuf_sz,
- MBUF_CACHE_SZ,
- sizeof(struct rte_pktmbuf_pool_private),
- rte_pktmbuf_pool_init, NULL,
- rte_pktmbuf_init, NULL,
- cpus->numacore,
- 0);
- if (dpdk->pktmbuf_pool == NULL) {
- fprintf(stderr, "mempool creation of %u mbufs failed\n", nb_pkts);
- last_failed = nb_pkts;
- if (last_success)
- nb_pkts = (last_failed + last_success) / 2;
- else
- nb_pkts /= 2;
- } else {
- fprintf(stderr, "mempool creation of %u mbufs SUCCESS :)\n", nb_pkts);
- rte_mempool_free(dpdk->pktmbuf_pool);
- last_success = nb_pkts;
- nb_pkts = (last_failed + last_success) / 2;
- }
- }
- return (0);
-}
-
-
int init_dpdk_eal_mempool(const struct cmd_opts* opts,
const struct cpus_bindings* cpus,
struct dpdk_ctx* dpdk)
@@ -219,7 +185,6 @@ int init_dpdk_eal_mempool(const struct cmd_opts* opts,
return (EINVAL);
rte_log_set_global_level(RTE_LOG_ERR);
- /* rte_log_set_global_level(RTE_LOG_DEBUG); */
/* craft an eal arg list */
eal_args = fill_eal_args(opts, cpus, dpdk, &eal_args_ac);
@@ -269,7 +234,6 @@ int init_dpdk_eal_mempool(const struct cmd_opts* opts,
0);
if (dpdk->pktmbuf_pool == NULL) {
fprintf(stderr, "DPDK: RTE Mempool creation failed\n");
- find_max_mempool_size(cpus, dpdk);
return (1);
}
return (0);
diff --git a/src/main.c b/src/main.c
index fbaea46..036ec62 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,11 +22,16 @@ void usage(void)
"Options:\n"
"--numacore numacore : use cores only if it fits the wanted numa.\n"
"--nbruns X : set the wanted number of replay (1 by default). Set to 0 to infinite mode.\n"
- "--wait-enter: will wait until you press ENTER to start the replay "
- " (asked once all the initialization are done)"
+ "--wait-enter: will wait until you press ENTER to start the replay (asked \n"
+ " once all the initialization are done)"
/* TODO: */
/* "[--maxbitrate bitrate]|[--normalspeed] : bitrate not to be exceeded (default: no limit) in ko/s.\n" */
/* " specify --normalspeed to replay the trace with the good timings." */
+ "\n/!\\ Dirty and temporary hack option:\n"
+ "--increase-hugepages-nb NB: will increase the amount of hugepages to be\n"
+ " used by the application to cache packets. Can be used if you got an \n"
+ " \"RTE Mempool creation failed\" error. 3 should be enough. /!\\ Temporary \n"
+ " option. Will be deleted once it will no longer be needed"
);
return ;
}
@@ -114,7 +119,6 @@ int parse_options(const int ac, char** av, struct cmd_opts* opts)
/* if no nb runs is specified */
if (i + 1 >= ac - 2)
return (ENOENT);
-
opts->nbruns = atoi(av[i + 1]);
if (opts->nbruns < 0)
return (EPROTO);
@@ -122,6 +126,18 @@ int parse_options(const int ac, char** av, struct cmd_opts* opts)
continue;
}
+ /* --increase-hugepages-nb nb */
+ if (!strcmp(av[i], "--increase-hugepages-nb")) {
+ /* if no nb is specified */
+ if (i + 1 >= ac - 2)
+ return (ENOENT);
+ opts->increase_hugepages_nb = atoi(av[i + 1]);
+ if (opts->increase_hugepages_nb < 0)
+ return (EPROTO);
+ i++;
+ continue;
+ }
+
/* --wait-enter */
if (!strcmp(av[i], "--wait-enter")) {
opts->wait = 1;
@@ -188,6 +204,7 @@ int check_needed_memory(const struct cmd_opts* opts, const struct pcap_ctx* pcap
dpdk->pool_sz = needed_mem / (float)(1024*1024*1024) + 1;
else
dpdk->pool_sz = needed_mem / (1024*1024*1024);
+ dpdk->pool_sz += opts->increase_hugepages_nb;
printf("-> Needed Hugepages of 1 Go = %lu\n", dpdk->pool_sz);
return (0);
}
diff --git a/src/main.h b/src/main.h
index 13b730c..6c5ec28 100644
--- a/src/main.h
+++ b/src/main.h
@@ -35,6 +35,7 @@ struct cmd_opts {
unsigned int maxbitrate;
int wait;
char* trace;
+ int increase_hugepages_nb;
};
/* struct to store the cpus context */