Message ID | 1393414244-17012-1-git-send-email-petri.savolainen@linaro.org |
---|---|
State | Superseded, archived |
Headers | show |
On 26 February 2014 17:00, Petri Savolainen <petri.savolainen@linaro.org> wrote: > Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> > --- More verbose patch description in header would help for reader. > test/packet/odp_example_pktio.c | 63 ++++++++++++++++++++++++++++++++--------- > 1 file changed, 49 insertions(+), 14 deletions(-) > > diff --git a/test/packet/odp_example_pktio.c b/test/packet/odp_example_pktio.c > index 875830e..516fe37 100644 > --- a/test/packet/odp_example_pktio.c > +++ b/test/packet/odp_example_pktio.c > @@ -38,6 +38,7 @@ > * Parsed command line application arguments > */ > typedef struct { > + int core_count; > int if_count; /**< Number of interfaces to be used */ > char **if_names; /**< Array of pointers to interface names */ > int mode; /**< Packet IO mode */ > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > odp_packet_t pkt; > odp_buffer_t buf; > int ret; > - unsigned long pkt_cnt = 0; > +/* unsigned long pkt_cnt = 0;*/ deleting them and other commented code too. Thanks. > unsigned long err_cnt = 0; > odp_pktio_params_t params; > socket_params_t *sock_params = ¶ms.sock_params; > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > /* Enqueue the packet for output */ > odp_queue_enq(outq_def, buf); > > - /* Print packet counts every once in a while */ > +/* > + // Print packet counts every once in a while > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); > fflush(NULL); > } > +*/ > } > > /* unreachable */ > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > thread_args_t *thr_args; > int pkts, pkts_ok; > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > - unsigned long pkt_cnt = 0; > +/* unsigned long pkt_cnt = 0;*/ > unsigned long err_cnt = 0; > - unsigned long tmp = 0; > +/* unsigned long tmp = 0;*/ > odp_pktio_params_t params; > socket_params_t *sock_params = ¶ms.sock_params; > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > if (odp_unlikely(pkts_ok != pkts)) > ODP_ERR("Dropped frames:%u - err_cnt:%lu\n", > pkts-pkts_ok, ++err_cnt); > - > - /* Print packet counts every once in a while */ > +/* > + // Print packet counts every once in a while > tmp += pkts_ok; > - if (odp_unlikely((tmp >= 100000) || /* OR first print:*/ > + if (odp_unlikely((tmp >= 100000) || // OR first print: > ((pkt_cnt == 0) && ((tmp-1) < MAX_PKT_BURST)))) { > pkt_cnt += tmp; > printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); > fflush(NULL); > tmp = 0; > } > +*/ > } > } > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > int num_workers; > void *pool_base; > int i; > + int first_core; > + int core_count; > > /* Init ODP before calling anything else */ > if (odp_init_global()) { > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > /* Print both system and application information */ > print_info(NO_PATH(argv[0]), &args->appl); > > - num_workers = odp_sys_core_count(); > + core_count = odp_sys_core_count(); > + num_workers = core_count; > + > + if (args->appl.core_count) > + num_workers = args->appl.core_count; > + > if (num_workers > MAX_WORKERS) > num_workers = MAX_WORKERS; > > + printf("Num worker threads: %i\n", num_workers); > + > + /* > + * By default core #0 runs Linux kernel background tasks. > + * Start mapping thread from core #1 > + */ > + first_core = 1; > + > + if (core_count == 1) > + first_core = 0; > + > + printf("First core: %i\n\n", first_core); > + > /* Init this thread */ > thr_id = odp_thread_create(0); > odp_init_local(thr_id); > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > memset(thread_tbl, 0, sizeof(thread_tbl)); > for (i = 0; i < num_workers; ++i) { > void *(*thr_run_func) (void *); > - int if_idx = i % args->appl.if_count; > + int core; > + int if_idx; > + > + core = (first_core + i) % core_count; > + > + if_idx = i % args->appl.if_count; > > args->thread[i].pktio_dev = args->appl.if_names[if_idx]; > args->thread[i].pool = pool; > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > * because each thread might get different arguments. > * Calls odp_thread_create(cpu) for each thread > */ > - odp_linux_pthread_create(thread_tbl, 1, i, thr_run_func, > + odp_linux_pthread_create(thread_tbl, 1, core, thr_run_func, > &args->thread[i]); > } > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) > size_t len; > int i; > static struct option longopts[] = { > + {"count", required_argument, NULL, 'c'}, > {"interface", required_argument, NULL, 'i'}, /* return 'i' */ > {"mode", required_argument, NULL, 'm'}, /* return 'm' */ > {"help", no_argument, NULL, 'h'}, /* return 'h' */ > @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) > appl_args->mode = -1; /* Invalid, must be changed by parsing */ > > while (1) { > - opt = getopt_long(argc, argv, "+i:m:h", longopts, &long_index); > + opt = getopt_long(argc, argv, "+c:i:m:h", > + longopts, &long_index); > > if (opt == -1) > break; /* No more options */ > > switch (opt) { > + case 'c': > + appl_args->core_count = atoi(optarg); > + break; > /* parse packet-io interface names */ > case 'i': > len = strlen(optarg); > @@ -537,8 +571,8 @@ static void print_info(char *progname, appl_args_t *appl_args) > "Core count: %i\n" > "\n", > odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), > - odp_sys_cache_line_size(), odp_sys_core_count() > - ); > + odp_sys_cache_line_size(), odp_sys_core_count()); > + > printf("Running ODP appl: \"%s\"\n" > "-----------------\n" > "IF-count: %i\n" > @@ -573,7 +607,8 @@ static void usage(char *progname) > " 1: Send&receive packets through ODP queues.\n" > "\n" > "Optional OPTIONS\n" > - " -h, --help Display help and exit.\n" > + " -c, --count <number> Core count.\n" > + " -h, --help Display help and exit.\n" > "\n", NO_PATH(progname), NO_PATH(progname) > ); > } > -- > 1.8.5.3 > > -- > You received this message because you are subscribed to the Google Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. > For more options, visit https://groups.google.com/a/linaro.org/groups/opt_out.
On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org<javascript:>> > wrote: > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org <javascript:>> > > --- > > More verbose patch description in header would help for reader. > It adds an option to choose core count (instead of running on all cores which is still the default). > > > test/packet/odp_example_pktio.c | 63 > ++++++++++++++++++++++++++++++++--------- > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > diff --git a/test/packet/odp_example_pktio.c > b/test/packet/odp_example_pktio.c > > index 875830e..516fe37 100644 > > --- a/test/packet/odp_example_pktio.c > > +++ b/test/packet/odp_example_pktio.c > > @@ -38,6 +38,7 @@ > > * Parsed command line application arguments > > */ > > typedef struct { > > + int core_count; > > int if_count; /**< Number of interfaces to be used */ > > char **if_names; /**< Array of pointers to interface > names */ > > int mode; /**< Packet IO mode */ > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > odp_packet_t pkt; > > odp_buffer_t buf; > > int ret; > > - unsigned long pkt_cnt = 0; > > +/* unsigned long pkt_cnt = 0;*/ > deleting them and other commented code too. > > Those commented printfs on fast path are potential reason for packet drops / low throughput. Still investigating that, so didn't remove the code yet. -Petri > Thanks. > > unsigned long err_cnt = 0; > > odp_pktio_params_t params; > > socket_params_t *sock_params = ¶ms.sock_params; > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > /* Enqueue the packet for output */ > > odp_queue_enq(outq_def, buf); > > > > - /* Print packet counts every once in a while */ > > +/* > > + // Print packet counts every once in a while > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); > > fflush(NULL); > > } > > +*/ > > } > > > > /* unreachable */ > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > thread_args_t *thr_args; > > int pkts, pkts_ok; > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > - unsigned long pkt_cnt = 0; > > +/* unsigned long pkt_cnt = 0;*/ > > unsigned long err_cnt = 0; > > - unsigned long tmp = 0; > > +/* unsigned long tmp = 0;*/ > > odp_pktio_params_t params; > > socket_params_t *sock_params = ¶ms.sock_params; > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > if (odp_unlikely(pkts_ok != pkts)) > > ODP_ERR("Dropped frames:%u - > err_cnt:%lu\n", > > pkts-pkts_ok, ++err_cnt); > > - > > - /* Print packet counts every once in a while */ > > +/* > > + // Print packet counts every once in a while > > tmp += pkts_ok; > > - if (odp_unlikely((tmp >= 100000) || /* OR first > print:*/ > > + if (odp_unlikely((tmp >= 100000) || // OR first > print: > > ((pkt_cnt == 0) && ((tmp-1) < > MAX_PKT_BURST)))) { > > pkt_cnt += tmp; > > printf(" [%02i] pkt_cnt:%lu\n", thr, > pkt_cnt); > > fflush(NULL); > > tmp = 0; > > } > > +*/ > > } > > } > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > int num_workers; > > void *pool_base; > > int i; > > + int first_core; > > + int core_count; > > > > /* Init ODP before calling anything else */ > > if (odp_init_global()) { > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > /* Print both system and application information */ > > print_info(NO_PATH(argv[0]), &args->appl); > > > > - num_workers = odp_sys_core_count(); > > + core_count = odp_sys_core_count(); > > + num_workers = core_count; > > + > > + if (args->appl.core_count) > > + num_workers = args->appl.core_count; > > + > > if (num_workers > MAX_WORKERS) > > num_workers = MAX_WORKERS; > > > > + printf("Num worker threads: %i\n", num_workers); > > + > > + /* > > + * By default core #0 runs Linux kernel background tasks. > > + * Start mapping thread from core #1 > > + */ > > + first_core = 1; > > + > > + if (core_count == 1) > > + first_core = 0; > > + > > + printf("First core: %i\n\n", first_core); > > + > > /* Init this thread */ > > thr_id = odp_thread_create(0); > > odp_init_local(thr_id); > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > for (i = 0; i < num_workers; ++i) { > > void *(*thr_run_func) (void *); > > - int if_idx = i % args->appl.if_count; > > + int core; > > + int if_idx; > > + > > + core = (first_core + i) % core_count; > > + > > + if_idx = i % args->appl.if_count; > > > > args->thread[i].pktio_dev = args->appl.if_names[if_idx]; > > args->thread[i].pool = pool; > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > * because each thread might get different arguments. > > * Calls odp_thread_create(cpu) for each thread > > */ > > - odp_linux_pthread_create(thread_tbl, 1, i, thr_run_func, > > + odp_linux_pthread_create(thread_tbl, 1, core, > thr_run_func, > > &args->thread[i]); > > } > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], > appl_args_t *appl_args) > > size_t len; > > int i; > > static struct option longopts[] = { > > + {"count", required_argument, NULL, 'c'}, > > {"interface", required_argument, NULL, 'i'}, /* > return 'i' */ > > {"mode", required_argument, NULL, 'm'}, /* > return 'm' */ > > {"help", no_argument, NULL, 'h'}, /* > return 'h' */ > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], > appl_args_t *appl_args) > > appl_args->mode = -1; /* Invalid, must be changed by parsing */ > > > > while (1) { > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, > &long_index); > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > + longopts, &long_index); > > > > if (opt == -1) > > break; /* No more options */ > > > > switch (opt) { > > + case 'c': > > + appl_args->core_count = atoi(optarg); > > + break; > > /* parse packet-io interface names */ > > case 'i': > > len = strlen(optarg); > > @@ -537,8 +571,8 @@ static void print_info(char *progname, appl_args_t > *appl_args) > > "Core count: %i\n" > > "\n", > > odp_version_api_str(), odp_sys_cpu_model_str(), > odp_sys_cpu_hz(), > > - odp_sys_cache_line_size(), odp_sys_core_count() > > - ); > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > + > > printf("Running ODP appl: \"%s\"\n" > > "-----------------\n" > > "IF-count: %i\n" > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > " 1: Send&receive packets through ODP > queues.\n" > > "\n" > > "Optional OPTIONS\n" > > - " -h, --help Display help and exit.\n" > > + " -c, --count <number> Core count.\n" > > + " -h, --help Display help and exit.\n" > > "\n", NO_PATH(progname), NO_PATH(progname) > > ); > > } > > -- > > 1.8.5.3 > > > > -- > > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+u...@linaro.org <javascript:>. > > To post to this group, send email to lng...@linaro.org <javascript:>. > > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > > > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. > > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out. >
Looks like it's good for inclusion, right? Maxim. On 02/26/2014 05:53 PM, Petri Savolainen wrote: > > > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > > On 26 February 2014 17:00, Petri Savolainen > <petri.sa...@linaro.org <javascript:>> wrote: > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org > <javascript:>> > > --- > > More verbose patch description in header would help for reader. > > > It adds an option to choose core count (instead of running on all > cores which is still the default). > > > > test/packet/odp_example_pktio.c | 63 > ++++++++++++++++++++++++++++++++--------- > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > diff --git a/test/packet/odp_example_pktio.c > b/test/packet/odp_example_pktio.c > > index 875830e..516fe37 100644 > > --- a/test/packet/odp_example_pktio.c > > +++ b/test/packet/odp_example_pktio.c > > @@ -38,6 +38,7 @@ > > * Parsed command line application arguments > > */ > > typedef struct { > > + int core_count; > > int if_count; /**< Number of interfaces to be > used */ > > char **if_names; /**< Array of pointers to > interface names */ > > int mode; /**< Packet IO mode */ > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > odp_packet_t pkt; > > odp_buffer_t buf; > > int ret; > > - unsigned long pkt_cnt = 0; > > +/* unsigned long pkt_cnt = 0;*/ > deleting them and other commented code too. > > Those commented printfs on fast path are potential reason for packet > drops / low throughput. Still investigating that, so didn't remove the > code yet. > > -Petri > > Thanks. > > unsigned long err_cnt = 0; > > odp_pktio_params_t params; > > socket_params_t *sock_params = ¶ms.sock_params; > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > /* Enqueue the packet for output */ > > odp_queue_enq(outq_def, buf); > > > > - /* Print packet counts every once in a while */ > > +/* > > + // Print packet counts every once in a while > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > printf(" [%02i] pkt_cnt:%lu\n", thr, > pkt_cnt); > > fflush(NULL); > > } > > +*/ > > } > > > > /* unreachable */ > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > thread_args_t *thr_args; > > int pkts, pkts_ok; > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > - unsigned long pkt_cnt = 0; > > +/* unsigned long pkt_cnt = 0;*/ > > unsigned long err_cnt = 0; > > - unsigned long tmp = 0; > > +/* unsigned long tmp = 0;*/ > > odp_pktio_params_t params; > > socket_params_t *sock_params = ¶ms.sock_params; > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > if (odp_unlikely(pkts_ok != pkts)) > > ODP_ERR("Dropped frames:%u - > err_cnt:%lu\n", > > pkts-pkts_ok, ++err_cnt); > > - > > - /* Print packet counts every once in a > while */ > > +/* > > + // Print packet counts every once in a > while > > tmp += pkts_ok; > > - if (odp_unlikely((tmp >= 100000) || /* > OR first print:*/ > > + if (odp_unlikely((tmp >= 100000) || // > OR first print: > > ((pkt_cnt == 0) && ((tmp-1) < > MAX_PKT_BURST)))) { > > pkt_cnt += tmp; > > printf(" [%02i] pkt_cnt:%lu\n", > thr, pkt_cnt); > > fflush(NULL); > > tmp = 0; > > } > > +*/ > > } > > } > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > int num_workers; > > void *pool_base; > > int i; > > + int first_core; > > + int core_count; > > > > /* Init ODP before calling anything else */ > > if (odp_init_global()) { > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > /* Print both system and application information */ > > print_info(NO_PATH(argv[0]), &args->appl); > > > > - num_workers = odp_sys_core_count(); > > + core_count = odp_sys_core_count(); > > + num_workers = core_count; > > + > > + if (args->appl.core_count) > > + num_workers = args->appl.core_count; > > + > > if (num_workers > MAX_WORKERS) > > num_workers = MAX_WORKERS; > > > > + printf("Num worker threads: %i\n", num_workers); > > + > > + /* > > + * By default core #0 runs Linux kernel background tasks. > > + * Start mapping thread from core #1 > > + */ > > + first_core = 1; > > + > > + if (core_count == 1) > > + first_core = 0; > > + > > + printf("First core: %i\n\n", first_core); > > + > > /* Init this thread */ > > thr_id = odp_thread_create(0); > > odp_init_local(thr_id); > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > for (i = 0; i < num_workers; ++i) { > > void *(*thr_run_func) (void *); > > - int if_idx = i % args->appl.if_count; > > + int core; > > + int if_idx; > > + > > + core = (first_core + i) % core_count; > > + > > + if_idx = i % args->appl.if_count; > > > > args->thread[i].pktio_dev = > args->appl.if_names[if_idx]; > > args->thread[i].pool = pool; > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > * because each thread might get different > arguments. > > * Calls odp_thread_create(cpu) for each thread > > */ > > - odp_linux_pthread_create(thread_tbl, 1, i, > thr_run_func, > > + odp_linux_pthread_create(thread_tbl, 1, core, > thr_run_func, > > &args->thread[i]); > > } > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char > *argv[], appl_args_t *appl_args) > > size_t len; > > int i; > > static struct option longopts[] = { > > + {"count", required_argument, NULL, 'c'}, > > {"interface", required_argument, NULL, 'i'}, > /* return 'i' */ > > {"mode", required_argument, NULL, 'm'}, /* > return 'm' */ > > {"help", no_argument, NULL, 'h'}, /* > return 'h' */ > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char > *argv[], appl_args_t *appl_args) > > appl_args->mode = -1; /* Invalid, must be changed by > parsing */ > > > > while (1) { > > - opt = getopt_long(argc, argv, "+i:m:h", > longopts, &long_index); > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > + longopts, &long_index); > > > > if (opt == -1) > > break; /* No more options */ > > > > switch (opt) { > > + case 'c': > > + appl_args->core_count = atoi(optarg); > > + break; > > /* parse packet-io interface names */ > > case 'i': > > len = strlen(optarg); > > @@ -537,8 +571,8 @@ static void print_info(char *progname, > appl_args_t *appl_args) > > "Core count: %i\n" > > "\n", > > odp_version_api_str(), odp_sys_cpu_model_str(), > odp_sys_cpu_hz(), > > - odp_sys_cache_line_size(), odp_sys_core_count() > > - ); > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > + > > printf("Running ODP appl: \"%s\"\n" > > "-----------------\n" > > "IF-count: %i\n" > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > " 1: Send&receive packets > through ODP queues.\n" > > "\n" > > "Optional OPTIONS\n" > > - " -h, --help Display help and exit.\n" > > + " -c, --count <number> Core count.\n" > > + " -h, --help Display help and exit.\n" > > "\n", NO_PATH(progname), NO_PATH(progname) > > ); > > } > > -- > > 1.8.5.3 > > > > -- > > You received this message because you are subscribed to the > Google Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" > group. > > To unsubscribe from this group and stop receiving emails from > it, send an email to lng-odp+u...@linaro.org <javascript:>. > > To post to this group, send email to lng...@linaro.org > <javascript:>. > > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/ > <http://groups.google.com/a/linaro.org/group/lng-odp/>. > > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org>. > > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out > <https://groups.google.com/a/linaro.org/groups/opt_out>. > > -- > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org. > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out.
On 2014-02-27 17:16, Maxim Uvarov wrote: > Looks like it's good for inclusion, right? No, it should not go in... > > Maxim. > > On 02/26/2014 05:53 PM, Petri Savolainen wrote: > > > > > >On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > > > > On 26 February 2014 17:00, Petri Savolainen > > <petri.sa...@linaro.org <javascript:>> wrote: > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org > > <javascript:>> > > > --- > > > > More verbose patch description in header would help for reader. > > > > > >It adds an option to choose core count (instead of running on all > >cores which is still the default). > > > > > > > test/packet/odp_example_pktio.c | 63 > > ++++++++++++++++++++++++++++++++--------- > > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > > > diff --git a/test/packet/odp_example_pktio.c > > b/test/packet/odp_example_pktio.c > > > index 875830e..516fe37 100644 > > > --- a/test/packet/odp_example_pktio.c > > > +++ b/test/packet/odp_example_pktio.c > > > @@ -38,6 +38,7 @@ > > > * Parsed command line application arguments > > > */ > > > typedef struct { > > > + int core_count; > > > int if_count; /**< Number of interfaces to be > > used */ > > > char **if_names; /**< Array of pointers to > > interface names */ > > > int mode; /**< Packet IO mode */ > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > > odp_packet_t pkt; > > > odp_buffer_t buf; > > > int ret; > > > - unsigned long pkt_cnt = 0; > > > +/* unsigned long pkt_cnt = 0;*/ > > deleting them and other commented code too. > > > >Those commented printfs on fast path are potential reason for > >packet drops / low throughput. Still investigating that, so didn't > >remove the code yet. > > > >-Petri > > > > Thanks. > > > unsigned long err_cnt = 0; > > > odp_pktio_params_t params; > > > socket_params_t *sock_params = ¶ms.sock_params; > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > > /* Enqueue the packet for output */ > > > odp_queue_enq(outq_def, buf); > > > > > > - /* Print packet counts every once in a while */ > > > +/* > > > + // Print packet counts every once in a while > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > > pkt_cnt); > > > fflush(NULL); > > > } > > > +*/ > > > } > > > > > > /* unreachable */ > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > > thread_args_t *thr_args; > > > int pkts, pkts_ok; > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > > - unsigned long pkt_cnt = 0; > > > +/* unsigned long pkt_cnt = 0;*/ > > > unsigned long err_cnt = 0; > > > - unsigned long tmp = 0; > > > +/* unsigned long tmp = 0;*/ > > > odp_pktio_params_t params; > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > > if (odp_unlikely(pkts_ok != pkts)) > > > ODP_ERR("Dropped frames:%u - > > err_cnt:%lu\n", > > > pkts-pkts_ok, ++err_cnt); > > > - > > > - /* Print packet counts every once in a > > while */ > > > +/* > > > + // Print packet counts every once in a > > while > > > tmp += pkts_ok; > > > - if (odp_unlikely((tmp >= 100000) || /* > > OR first print:*/ > > > + if (odp_unlikely((tmp >= 100000) || // > > OR first print: > > > ((pkt_cnt == 0) && ((tmp-1) < > > MAX_PKT_BURST)))) { > > > pkt_cnt += tmp; > > > printf(" [%02i] pkt_cnt:%lu\n", > > thr, pkt_cnt); > > > fflush(NULL); > > > tmp = 0; > > > } > > > +*/ > > > } > > > } > > > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > > int num_workers; > > > void *pool_base; > > > int i; > > > + int first_core; > > > + int core_count; > > > > > > /* Init ODP before calling anything else */ > > > if (odp_init_global()) { > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > > /* Print both system and application information */ > > > print_info(NO_PATH(argv[0]), &args->appl); > > > > > > - num_workers = odp_sys_core_count(); > > > + core_count = odp_sys_core_count(); > > > + num_workers = core_count; > > > + > > > + if (args->appl.core_count) > > > + num_workers = args->appl.core_count; > > > + > > > if (num_workers > MAX_WORKERS) > > > num_workers = MAX_WORKERS; > > > > > > + printf("Num worker threads: %i\n", num_workers); > > > + > > > + /* > > > + * By default core #0 runs Linux kernel background tasks. > > > + * Start mapping thread from core #1 > > > + */ > > > + first_core = 1; > > > + > > > + if (core_count == 1) > > > + first_core = 0; > > > + > > > + printf("First core: %i\n\n", first_core); > > > + > > > /* Init this thread */ > > > thr_id = odp_thread_create(0); > > > odp_init_local(thr_id); > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > > for (i = 0; i < num_workers; ++i) { > > > void *(*thr_run_func) (void *); > > > - int if_idx = i % args->appl.if_count; > > > + int core; > > > + int if_idx; > > > + > > > + core = (first_core + i) % core_count; > > > + > > > + if_idx = i % args->appl.if_count; > > > > > > args->thread[i].pktio_dev = > > args->appl.if_names[if_idx]; > > > args->thread[i].pool = pool; > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > > * because each thread might get different > > arguments. > > > * Calls odp_thread_create(cpu) for each thread > > > */ > > > - odp_linux_pthread_create(thread_tbl, 1, i, > > thr_run_func, > > > + odp_linux_pthread_create(thread_tbl, 1, core, > > thr_run_func, > > > &args->thread[i]); > > > } > > > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char > > *argv[], appl_args_t *appl_args) > > > size_t len; > > > int i; > > > static struct option longopts[] = { > > > + {"count", required_argument, NULL, 'c'}, > > > {"interface", required_argument, NULL, 'i'}, > >/* return 'i' */ > > > {"mode", required_argument, NULL, 'm'}, /* > > return 'm' */ > > > {"help", no_argument, NULL, 'h'}, /* > > return 'h' */ > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char > > *argv[], appl_args_t *appl_args) > > > appl_args->mode = -1; /* Invalid, must be changed by > > parsing */ > > > > > > while (1) { > > > - opt = getopt_long(argc, argv, "+i:m:h", > > longopts, &long_index); > > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > > + longopts, &long_index); > > > > > > if (opt == -1) > > > break; /* No more options */ > > > > > > switch (opt) { > > > + case 'c': > > > + appl_args->core_count = atoi(optarg); > > > + break; > > > /* parse packet-io interface names */ > > > case 'i': > > > len = strlen(optarg); > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, > > appl_args_t *appl_args) > > > "Core count: %i\n" > > > "\n", > > > odp_version_api_str(), odp_sys_cpu_model_str(), > > odp_sys_cpu_hz(), > > > - odp_sys_cache_line_size(), odp_sys_core_count() > > > - ); > > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > > + > > > printf("Running ODP appl: \"%s\"\n" > > > "-----------------\n" > > > "IF-count: %i\n" > > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > > " 1: Send&receive packets > > through ODP queues.\n" > > > "\n" > > > "Optional OPTIONS\n" > > > - " -h, --help Display help and exit.\n" > > > + " -c, --count <number> Core count.\n" > > > + " -h, --help Display help and exit.\n" > > > "\n", NO_PATH(progname), NO_PATH(progname) > > > ); > > > } > > > -- > > > 1.8.5.3 > > > > > > -- > > > You received this message because you are subscribed to the > > Google Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" > > group. > > > To unsubscribe from this group and stop receiving emails from > > it, send an email to lng-odp+u...@linaro.org <javascript:>. > > > To post to this group, send email to lng...@linaro.org > > <javascript:>. > > > Visit this group at > > http://groups.google.com/a/linaro.org/group/lng-odp/ > > <http://groups.google.com/a/linaro.org/group/lng-odp/>. > > > To view this discussion on the web visit > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org > > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org>. > > > > > For more options, visit > > https://groups.google.com/a/linaro.org/groups/opt_out > > <https://groups.google.com/a/linaro.org/groups/opt_out>. > > > >-- > >You received this message because you are subscribed to the Google > >Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > >To unsubscribe from this group and stop receiving emails from it, > >send an email to lng-odp+unsubscribe@linaro.org. > >To post to this group, send email to lng-odp@linaro.org. > >Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > >To view this discussion on the web visit https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org. > >For more options, visit > >https://groups.google.com/a/linaro.org/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit https://groups.google.com/a/linaro.org/d/msgid/lng-odp/530F3A91.5090607%40linaro.org. > For more options, visit https://groups.google.com/a/linaro.org/groups/opt_out.
On 2014-02-26 05:53, Petri Savolainen wrote: > > > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org<javascript:>> > > wrote: > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org <javascript:>> > > > --- > > > > More verbose patch description in header would help for reader. > > > > It adds an option to choose core count (instead of running on all cores > which is still the default). > > > > > > > test/packet/odp_example_pktio.c | 63 > > ++++++++++++++++++++++++++++++++--------- > > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > > > diff --git a/test/packet/odp_example_pktio.c > > b/test/packet/odp_example_pktio.c > > > index 875830e..516fe37 100644 > > > --- a/test/packet/odp_example_pktio.c > > > +++ b/test/packet/odp_example_pktio.c > > > @@ -38,6 +38,7 @@ > > > * Parsed command line application arguments > > > */ > > > typedef struct { > > > + int core_count; > > > int if_count; /**< Number of interfaces to be used */ > > > char **if_names; /**< Array of pointers to interface > > names */ > > > int mode; /**< Packet IO mode */ > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > > odp_packet_t pkt; > > > odp_buffer_t buf; > > > int ret; > > > - unsigned long pkt_cnt = 0; > > > +/* unsigned long pkt_cnt = 0;*/ > > deleting them and other commented code too. > > > > > Those commented printfs on fast path are potential reason for packet drops > / low throughput. Still investigating that, so didn't remove the code yet. this should not go into the official repository... if you want to have a local copy of out commented code just stash it! Cheers, Anders > > -Petri > > > > Thanks. > > > unsigned long err_cnt = 0; > > > odp_pktio_params_t params; > > > socket_params_t *sock_params = ¶ms.sock_params; > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > > /* Enqueue the packet for output */ > > > odp_queue_enq(outq_def, buf); > > > > > > - /* Print packet counts every once in a while */ > > > +/* > > > + // Print packet counts every once in a while > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > > printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); > > > fflush(NULL); > > > } > > > +*/ > > > } > > > > > > /* unreachable */ > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > > thread_args_t *thr_args; > > > int pkts, pkts_ok; > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > > - unsigned long pkt_cnt = 0; > > > +/* unsigned long pkt_cnt = 0;*/ > > > unsigned long err_cnt = 0; > > > - unsigned long tmp = 0; > > > +/* unsigned long tmp = 0;*/ > > > odp_pktio_params_t params; > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > > if (odp_unlikely(pkts_ok != pkts)) > > > ODP_ERR("Dropped frames:%u - > > err_cnt:%lu\n", > > > pkts-pkts_ok, ++err_cnt); > > > - > > > - /* Print packet counts every once in a while */ > > > +/* > > > + // Print packet counts every once in a while > > > tmp += pkts_ok; > > > - if (odp_unlikely((tmp >= 100000) || /* OR first > > print:*/ > > > + if (odp_unlikely((tmp >= 100000) || // OR first > > print: > > > ((pkt_cnt == 0) && ((tmp-1) < > > MAX_PKT_BURST)))) { > > > pkt_cnt += tmp; > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > > pkt_cnt); > > > fflush(NULL); > > > tmp = 0; > > > } > > > +*/ > > > } > > > } > > > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > > int num_workers; > > > void *pool_base; > > > int i; > > > + int first_core; > > > + int core_count; > > > > > > /* Init ODP before calling anything else */ > > > if (odp_init_global()) { > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > > /* Print both system and application information */ > > > print_info(NO_PATH(argv[0]), &args->appl); > > > > > > - num_workers = odp_sys_core_count(); > > > + core_count = odp_sys_core_count(); > > > + num_workers = core_count; > > > + > > > + if (args->appl.core_count) > > > + num_workers = args->appl.core_count; > > > + > > > if (num_workers > MAX_WORKERS) > > > num_workers = MAX_WORKERS; > > > > > > + printf("Num worker threads: %i\n", num_workers); > > > + > > > + /* > > > + * By default core #0 runs Linux kernel background tasks. > > > + * Start mapping thread from core #1 > > > + */ > > > + first_core = 1; > > > + > > > + if (core_count == 1) > > > + first_core = 0; > > > + > > > + printf("First core: %i\n\n", first_core); > > > + > > > /* Init this thread */ > > > thr_id = odp_thread_create(0); > > > odp_init_local(thr_id); > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > > for (i = 0; i < num_workers; ++i) { > > > void *(*thr_run_func) (void *); > > > - int if_idx = i % args->appl.if_count; > > > + int core; > > > + int if_idx; > > > + > > > + core = (first_core + i) % core_count; > > > + > > > + if_idx = i % args->appl.if_count; > > > > > > args->thread[i].pktio_dev = args->appl.if_names[if_idx]; > > > args->thread[i].pool = pool; > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > > * because each thread might get different arguments. > > > * Calls odp_thread_create(cpu) for each thread > > > */ > > > - odp_linux_pthread_create(thread_tbl, 1, i, thr_run_func, > > > + odp_linux_pthread_create(thread_tbl, 1, core, > > thr_run_func, > > > &args->thread[i]); > > > } > > > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], > > appl_args_t *appl_args) > > > size_t len; > > > int i; > > > static struct option longopts[] = { > > > + {"count", required_argument, NULL, 'c'}, > > > {"interface", required_argument, NULL, 'i'}, /* > > return 'i' */ > > > {"mode", required_argument, NULL, 'm'}, /* > > return 'm' */ > > > {"help", no_argument, NULL, 'h'}, /* > > return 'h' */ > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], > > appl_args_t *appl_args) > > > appl_args->mode = -1; /* Invalid, must be changed by parsing */ > > > > > > while (1) { > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, > > &long_index); > > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > > + longopts, &long_index); > > > > > > if (opt == -1) > > > break; /* No more options */ > > > > > > switch (opt) { > > > + case 'c': > > > + appl_args->core_count = atoi(optarg); > > > + break; > > > /* parse packet-io interface names */ > > > case 'i': > > > len = strlen(optarg); > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, appl_args_t > > *appl_args) > > > "Core count: %i\n" > > > "\n", > > > odp_version_api_str(), odp_sys_cpu_model_str(), > > odp_sys_cpu_hz(), > > > - odp_sys_cache_line_size(), odp_sys_core_count() > > > - ); > > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > > + > > > printf("Running ODP appl: \"%s\"\n" > > > "-----------------\n" > > > "IF-count: %i\n" > > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > > " 1: Send&receive packets through ODP > > queues.\n" > > > "\n" > > > "Optional OPTIONS\n" > > > - " -h, --help Display help and exit.\n" > > > + " -c, --count <number> Core count.\n" > > > + " -h, --help Display help and exit.\n" > > > "\n", NO_PATH(progname), NO_PATH(progname) > > > ); > > > } > > > -- > > > 1.8.5.3 > > > > > > -- > > > You received this message because you are subscribed to the Google > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. > > > To unsubscribe from this group and stop receiving emails from it, send > > an email to lng-odp+u...@linaro.org <javascript:>. > > > To post to this group, send email to lng...@linaro.org <javascript:>. > > > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > > > > > To view this discussion on the web visit > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. > > > > > For more options, visit > > https://groups.google.com/a/linaro.org/groups/opt_out. > > > > -- > You received this message because you are subscribed to the Google Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org. > For more options, visit https://groups.google.com/a/linaro.org/groups/opt_out.
I think the official repo should be just the currently accepted "best" code, just to stop all of us adding commented out notes to ourselves and making it harder for others. On 27 February 2014 09:03, Anders Roxell <anders.roxell@linaro.org> wrote: > On 2014-02-26 05:53, Petri Savolainen wrote: > > > > > > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > > > > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org > <javascript:>> > > > wrote: > > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org<javascript:>> > > > > --- > > > > > > More verbose patch description in header would help for reader. > > > > > > > It adds an option to choose core count (instead of running on all cores > > which is still the default). > > > > > > > > > > > test/packet/odp_example_pktio.c | 63 > > > ++++++++++++++++++++++++++++++++--------- > > > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/test/packet/odp_example_pktio.c > > > b/test/packet/odp_example_pktio.c > > > > index 875830e..516fe37 100644 > > > > --- a/test/packet/odp_example_pktio.c > > > > +++ b/test/packet/odp_example_pktio.c > > > > @@ -38,6 +38,7 @@ > > > > * Parsed command line application arguments > > > > */ > > > > typedef struct { > > > > + int core_count; > > > > int if_count; /**< Number of interfaces to be used > */ > > > > char **if_names; /**< Array of pointers to interface > > > names */ > > > > int mode; /**< Packet IO mode */ > > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > > > odp_packet_t pkt; > > > > odp_buffer_t buf; > > > > int ret; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > deleting them and other commented code too. > > > > > > > > Those commented printfs on fast path are potential reason for packet > drops > > / low throughput. Still investigating that, so didn't remove the code > yet. > > this should not go into the official repository... if you want to have a > local copy of out commented code just stash it! > > Cheers, > Anders > > > > > -Petri > > > > > > > Thanks. > > > > unsigned long err_cnt = 0; > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > > > /* Enqueue the packet for output */ > > > > odp_queue_enq(outq_def, buf); > > > > > > > > - /* Print packet counts every once in a while */ > > > > +/* > > > > + // Print packet counts every once in a while > > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > pkt_cnt); > > > > fflush(NULL); > > > > } > > > > +*/ > > > > } > > > > > > > > /* unreachable */ > > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > > > thread_args_t *thr_args; > > > > int pkts, pkts_ok; > > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > > unsigned long err_cnt = 0; > > > > - unsigned long tmp = 0; > > > > +/* unsigned long tmp = 0;*/ > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > > > if (odp_unlikely(pkts_ok != pkts)) > > > > ODP_ERR("Dropped frames:%u - > > > err_cnt:%lu\n", > > > > pkts-pkts_ok, ++err_cnt); > > > > - > > > > - /* Print packet counts every once in a while > */ > > > > +/* > > > > + // Print packet counts every once in a while > > > > tmp += pkts_ok; > > > > - if (odp_unlikely((tmp >= 100000) || /* OR > first > > > print:*/ > > > > + if (odp_unlikely((tmp >= 100000) || // OR > first > > > print: > > > > ((pkt_cnt == 0) && ((tmp-1) < > > > MAX_PKT_BURST)))) { > > > > pkt_cnt += tmp; > > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > > > pkt_cnt); > > > > fflush(NULL); > > > > tmp = 0; > > > > } > > > > +*/ > > > > } > > > > } > > > > > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > > > int num_workers; > > > > void *pool_base; > > > > int i; > > > > + int first_core; > > > > + int core_count; > > > > > > > > /* Init ODP before calling anything else */ > > > > if (odp_init_global()) { > > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > > > /* Print both system and application information */ > > > > print_info(NO_PATH(argv[0]), &args->appl); > > > > > > > > - num_workers = odp_sys_core_count(); > > > > + core_count = odp_sys_core_count(); > > > > + num_workers = core_count; > > > > + > > > > + if (args->appl.core_count) > > > > + num_workers = args->appl.core_count; > > > > + > > > > if (num_workers > MAX_WORKERS) > > > > num_workers = MAX_WORKERS; > > > > > > > > + printf("Num worker threads: %i\n", num_workers); > > > > + > > > > + /* > > > > + * By default core #0 runs Linux kernel background tasks. > > > > + * Start mapping thread from core #1 > > > > + */ > > > > + first_core = 1; > > > > + > > > > + if (core_count == 1) > > > > + first_core = 0; > > > > + > > > > + printf("First core: %i\n\n", first_core); > > > > + > > > > /* Init this thread */ > > > > thr_id = odp_thread_create(0); > > > > odp_init_local(thr_id); > > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > > > for (i = 0; i < num_workers; ++i) { > > > > void *(*thr_run_func) (void *); > > > > - int if_idx = i % args->appl.if_count; > > > > + int core; > > > > + int if_idx; > > > > + > > > > + core = (first_core + i) % core_count; > > > > + > > > > + if_idx = i % args->appl.if_count; > > > > > > > > args->thread[i].pktio_dev = > args->appl.if_names[if_idx]; > > > > args->thread[i].pool = pool; > > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > > > * because each thread might get different arguments. > > > > * Calls odp_thread_create(cpu) for each thread > > > > */ > > > > - odp_linux_pthread_create(thread_tbl, 1, i, > thr_run_func, > > > > + odp_linux_pthread_create(thread_tbl, 1, core, > > > thr_run_func, > > > > &args->thread[i]); > > > > } > > > > > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], > > > appl_args_t *appl_args) > > > > size_t len; > > > > int i; > > > > static struct option longopts[] = { > > > > + {"count", required_argument, NULL, 'c'}, > > > > {"interface", required_argument, NULL, 'i'}, /* > > > return 'i' */ > > > > {"mode", required_argument, NULL, 'm'}, /* > > > return 'm' */ > > > > {"help", no_argument, NULL, 'h'}, /* > > > return 'h' */ > > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], > > > appl_args_t *appl_args) > > > > appl_args->mode = -1; /* Invalid, must be changed by parsing > */ > > > > > > > > while (1) { > > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, > > > &long_index); > > > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > > > + longopts, &long_index); > > > > > > > > if (opt == -1) > > > > break; /* No more options */ > > > > > > > > switch (opt) { > > > > + case 'c': > > > > + appl_args->core_count = atoi(optarg); > > > > + break; > > > > /* parse packet-io interface names */ > > > > case 'i': > > > > len = strlen(optarg); > > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, > appl_args_t > > > *appl_args) > > > > "Core count: %i\n" > > > > "\n", > > > > odp_version_api_str(), odp_sys_cpu_model_str(), > > > odp_sys_cpu_hz(), > > > > - odp_sys_cache_line_size(), odp_sys_core_count() > > > > - ); > > > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > > > + > > > > printf("Running ODP appl: \"%s\"\n" > > > > "-----------------\n" > > > > "IF-count: %i\n" > > > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > > > " 1: Send&receive packets through ODP > > > queues.\n" > > > > "\n" > > > > "Optional OPTIONS\n" > > > > - " -h, --help Display help and exit.\n" > > > > + " -c, --count <number> Core count.\n" > > > > + " -h, --help Display help and exit.\n" > > > > "\n", NO_PATH(progname), NO_PATH(progname) > > > > ); > > > > } > > > > -- > > > > 1.8.5.3 > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. > > > > To unsubscribe from this group and stop receiving emails from it, > send > > > an email to lng-odp+u...@linaro.org <javascript:>. > > > > To post to this group, send email to lng...@linaro.org<javascript:>. > > > > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/. > > > > > > > To view this discussion on the web visit > > > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org > . > > > > > > > For more options, visit > > > https://groups.google.com/a/linaro.org/groups/opt_out. > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+unsubscribe@linaro.org. > > To post to this group, send email to lng-odp@linaro.org. > > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/ > . > > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org > . > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out. > > -- > Anders Roxell > anders.roxell@linaro.org > M: +46 709 71 42 85 | IRC: roxell > > -- > You received this message because you are subscribed to the Google Groups > "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/20140227140308.GB30514%408470w > . > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out. >
On Thursday, 27 February 2014 16:03:08 UTC+2, Anders Roxell wrote: > On 2014-02-26 05:53, Petri Savolainen wrote: > > > > > > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: > > > > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org<javascript:>> > > > > wrote: > > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org<javascript:>> > > > > --- > > > > > > More verbose patch description in header would help for reader. > > > > > > > It adds an option to choose core count (instead of running on all cores > > which is still the default). > > > > > > > > > > > test/packet/odp_example_pktio.c | 63 > > > ++++++++++++++++++++++++++++++++--------- > > > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/test/packet/odp_example_pktio.c > > > b/test/packet/odp_example_pktio.c > > > > index 875830e..516fe37 100644 > > > > --- a/test/packet/odp_example_pktio.c > > > > +++ b/test/packet/odp_example_pktio.c > > > > @@ -38,6 +38,7 @@ > > > > * Parsed command line application arguments > > > > */ > > > > typedef struct { > > > > + int core_count; > > > > int if_count; /**< Number of interfaces to be used > */ > > > > char **if_names; /**< Array of pointers to interface > > > names */ > > > > int mode; /**< Packet IO mode */ > > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) > > > > odp_packet_t pkt; > > > > odp_buffer_t buf; > > > > int ret; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > deleting them and other commented code too. > > > > > > > > Those commented printfs on fast path are potential reason for packet > drops > > / low throughput. Still investigating that, so didn't remove the code > yet. > > this should not go into the official repository... if you want to have a > local copy of out commented code just stash it! > > I left those there for others. The test used to print out those lines when receiving packets. Now when it's not doing that anymore (by default) people may think that packets stopped going through. It's still easy for others to uncomment the liens and see the familiar prints. -Petri > Cheers, > Anders > > > > > -Petri > > > > > > > Thanks. > > > > unsigned long err_cnt = 0; > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) > > > > /* Enqueue the packet for output */ > > > > odp_queue_enq(outq_def, buf); > > > > > > > > - /* Print packet counts every once in a while */ > > > > +/* > > > > + // Print packet counts every once in a while > > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { > > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > pkt_cnt); > > > > fflush(NULL); > > > > } > > > > +*/ > > > > } > > > > > > > > /* unreachable */ > > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) > > > > thread_args_t *thr_args; > > > > int pkts, pkts_ok; > > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > > unsigned long err_cnt = 0; > > > > - unsigned long tmp = 0; > > > > +/* unsigned long tmp = 0;*/ > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = ¶ms.sock_params; > > > > > > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) > > > > if (odp_unlikely(pkts_ok != pkts)) > > > > ODP_ERR("Dropped frames:%u - > > > err_cnt:%lu\n", > > > > pkts-pkts_ok, ++err_cnt); > > > > - > > > > - /* Print packet counts every once in a while > */ > > > > +/* > > > > + // Print packet counts every once in a while > > > > tmp += pkts_ok; > > > > - if (odp_unlikely((tmp >= 100000) || /* OR > first > > > print:*/ > > > > + if (odp_unlikely((tmp >= 100000) || // OR > first > > > print: > > > > ((pkt_cnt == 0) && ((tmp-1) < > > > MAX_PKT_BURST)))) { > > > > pkt_cnt += tmp; > > > > printf(" [%02i] pkt_cnt:%lu\n", > thr, > > > pkt_cnt); > > > > fflush(NULL); > > > > tmp = 0; > > > > } > > > > +*/ > > > > } > > > > } > > > > > > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) > > > > int num_workers; > > > > void *pool_base; > > > > int i; > > > > + int first_core; > > > > + int core_count; > > > > > > > > /* Init ODP before calling anything else */ > > > > if (odp_init_global()) { > > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) > > > > /* Print both system and application information */ > > > > print_info(NO_PATH(argv[0]), &args->appl); > > > > > > > > - num_workers = odp_sys_core_count(); > > > > + core_count = odp_sys_core_count(); > > > > + num_workers = core_count; > > > > + > > > > + if (args->appl.core_count) > > > > + num_workers = args->appl.core_count; > > > > + > > > > if (num_workers > MAX_WORKERS) > > > > num_workers = MAX_WORKERS; > > > > > > > > + printf("Num worker threads: %i\n", num_workers); > > > > + > > > > + /* > > > > + * By default core #0 runs Linux kernel background tasks. > > > > + * Start mapping thread from core #1 > > > > + */ > > > > + first_core = 1; > > > > + > > > > + if (core_count == 1) > > > > + first_core = 0; > > > > + > > > > + printf("First core: %i\n\n", first_core); > > > > + > > > > /* Init this thread */ > > > > thr_id = odp_thread_create(0); > > > > odp_init_local(thr_id); > > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) > > > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > > > for (i = 0; i < num_workers; ++i) { > > > > void *(*thr_run_func) (void *); > > > > - int if_idx = i % args->appl.if_count; > > > > + int core; > > > > + int if_idx; > > > > + > > > > + core = (first_core + i) % core_count; > > > > + > > > > + if_idx = i % args->appl.if_count; > > > > > > > > args->thread[i].pktio_dev = > args->appl.if_names[if_idx]; > > > > args->thread[i].pool = pool; > > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) > > > > * because each thread might get different > arguments. > > > > * Calls odp_thread_create(cpu) for each thread > > > > */ > > > > - odp_linux_pthread_create(thread_tbl, 1, i, > thr_run_func, > > > > + odp_linux_pthread_create(thread_tbl, 1, core, > > > thr_run_func, > > > > &args->thread[i]); > > > > } > > > > > > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], > > > appl_args_t *appl_args) > > > > size_t len; > > > > int i; > > > > static struct option longopts[] = { > > > > + {"count", required_argument, NULL, 'c'}, > > > > {"interface", required_argument, NULL, 'i'}, /* > > > return 'i' */ > > > > {"mode", required_argument, NULL, 'm'}, /* > > > return 'm' */ > > > > {"help", no_argument, NULL, 'h'}, /* > > > return 'h' */ > > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], > > > appl_args_t *appl_args) > > > > appl_args->mode = -1; /* Invalid, must be changed by parsing > */ > > > > > > > > while (1) { > > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, > > > &long_index); > > > > + opt = getopt_long(argc, argv, "+c:i:m:h", > > > > + longopts, &long_index); > > > > > > > > if (opt == -1) > > > > break; /* No more options */ > > > > > > > > switch (opt) { > > > > + case 'c': > > > > + appl_args->core_count = atoi(optarg); > > > > + break; > > > > /* parse packet-io interface names */ > > > > case 'i': > > > > len = strlen(optarg); > > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, > appl_args_t > > > *appl_args) > > > > "Core count: %i\n" > > > > "\n", > > > > odp_version_api_str(), odp_sys_cpu_model_str(), > > > odp_sys_cpu_hz(), > > > > - odp_sys_cache_line_size(), odp_sys_core_count() > > > > - ); > > > > + odp_sys_cache_line_size(), odp_sys_core_count()); > > > > + > > > > printf("Running ODP appl: \"%s\"\n" > > > > "-----------------\n" > > > > "IF-count: %i\n" > > > > @@ -573,7 +607,8 @@ static void usage(char *progname) > > > > " 1: Send&receive packets through > ODP > > > queues.\n" > > > > "\n" > > > > "Optional OPTIONS\n" > > > > - " -h, --help Display help and exit.\n" > > > > + " -c, --count <number> Core count.\n" > > > > + " -h, --help Display help and exit.\n" > > > > "\n", NO_PATH(progname), NO_PATH(progname) > > > > ); > > > > } > > > > -- > > > > 1.8.5.3 > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. > > > > To unsubscribe from this group and stop receiving emails from it, > send > > > an email to lng-odp+u...@linaro.org <javascript:>. > > > > To post to this group, send email to lng...@linaro.org<javascript:>. > > > > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/. > > > > > > > To view this discussion on the web visit > > > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. > > > > > > > > For more options, visit > > > https://groups.google.com/a/linaro.org/groups/opt_out. > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+u...@linaro.org <javascript:>. > > To post to this group, send email to lng...@linaro.org <javascript:>. > > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > > > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org. > > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out. > > -- > Anders Roxell > anders...@linaro.org <javascript:> > M: +46 709 71 42 85 | IRC: roxell >
Should it be a #define ODP_ENABLE_PACKET_DEBUG, I think that would be better than commenting it out. On 27 February 2014 09:17, Petri Savolainen <petri.savolainen@linaro.org>wrote: > > > On Thursday, 27 February 2014 16:03:08 UTC+2, Anders Roxell wrote: > >> On 2014-02-26 05:53, Petri Savolainen wrote: >> > >> > >> > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: >> > >> > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org<javascript:>> >> >> > > wrote: >> > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org<javascript:>> >> > > > --- >> > > >> > > More verbose patch description in header would help for reader. >> > > >> > >> > It adds an option to choose core count (instead of running on all cores >> > which is still the default). >> > >> > >> > > >> > > > test/packet/odp_example_pktio.c | 63 >> > > ++++++++++++++++++++++++++++++++--------- >> > > > 1 file changed, 49 insertions(+), 14 deletions(-) >> > > > >> > > > diff --git a/test/packet/odp_example_pktio.c >> > > b/test/packet/odp_example_pktio.c >> > > > index 875830e..516fe37 100644 >> > > > --- a/test/packet/odp_example_pktio.c >> > > > +++ b/test/packet/odp_example_pktio.c >> > > > @@ -38,6 +38,7 @@ >> > > > * Parsed command line application arguments >> > > > */ >> > > > typedef struct { >> > > > + int core_count; >> > > > int if_count; /**< Number of interfaces to be >> used */ >> > > > char **if_names; /**< Array of pointers to interface >> > > names */ >> > > > int mode; /**< Packet IO mode */ >> > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) >> > > > odp_packet_t pkt; >> > > > odp_buffer_t buf; >> > > > int ret; >> > > > - unsigned long pkt_cnt = 0; >> > > > +/* unsigned long pkt_cnt = 0;*/ >> > > deleting them and other commented code too. >> > > >> > > >> > Those commented printfs on fast path are potential reason for packet >> drops >> > / low throughput. Still investigating that, so didn't remove the code >> yet. >> >> this should not go into the official repository... if you want to have a >> local copy of out commented code just stash it! >> >> > I left those there for others. The test used to print out those lines when > receiving packets. Now when it's not doing that anymore (by default) people > may think that packets stopped going through. It's still easy for others to > uncomment the liens and see the familiar prints. > > -Petri > > > >> Cheers, >> Anders >> >> > >> > -Petri >> > >> > >> > > Thanks. >> > > > unsigned long err_cnt = 0; >> > > > odp_pktio_params_t params; >> > > > socket_params_t *sock_params = ¶ms.sock_params; >> > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) >> > > > /* Enqueue the packet for output */ >> > > > odp_queue_enq(outq_def, buf); >> > > > >> > > > - /* Print packet counts every once in a while */ >> > > > +/* >> > > > + // Print packet counts every once in a while >> > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { >> > > > printf(" [%02i] pkt_cnt:%lu\n", thr, >> pkt_cnt); >> > > > fflush(NULL); >> > > > } >> > > > +*/ >> > > > } >> > > > >> > > > /* unreachable */ >> > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) >> > > > thread_args_t *thr_args; >> > > > int pkts, pkts_ok; >> > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; >> > > > - unsigned long pkt_cnt = 0; >> > > > +/* unsigned long pkt_cnt = 0;*/ >> > > > unsigned long err_cnt = 0; >> > > > - unsigned long tmp = 0; >> > > > +/* unsigned long tmp = 0;*/ >> > > > odp_pktio_params_t params; >> > > > socket_params_t *sock_params = ¶ms.sock_params; >> > > > >> > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) >> > > > if (odp_unlikely(pkts_ok != pkts)) >> > > > ODP_ERR("Dropped frames:%u - >> > > err_cnt:%lu\n", >> > > > pkts-pkts_ok, ++err_cnt); >> > > > - >> > > > - /* Print packet counts every once in a >> while */ >> > > > +/* >> > > > + // Print packet counts every once in a >> while >> > > > tmp += pkts_ok; >> > > > - if (odp_unlikely((tmp >= 100000) || /* OR >> first >> > > print:*/ >> > > > + if (odp_unlikely((tmp >= 100000) || // OR >> first >> > > print: >> > > > ((pkt_cnt == 0) && ((tmp-1) < >> > > MAX_PKT_BURST)))) { >> > > > pkt_cnt += tmp; >> > > > printf(" [%02i] pkt_cnt:%lu\n", >> thr, >> > > pkt_cnt); >> > > > fflush(NULL); >> > > > tmp = 0; >> > > > } >> > > > +*/ >> > > > } >> > > > } >> > > > >> > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) >> > > > int num_workers; >> > > > void *pool_base; >> > > > int i; >> > > > + int first_core; >> > > > + int core_count; >> > > > >> > > > /* Init ODP before calling anything else */ >> > > > if (odp_init_global()) { >> > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) >> > > > /* Print both system and application information */ >> > > > print_info(NO_PATH(argv[0]), &args->appl); >> > > > >> > > > - num_workers = odp_sys_core_count(); >> > > > + core_count = odp_sys_core_count(); >> > > > + num_workers = core_count; >> > > > + >> > > > + if (args->appl.core_count) >> > > > + num_workers = args->appl.core_count; >> > > > + >> > > > if (num_workers > MAX_WORKERS) >> > > > num_workers = MAX_WORKERS; >> > > > >> > > > + printf("Num worker threads: %i\n", num_workers); >> > > > + >> > > > + /* >> > > > + * By default core #0 runs Linux kernel background tasks. >> > > > + * Start mapping thread from core #1 >> > > > + */ >> > > > + first_core = 1; >> > > > + >> > > > + if (core_count == 1) >> > > > + first_core = 0; >> > > > + >> > > > + printf("First core: %i\n\n", first_core); >> > > > + >> > > > /* Init this thread */ >> > > > thr_id = odp_thread_create(0); >> > > > odp_init_local(thr_id); >> > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) >> > > > memset(thread_tbl, 0, sizeof(thread_tbl)); >> > > > for (i = 0; i < num_workers; ++i) { >> > > > void *(*thr_run_func) (void *); >> > > > - int if_idx = i % args->appl.if_count; >> > > > + int core; >> > > > + int if_idx; >> > > > + >> > > > + core = (first_core + i) % core_count; >> > > > + >> > > > + if_idx = i % args->appl.if_count; >> > > > >> > > > args->thread[i].pktio_dev = >> args->appl.if_names[if_idx]; >> > > > args->thread[i].pool = pool; >> > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) >> > > > * because each thread might get different >> arguments. >> > > > * Calls odp_thread_create(cpu) for each thread >> > > > */ >> > > > - odp_linux_pthread_create(thread_tbl, 1, i, >> thr_run_func, >> > > > + odp_linux_pthread_create(thread_tbl, 1, core, >> > > thr_run_func, >> > > > &args->thread[i]); >> > > > } >> > > > >> > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], >> > > appl_args_t *appl_args) >> > > > size_t len; >> > > > int i; >> > > > static struct option longopts[] = { >> > > > + {"count", required_argument, NULL, 'c'}, >> > > > {"interface", required_argument, NULL, 'i'}, /* >> > > return 'i' */ >> > > > {"mode", required_argument, NULL, 'm'}, /* >> > > return 'm' */ >> > > > {"help", no_argument, NULL, 'h'}, /* >> > > return 'h' */ >> > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char >> *argv[], >> > > appl_args_t *appl_args) >> > > > appl_args->mode = -1; /* Invalid, must be changed by >> parsing */ >> > > > >> > > > while (1) { >> > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, >> > > &long_index); >> > > > + opt = getopt_long(argc, argv, "+c:i:m:h", >> > > > + longopts, &long_index); >> > > > >> > > > if (opt == -1) >> > > > break; /* No more options */ >> > > > >> > > > switch (opt) { >> > > > + case 'c': >> > > > + appl_args->core_count = atoi(optarg); >> > > > + break; >> > > > /* parse packet-io interface names */ >> > > > case 'i': >> > > > len = strlen(optarg); >> > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, >> appl_args_t >> > > *appl_args) >> > > > "Core count: %i\n" >> > > > "\n", >> > > > odp_version_api_str(), odp_sys_cpu_model_str(), >> > > odp_sys_cpu_hz(), >> > > > - odp_sys_cache_line_size(), odp_sys_core_count() >> > > > - ); >> > > > + odp_sys_cache_line_size(), odp_sys_core_count()); >> > > > + >> > > > printf("Running ODP appl: \"%s\"\n" >> > > > "-----------------\n" >> > > > "IF-count: %i\n" >> > > > @@ -573,7 +607,8 @@ static void usage(char *progname) >> > > > " 1: Send&receive packets through >> ODP >> > > queues.\n" >> > > > "\n" >> > > > "Optional OPTIONS\n" >> > > > - " -h, --help Display help and exit.\n" >> > > > + " -c, --count <number> Core count.\n" >> > > > + " -h, --help Display help and exit.\n" >> > > > "\n", NO_PATH(progname), NO_PATH(progname) >> > > > ); >> > > > } >> > > > -- >> > > > 1.8.5.3 >> > > > >> > > > -- >> > > > You received this message because you are subscribed to the Google >> > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. >> > > > To unsubscribe from this group and stop receiving emails from it, >> send >> > > an email to lng-odp+u...@linaro.org <javascript:>. >> > > > To post to this group, send email to lng...@linaro.org<javascript:>. >> > > > Visit this group at http://groups.google.com/a/ >> linaro.org/group/lng-odp/. >> > > >> > > > To view this discussion on the web visit >> > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/ >> 1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. >> > > >> > > > For more options, visit >> > > https://groups.google.com/a/linaro.org/groups/opt_out. >> > > >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "LNG ODP Sub-team - lng...@linaro.org" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to lng-odp+u...@linaro.org. >> > To post to this group, send email to lng...@linaro.org. >> > Visit this group at http://groups.google.com/a/ >> linaro.org/group/lng-odp/. >> > To view this discussion on the web visit https://groups.google.com/a/ >> linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50- >> eea50a7504ec%40linaro.org. >> > For more options, visit https://groups.google.com/a/ >> linaro.org/groups/opt_out. >> >> -- >> Anders Roxell >> anders...@linaro.org >> M: +46 709 71 42 85 | IRC: roxell >> > -- > You received this message because you are subscribed to the Google Groups > "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a62d9373-1039-4a3f-ac7b-44b5eb08e78f%40linaro.org > . > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out. >
Actually that is way better, I can then build it in regression and ensure the code does not rot. On 27 February 2014 09:19, Mike Holmes <mike.holmes@linaro.org> wrote: > Should it be a #define ODP_ENABLE_PACKET_DEBUG, I think that would be > better than commenting it out. > > > On 27 February 2014 09:17, Petri Savolainen <petri.savolainen@linaro.org>wrote: > >> >> >> On Thursday, 27 February 2014 16:03:08 UTC+2, Anders Roxell wrote: >> >>> On 2014-02-26 05:53, Petri Savolainen wrote: >>> > >>> > >>> > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: >>> > >>> > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org<javascript:>> >>> >>> > > wrote: >>> > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org<javascript:>> >>> > > > --- >>> > > >>> > > More verbose patch description in header would help for reader. >>> > > >>> > >>> > It adds an option to choose core count (instead of running on all >>> cores >>> > which is still the default). >>> > >>> > >>> > > >>> > > > test/packet/odp_example_pktio.c | 63 >>> > > ++++++++++++++++++++++++++++++++--------- >>> > > > 1 file changed, 49 insertions(+), 14 deletions(-) >>> > > > >>> > > > diff --git a/test/packet/odp_example_pktio.c >>> > > b/test/packet/odp_example_pktio.c >>> > > > index 875830e..516fe37 100644 >>> > > > --- a/test/packet/odp_example_pktio.c >>> > > > +++ b/test/packet/odp_example_pktio.c >>> > > > @@ -38,6 +38,7 @@ >>> > > > * Parsed command line application arguments >>> > > > */ >>> > > > typedef struct { >>> > > > + int core_count; >>> > > > int if_count; /**< Number of interfaces to be >>> used */ >>> > > > char **if_names; /**< Array of pointers to >>> interface >>> > > names */ >>> > > > int mode; /**< Packet IO mode */ >>> > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) >>> > > > odp_packet_t pkt; >>> > > > odp_buffer_t buf; >>> > > > int ret; >>> > > > - unsigned long pkt_cnt = 0; >>> > > > +/* unsigned long pkt_cnt = 0;*/ >>> > > deleting them and other commented code too. >>> > > >>> > > >>> > Those commented printfs on fast path are potential reason for packet >>> drops >>> > / low throughput. Still investigating that, so didn't remove the code >>> yet. >>> >>> this should not go into the official repository... if you want to have a >>> local copy of out commented code just stash it! >>> >>> >> I left those there for others. The test used to print out those lines >> when receiving packets. Now when it's not doing that anymore (by default) >> people may think that packets stopped going through. It's still easy for >> others to uncomment the liens and see the familiar prints. >> >> -Petri >> >> >> >>> Cheers, >>> Anders >>> >>> > >>> > -Petri >>> > >>> > >>> > > Thanks. >>> > > > unsigned long err_cnt = 0; >>> > > > odp_pktio_params_t params; >>> > > > socket_params_t *sock_params = ¶ms.sock_params; >>> > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) >>> > > > /* Enqueue the packet for output */ >>> > > > odp_queue_enq(outq_def, buf); >>> > > > >>> > > > - /* Print packet counts every once in a while */ >>> > > > +/* >>> > > > + // Print packet counts every once in a while >>> > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { >>> > > > printf(" [%02i] pkt_cnt:%lu\n", thr, >>> pkt_cnt); >>> > > > fflush(NULL); >>> > > > } >>> > > > +*/ >>> > > > } >>> > > > >>> > > > /* unreachable */ >>> > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) >>> > > > thread_args_t *thr_args; >>> > > > int pkts, pkts_ok; >>> > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; >>> > > > - unsigned long pkt_cnt = 0; >>> > > > +/* unsigned long pkt_cnt = 0;*/ >>> > > > unsigned long err_cnt = 0; >>> > > > - unsigned long tmp = 0; >>> > > > +/* unsigned long tmp = 0;*/ >>> > > > odp_pktio_params_t params; >>> > > > socket_params_t *sock_params = ¶ms.sock_params; >>> > > > >>> > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) >>> > > > if (odp_unlikely(pkts_ok != pkts)) >>> > > > ODP_ERR("Dropped frames:%u - >>> > > err_cnt:%lu\n", >>> > > > pkts-pkts_ok, ++err_cnt); >>> > > > - >>> > > > - /* Print packet counts every once in a >>> while */ >>> > > > +/* >>> > > > + // Print packet counts every once in a >>> while >>> > > > tmp += pkts_ok; >>> > > > - if (odp_unlikely((tmp >= 100000) || /* OR >>> first >>> > > print:*/ >>> > > > + if (odp_unlikely((tmp >= 100000) || // OR >>> first >>> > > print: >>> > > > ((pkt_cnt == 0) && ((tmp-1) < >>> > > MAX_PKT_BURST)))) { >>> > > > pkt_cnt += tmp; >>> > > > printf(" [%02i] pkt_cnt:%lu\n", >>> thr, >>> > > pkt_cnt); >>> > > > fflush(NULL); >>> > > > tmp = 0; >>> > > > } >>> > > > +*/ >>> > > > } >>> > > > } >>> > > > >>> > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) >>> > > > int num_workers; >>> > > > void *pool_base; >>> > > > int i; >>> > > > + int first_core; >>> > > > + int core_count; >>> > > > >>> > > > /* Init ODP before calling anything else */ >>> > > > if (odp_init_global()) { >>> > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) >>> > > > /* Print both system and application information */ >>> > > > print_info(NO_PATH(argv[0]), &args->appl); >>> > > > >>> > > > - num_workers = odp_sys_core_count(); >>> > > > + core_count = odp_sys_core_count(); >>> > > > + num_workers = core_count; >>> > > > + >>> > > > + if (args->appl.core_count) >>> > > > + num_workers = args->appl.core_count; >>> > > > + >>> > > > if (num_workers > MAX_WORKERS) >>> > > > num_workers = MAX_WORKERS; >>> > > > >>> > > > + printf("Num worker threads: %i\n", num_workers); >>> > > > + >>> > > > + /* >>> > > > + * By default core #0 runs Linux kernel background tasks. >>> > > > + * Start mapping thread from core #1 >>> > > > + */ >>> > > > + first_core = 1; >>> > > > + >>> > > > + if (core_count == 1) >>> > > > + first_core = 0; >>> > > > + >>> > > > + printf("First core: %i\n\n", first_core); >>> > > > + >>> > > > /* Init this thread */ >>> > > > thr_id = odp_thread_create(0); >>> > > > odp_init_local(thr_id); >>> > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) >>> > > > memset(thread_tbl, 0, sizeof(thread_tbl)); >>> > > > for (i = 0; i < num_workers; ++i) { >>> > > > void *(*thr_run_func) (void *); >>> > > > - int if_idx = i % args->appl.if_count; >>> > > > + int core; >>> > > > + int if_idx; >>> > > > + >>> > > > + core = (first_core + i) % core_count; >>> > > > + >>> > > > + if_idx = i % args->appl.if_count; >>> > > > >>> > > > args->thread[i].pktio_dev = >>> args->appl.if_names[if_idx]; >>> > > > args->thread[i].pool = pool; >>> > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) >>> > > > * because each thread might get different >>> arguments. >>> > > > * Calls odp_thread_create(cpu) for each thread >>> > > > */ >>> > > > - odp_linux_pthread_create(thread_tbl, 1, i, >>> thr_run_func, >>> > > > + odp_linux_pthread_create(thread_tbl, 1, core, >>> > > thr_run_func, >>> > > > &args->thread[i]); >>> > > > } >>> > > > >>> > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], >>> > > appl_args_t *appl_args) >>> > > > size_t len; >>> > > > int i; >>> > > > static struct option longopts[] = { >>> > > > + {"count", required_argument, NULL, 'c'}, >>> > > > {"interface", required_argument, NULL, 'i'}, /* >>> > > return 'i' */ >>> > > > {"mode", required_argument, NULL, 'm'}, /* >>> > > return 'm' */ >>> > > > {"help", no_argument, NULL, 'h'}, /* >>> > > return 'h' */ >>> > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char >>> *argv[], >>> > > appl_args_t *appl_args) >>> > > > appl_args->mode = -1; /* Invalid, must be changed by >>> parsing */ >>> > > > >>> > > > while (1) { >>> > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, >>> > > &long_index); >>> > > > + opt = getopt_long(argc, argv, "+c:i:m:h", >>> > > > + longopts, &long_index); >>> > > > >>> > > > if (opt == -1) >>> > > > break; /* No more options */ >>> > > > >>> > > > switch (opt) { >>> > > > + case 'c': >>> > > > + appl_args->core_count = atoi(optarg); >>> > > > + break; >>> > > > /* parse packet-io interface names */ >>> > > > case 'i': >>> > > > len = strlen(optarg); >>> > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, >>> appl_args_t >>> > > *appl_args) >>> > > > "Core count: %i\n" >>> > > > "\n", >>> > > > odp_version_api_str(), odp_sys_cpu_model_str(), >>> > > odp_sys_cpu_hz(), >>> > > > - odp_sys_cache_line_size(), odp_sys_core_count() >>> > > > - ); >>> > > > + odp_sys_cache_line_size(), odp_sys_core_count()); >>> > > > + >>> > > > printf("Running ODP appl: \"%s\"\n" >>> > > > "-----------------\n" >>> > > > "IF-count: %i\n" >>> > > > @@ -573,7 +607,8 @@ static void usage(char *progname) >>> > > > " 1: Send&receive packets through >>> ODP >>> > > queues.\n" >>> > > > "\n" >>> > > > "Optional OPTIONS\n" >>> > > > - " -h, --help Display help and exit.\n" >>> > > > + " -c, --count <number> Core count.\n" >>> > > > + " -h, --help Display help and exit.\n" >>> > > > "\n", NO_PATH(progname), NO_PATH(progname) >>> > > > ); >>> > > > } >>> > > > -- >>> > > > 1.8.5.3 >>> > > > >>> > > > -- >>> > > > You received this message because you are subscribed to the Google >>> > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. >>> > > > To unsubscribe from this group and stop receiving emails from it, >>> send >>> > > an email to lng-odp+u...@linaro.org <javascript:>. >>> > > > To post to this group, send email to lng...@linaro.org<javascript:>. >>> > > > Visit this group at http://groups.google.com/a/ >>> linaro.org/group/lng-odp/. >>> > > >>> > > > To view this discussion on the web visit >>> > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/ >>> 1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. >>> > > >>> > > > For more options, visit >>> > > https://groups.google.com/a/linaro.org/groups/opt_out. >>> > > >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> Groups "LNG ODP Sub-team - lng...@linaro.org" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an email to lng-odp+u...@linaro.org. >>> > To post to this group, send email to lng...@linaro.org. >>> > Visit this group at http://groups.google.com/a/ >>> linaro.org/group/lng-odp/. >>> > To view this discussion on the web visit https://groups.google.com/a/ >>> linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50- >>> eea50a7504ec%40linaro.org. >>> > For more options, visit https://groups.google.com/a/ >>> linaro.org/groups/opt_out. >>> >>> -- >>> Anders Roxell >>> anders...@linaro.org >>> M: +46 709 71 42 85 | IRC: roxell >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "LNG ODP Sub-team - lng-odp@linaro.org" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to lng-odp+unsubscribe@linaro.org. >> To post to this group, send email to lng-odp@linaro.org. >> Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. >> To view this discussion on the web visit >> https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a62d9373-1039-4a3f-ac7b-44b5eb08e78f%40linaro.org >> . >> >> For more options, visit >> https://groups.google.com/a/linaro.org/groups/opt_out. >> > >
I'm not going to #ifdef, but delete those in a future patch, if others (e.g. your CI loop) do not depend on those printouts. -Petri On Thursday, 27 February 2014 16:19:57 UTC+2, Mike Holmes wrote: > > Actually that is way better, I can then build it in regression and ensure > the code does not rot. > > > On 27 February 2014 09:19, Mike Holmes <mike....@linaro.org <javascript:>>wrote: > >> Should it be a #define ODP_ENABLE_PACKET_DEBUG, I think that would be >> better than commenting it out. >> >> >> On 27 February 2014 09:17, Petri Savolainen <petri.sa...@linaro.org<javascript:> >> > wrote: >> >>> >>> >>> On Thursday, 27 February 2014 16:03:08 UTC+2, Anders Roxell wrote: >>> >>>> On 2014-02-26 05:53, Petri Savolainen wrote: >>>> > >>>> > >>>> > On Wednesday, 26 February 2014 15:14:08 UTC+2, Santosh Shukla wrote: >>>> > >>>> > > On 26 February 2014 17:00, Petri Savolainen <petri.sa...@linaro.org >>>> <javascript:>> >>>> > > wrote: >>>> > > > Signed-off-by: Petri Savolainen <petri.sa...@linaro.org<javascript:>> >>>> > > > --- >>>> > > >>>> > > More verbose patch description in header would help for reader. >>>> > > >>>> > >>>> > It adds an option to choose core count (instead of running on all >>>> cores >>>> > which is still the default). >>>> > >>>> > >>>> > > >>>> > > > test/packet/odp_example_pktio.c | 63 >>>> > > ++++++++++++++++++++++++++++++++--------- >>>> > > > 1 file changed, 49 insertions(+), 14 deletions(-) >>>> > > > >>>> > > > diff --git a/test/packet/odp_example_pktio.c >>>> > > b/test/packet/odp_example_pktio.c >>>> > > > index 875830e..516fe37 100644 >>>> > > > --- a/test/packet/odp_example_pktio.c >>>> > > > +++ b/test/packet/odp_example_pktio.c >>>> > > > @@ -38,6 +38,7 @@ >>>> > > > * Parsed command line application arguments >>>> > > > */ >>>> > > > typedef struct { >>>> > > > + int core_count; >>>> > > > int if_count; /**< Number of interfaces to be >>>> used */ >>>> > > > char **if_names; /**< Array of pointers to >>>> interface >>>> > > names */ >>>> > > > int mode; /**< Packet IO mode */ >>>> > > > @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) >>>> > > > odp_packet_t pkt; >>>> > > > odp_buffer_t buf; >>>> > > > int ret; >>>> > > > - unsigned long pkt_cnt = 0; >>>> > > > +/* unsigned long pkt_cnt = 0;*/ >>>> > > deleting them and other commented code too. >>>> > > >>>> > > >>>> > Those commented printfs on fast path are potential reason for packet >>>> drops >>>> > / low throughput. Still investigating that, so didn't remove the code >>>> yet. >>>> >>>> this should not go into the official repository... if you want to have >>>> a >>>> local copy of out commented code just stash it! >>>> >>>> >>> I left those there for others. The test used to print out those lines >>> when receiving packets. Now when it's not doing that anymore (by default) >>> people may think that packets stopped going through. It's still easy for >>> others to uncomment the liens and see the familiar prints. >>> >>> -Petri >>> >>> >>> >>>> Cheers, >>>> Anders >>>> >>>> > >>>> > -Petri >>>> > >>>> > >>>> > > Thanks. >>>> > > > unsigned long err_cnt = 0; >>>> > > > odp_pktio_params_t params; >>>> > > > socket_params_t *sock_params = ¶ms.sock_params; >>>> > > > @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) >>>> > > > /* Enqueue the packet for output */ >>>> > > > odp_queue_enq(outq_def, buf); >>>> > > > >>>> > > > - /* Print packet counts every once in a while */ >>>> > > > +/* >>>> > > > + // Print packet counts every once in a while >>>> > > > if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { >>>> > > > printf(" [%02i] pkt_cnt:%lu\n", thr, >>>> pkt_cnt); >>>> > > > fflush(NULL); >>>> > > > } >>>> > > > +*/ >>>> > > > } >>>> > > > >>>> > > > /* unreachable */ >>>> > > > @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) >>>> > > > thread_args_t *thr_args; >>>> > > > int pkts, pkts_ok; >>>> > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; >>>> > > > - unsigned long pkt_cnt = 0; >>>> > > > +/* unsigned long pkt_cnt = 0;*/ >>>> > > > unsigned long err_cnt = 0; >>>> > > > - unsigned long tmp = 0; >>>> > > > +/* unsigned long tmp = 0;*/ >>>> > > > odp_pktio_params_t params; >>>> > > > socket_params_t *sock_params = ¶ms.sock_params; >>>> > > > >>>> > > > @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void >>>> *arg) >>>> > > > if (odp_unlikely(pkts_ok != pkts)) >>>> > > > ODP_ERR("Dropped frames:%u - >>>> > > err_cnt:%lu\n", >>>> > > > pkts-pkts_ok, ++err_cnt); >>>> > > > - >>>> > > > - /* Print packet counts every once in a >>>> while */ >>>> > > > +/* >>>> > > > + // Print packet counts every once in a >>>> while >>>> > > > tmp += pkts_ok; >>>> > > > - if (odp_unlikely((tmp >= 100000) || /* OR >>>> first >>>> > > print:*/ >>>> > > > + if (odp_unlikely((tmp >= 100000) || // OR >>>> first >>>> > > print: >>>> > > > ((pkt_cnt == 0) && ((tmp-1) < >>>> > > MAX_PKT_BURST)))) { >>>> > > > pkt_cnt += tmp; >>>> > > > printf(" [%02i] pkt_cnt:%lu\n", >>>> thr, >>>> > > pkt_cnt); >>>> > > > fflush(NULL); >>>> > > > tmp = 0; >>>> > > > } >>>> > > > +*/ >>>> > > > } >>>> > > > } >>>> > > > >>>> > > > @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) >>>> > > > int num_workers; >>>> > > > void *pool_base; >>>> > > > int i; >>>> > > > + int first_core; >>>> > > > + int core_count; >>>> > > > >>>> > > > /* Init ODP before calling anything else */ >>>> > > > if (odp_init_global()) { >>>> > > > @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) >>>> > > > /* Print both system and application information */ >>>> > > > print_info(NO_PATH(argv[0]), &args->appl); >>>> > > > >>>> > > > - num_workers = odp_sys_core_count(); >>>> > > > + core_count = odp_sys_core_count(); >>>> > > > + num_workers = core_count; >>>> > > > + >>>> > > > + if (args->appl.core_count) >>>> > > > + num_workers = args->appl.core_count; >>>> > > > + >>>> > > > if (num_workers > MAX_WORKERS) >>>> > > > num_workers = MAX_WORKERS; >>>> > > > >>>> > > > + printf("Num worker threads: %i\n", num_workers); >>>> > > > + >>>> > > > + /* >>>> > > > + * By default core #0 runs Linux kernel background tasks. >>>> > > > + * Start mapping thread from core #1 >>>> > > > + */ >>>> > > > + first_core = 1; >>>> > > > + >>>> > > > + if (core_count == 1) >>>> > > > + first_core = 0; >>>> > > > + >>>> > > > + printf("First core: %i\n\n", first_core); >>>> > > > + >>>> > > > /* Init this thread */ >>>> > > > thr_id = odp_thread_create(0); >>>> > > > odp_init_local(thr_id); >>>> > > > @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) >>>> > > > memset(thread_tbl, 0, sizeof(thread_tbl)); >>>> > > > for (i = 0; i < num_workers; ++i) { >>>> > > > void *(*thr_run_func) (void *); >>>> > > > - int if_idx = i % args->appl.if_count; >>>> > > > + int core; >>>> > > > + int if_idx; >>>> > > > + >>>> > > > + core = (first_core + i) % core_count; >>>> > > > + >>>> > > > + if_idx = i % args->appl.if_count; >>>> > > > >>>> > > > args->thread[i].pktio_dev = >>>> args->appl.if_names[if_idx]; >>>> > > > args->thread[i].pool = pool; >>>> > > > @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) >>>> > > > * because each thread might get different >>>> arguments. >>>> > > > * Calls odp_thread_create(cpu) for each thread >>>> > > > */ >>>> > > > - odp_linux_pthread_create(thread_tbl, 1, i, >>>> thr_run_func, >>>> > > > + odp_linux_pthread_create(thread_tbl, 1, core, >>>> > > thr_run_func, >>>> > > > &args->thread[i]); >>>> > > > } >>>> > > > >>>> > > > @@ -436,6 +465,7 @@ static void parse_args(int argc, char >>>> *argv[], >>>> > > appl_args_t *appl_args) >>>> > > > size_t len; >>>> > > > int i; >>>> > > > static struct option longopts[] = { >>>> > > > + {"count", required_argument, NULL, 'c'}, >>>> > > > {"interface", required_argument, NULL, 'i'}, >>>> /* >>>> > > return 'i' */ >>>> > > > {"mode", required_argument, NULL, 'm'}, >>>> /* >>>> > > return 'm' */ >>>> > > > {"help", no_argument, NULL, 'h'}, >>>> /* >>>> > > return 'h' */ >>>> > > > @@ -445,12 +475,16 @@ static void parse_args(int argc, char >>>> *argv[], >>>> > > appl_args_t *appl_args) >>>> > > > appl_args->mode = -1; /* Invalid, must be changed by >>>> parsing */ >>>> > > > >>>> > > > while (1) { >>>> > > > - opt = getopt_long(argc, argv, "+i:m:h", longopts, >>>> > > &long_index); >>>> > > > + opt = getopt_long(argc, argv, "+c:i:m:h", >>>> > > > + longopts, &long_index); >>>> > > > >>>> > > > if (opt == -1) >>>> > > > break; /* No more options */ >>>> > > > >>>> > > > switch (opt) { >>>> > > > + case 'c': >>>> > > > + appl_args->core_count = atoi(optarg); >>>> > > > + break; >>>> > > > /* parse packet-io interface names */ >>>> > > > case 'i': >>>> > > > len = strlen(optarg); >>>> > > > @@ -537,8 +571,8 @@ static void print_info(char *progname, >>>> appl_args_t >>>> > > *appl_args) >>>> > > > "Core count: %i\n" >>>> > > > "\n", >>>> > > > odp_version_api_str(), odp_sys_cpu_model_str(), >>>> > > odp_sys_cpu_hz(), >>>> > > > - odp_sys_cache_line_size(), odp_sys_core_count() >>>> > > > - ); >>>> > > > + odp_sys_cache_line_size(), odp_sys_core_count()); >>>> > > > + >>>> > > > printf("Running ODP appl: \"%s\"\n" >>>> > > > "-----------------\n" >>>> > > > "IF-count: %i\n" >>>> > > > @@ -573,7 +607,8 @@ static void usage(char *progname) >>>> > > > " 1: Send&receive packets through >>>> ODP >>>> > > queues.\n" >>>> > > > "\n" >>>> > > > "Optional OPTIONS\n" >>>> > > > - " -h, --help Display help and exit.\n" >>>> > > > + " -c, --count <number> Core count.\n" >>>> > > > + " -h, --help Display help and exit.\n" >>>> > > > "\n", NO_PATH(progname), NO_PATH(progname) >>>> > > > ); >>>> > > > } >>>> > > > -- >>>> > > > 1.8.5.3 >>>> > > > >>>> > > > -- >>>> > > > You received this message because you are subscribed to the >>>> Google >>>> > > Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. >>>> > > > To unsubscribe from this group and stop receiving emails from it, >>>> send >>>> > > an email to lng-odp+u...@linaro.org <javascript:>. >>>> > > > To post to this group, send email to lng...@linaro.org<javascript:>. >>>> > > > Visit this group at http://groups.google.com/a/ >>>> linaro.org/group/lng-odp/. >>>> > > >>>> > > > To view this discussion on the web visit >>>> > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/ >>>> 1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org. >>>> > > >>>> > > > For more options, visit >>>> > > https://groups.google.com/a/linaro.org/groups/opt_out. >>>> > > >>>> > >>>> > -- >>>> > You received this message because you are subscribed to the Google >>>> Groups "LNG ODP Sub-team - lng...@linaro.org" group. >>>> > To unsubscribe from this group and stop receiving emails from it, >>>> send an email to lng-odp+u...@linaro.org. >>>> > To post to this group, send email to lng...@linaro.org. >>>> > Visit this group at http://groups.google.com/a/ >>>> linaro.org/group/lng-odp/. >>>> > To view this discussion on the web visit https://groups.google.com/a/ >>>> linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50- >>>> eea50a7504ec%40linaro.org. >>>> > For more options, visit https://groups.google.com/a/ >>>> linaro.org/groups/opt_out. >>>> >>>> -- >>>> Anders Roxell >>>> anders...@linaro.org >>>> M: +46 709 71 42 85 | IRC: roxell >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "LNG ODP Sub-team - lng...@linaro.org <javascript:>" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to lng-odp+u...@linaro.org <javascript:>. >>> To post to this group, send email to lng...@linaro.org <javascript:>. >>> Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/ >>> . >>> To view this discussion on the web visit >>> https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a62d9373-1039-4a3f-ac7b-44b5eb08e78f%40linaro.org >>> . >>> >>> For more options, visit >>> https://groups.google.com/a/linaro.org/groups/opt_out. >>> >> >> >
On 02/27/2014 06:30 PM, Petri Savolainen wrote: > > I'm not going to #ifdef, but delete those in a future patch, if others > (e.g. your CI loop) do not depend on those printouts. > > -Petri > What about leave cnt code there and wrap printf with ODP_DEBUG? Maxim. > On Thursday, 27 February 2014 16:19:57 UTC+2, Mike Holmes wrote: > > Actually that is way better, I can then build it in regression and > ensure the code does not rot. > > > On 27 February 2014 09:19, Mike Holmes <mike....@linaro.org > <javascript:>> wrote: > > Should it be a #define ODP_ENABLE_PACKET_DEBUG, I think that > would be better than commenting it out. > > > On 27 February 2014 09:17, Petri Savolainen > <petri.sa...@linaro.org <javascript:>> wrote: > > > > On Thursday, 27 February 2014 16:03:08 UTC+2, Anders > Roxell wrote: > > On 2014-02-26 05:53, Petri Savolainen wrote: > > > > > > On Wednesday, 26 February 2014 15:14:08 UTC+2, > Santosh Shukla wrote: > > > > > On 26 February 2014 17:00, Petri Savolainen > <petri.sa...@linaro.org<javascript:>> > > > wrote: > > > > Signed-off-by: Petri Savolainen > <petri.sa...@linaro.org <javascript:>> > > > > --- > > > > > > More verbose patch description in header would > help for reader. > > > > > > > It adds an option to choose core count (instead of > running on all cores > > which is still the default). > > > > > > > > > > > test/packet/odp_example_pktio.c | 63 > > > ++++++++++++++++++++++++++++++++--------- > > > > 1 file changed, 49 insertions(+), 14 deletions(-) > > > > > > > > diff --git a/test/packet/odp_example_pktio.c > > > b/test/packet/odp_example_pktio.c > > > > index 875830e..516fe37 100644 > > > > --- a/test/packet/odp_example_pktio.c > > > > +++ b/test/packet/odp_example_pktio.c > > > > @@ -38,6 +38,7 @@ > > > > * Parsed command line application arguments > > > > */ > > > > typedef struct { > > > > + int core_count; > > > > int if_count; /**< Number of > interfaces to be used */ > > > > char **if_names; /**< Array of > pointers to interface > > > names */ > > > > int mode; /**< Packet IO mode */ > > > > @@ -91,7 +92,7 @@ static void > *pktio_queue_thread(void *arg) > > > > odp_packet_t pkt; > > > > odp_buffer_t buf; > > > > int ret; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > deleting them and other commented code too. > > > > > > > > Those commented printfs on fast path are potential > reason for packet drops > > / low throughput. Still investigating that, so > didn't remove the code yet. > > this should not go into the official repository... if > you want to have a > local copy of out commented code just stash it! > > > I left those there for others. The test used to print out > those lines when receiving packets. Now when it's not > doing that anymore (by default) people may think that > packets stopped going through. It's still easy for others > to uncomment the liens and see the familiar prints. > > -Petri > > Cheers, > Anders > > > > > -Petri > > > > > > > Thanks. > > > > unsigned long err_cnt = 0; > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = > ¶ms.sock_params; > > > > @@ -179,11 +180,13 @@ static void > *pktio_queue_thread(void *arg) > > > > /* Enqueue the packet for output */ > > > > odp_queue_enq(outq_def, buf); > > > > > > > > - /* Print packet counts every > once in a while */ > > > > +/* > > > > + // Print packet counts every > once in a while > > > > if (odp_unlikely(pkt_cnt++ % > 100000 == 0)) { > > > > printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); > > > > fflush(NULL); > > > > } > > > > +*/ > > > > } > > > > > > > > /* unreachable */ > > > > @@ -202,9 +205,9 @@ static void > *pktio_ifburst_thread(void *arg) > > > > thread_args_t *thr_args; > > > > int pkts, pkts_ok; > > > > odp_packet_t pkt_tbl[MAX_PKT_BURST]; > > > > - unsigned long pkt_cnt = 0; > > > > +/* unsigned long pkt_cnt = 0;*/ > > > > unsigned long err_cnt = 0; > > > > - unsigned long tmp = 0; > > > > +/* unsigned long tmp = 0;*/ > > > > odp_pktio_params_t params; > > > > socket_params_t *sock_params = > ¶ms.sock_params; > > > > > > > > @@ -247,16 +250,17 @@ static void > *pktio_ifburst_thread(void *arg) > > > > if (odp_unlikely(pkts_ok != pkts)) > > > > ODP_ERR("Dropped frames:%u - > > > err_cnt:%lu\n", > > > > pkts-pkts_ok, ++err_cnt); > > > > - > > > > - /* Print packet counts every once in a while */ > > > > +/* > > > > + // Print packet counts every once in a while > > > > tmp += pkts_ok; > > > > - if (odp_unlikely((tmp >= 100000) || /* OR first > > > print:*/ > > > > + if (odp_unlikely((tmp >= 100000) || // OR first > > > print: > > > > ((pkt_cnt == 0) && ((tmp-1) < > > > MAX_PKT_BURST)))) { > > > > pkt_cnt += tmp; > > > > printf(" [%02i] pkt_cnt:%lu\n", thr, > > > pkt_cnt); > > > > fflush(NULL); > > > > tmp = 0; > > > > } > > > > +*/ > > > > } > > > > } > > > > > > > > @@ -274,6 +278,8 @@ int main(int argc, char > *argv[]) > > > > int num_workers; > > > > void *pool_base; > > > > int i; > > > > + int first_core; > > > > + int core_count; > > > > > > > > /* Init ODP before calling anything else */ > > > > if (odp_init_global()) { > > > > @@ -295,10 +301,28 @@ int main(int argc, char > *argv[]) > > > > /* Print both system and application > information */ > > > > print_info(NO_PATH(argv[0]), &args->appl); > > > > > > > > - num_workers = odp_sys_core_count(); > > > > + core_count = odp_sys_core_count(); > > > > + num_workers = core_count; > > > > + > > > > + if (args->appl.core_count) > > > > + num_workers = args->appl.core_count; > > > > + > > > > if (num_workers > MAX_WORKERS) > > > > num_workers = MAX_WORKERS; > > > > > > > > + printf("Num worker threads: %i\n", > num_workers); > > > > + > > > > + /* > > > > + * By default core #0 runs Linux kernel > background tasks. > > > > + * Start mapping thread from core #1 > > > > + */ > > > > + first_core = 1; > > > > + > > > > + if (core_count == 1) > > > > + first_core = 0; > > > > + > > > > + printf("First core: %i\n\n", > first_core); > > > > + > > > > /* Init this thread */ > > > > thr_id = odp_thread_create(0); > > > > odp_init_local(thr_id); > > > > @@ -326,7 +350,12 @@ int main(int argc, char > *argv[]) > > > > memset(thread_tbl, 0, sizeof(thread_tbl)); > > > > for (i = 0; i < num_workers; ++i) { > > > > void *(*thr_run_func) (void *); > > > > - int if_idx = i % > args->appl.if_count; > > > > + int core; > > > > + int if_idx; > > > > + > > > > + core = (first_core + i) % > core_count; > > > > + > > > > + if_idx = i % args->appl.if_count; > > > > > > > > args->thread[i].pktio_dev = > args->appl.if_names[if_idx]; > > > > args->thread[i].pool = pool; > > > > @@ -341,7 +370,7 @@ int main(int argc, char > *argv[]) > > > > * because each thread might get > different arguments. > > > > * Calls odp_thread_create(cpu) > for each thread > > > > */ > > > > - odp_linux_pthread_create(thread_tbl, 1, i, > thr_run_func, > > > > + odp_linux_pthread_create(thread_tbl, 1, core, > > > thr_run_func, > > > > &args->thread[i]); > > > > } > > > > > > > > @@ -436,6 +465,7 @@ static void parse_args(int > argc, char *argv[], > > > appl_args_t *appl_args) > > > > size_t len; > > > > int i; > > > > static struct option longopts[] = { > > > > + {"count", required_argument, NULL, 'c'}, > > > > {"interface", required_argument, NULL, 'i'}, /* > > > return 'i' */ > > > > {"mode", required_argument, NULL, 'm'}, /* > > > return 'm' */ > > > > {"help", no_argument, NULL, 'h'}, /* > > > return 'h' */ > > > > @@ -445,12 +475,16 @@ static void parse_args(int > argc, char *argv[], > > > appl_args_t *appl_args) > > > > appl_args->mode = -1; /* Invalid, must be > changed by parsing */ > > > > > > > > while (1) { > > > > - opt = getopt_long(argc, argv, > "+i:m:h", longopts, > > > &long_index); > > > > + opt = getopt_long(argc, argv, > "+c:i:m:h", > > > > + longopts, &long_index); > > > > > > > > if (opt == -1) > > > > break; /* No more options */ > > > > > > > > switch (opt) { > > > > + case 'c': > > > > + appl_args->core_count = atoi(optarg); > > > > + break; > > > > /* parse packet-io interface names */ > > > > case 'i': > > > > len = strlen(optarg); > > > > @@ -537,8 +571,8 @@ static void print_info(char > *progname, appl_args_t > > > *appl_args) > > > > "Core count: %i\n" > > > > "\n", > > > > odp_version_api_str(), odp_sys_cpu_model_str(), > > > odp_sys_cpu_hz(), > > > > - odp_sys_cache_line_size(), odp_sys_core_count() > > > > - ); > > > > + odp_sys_cache_line_size(), > odp_sys_core_count()); > > > > + > > > > printf("Running ODP appl: \"%s\"\n" > > > > "-----------------\n" > > > > "IF-count: %i\n" > > > > @@ -573,7 +607,8 @@ static void usage(char > *progname) > > > > " 1: Send&receive > packets through ODP > > > queues.\n" > > > > "\n" > > > > "Optional OPTIONS\n" > > > > - " -h, --help Display help > and exit.\n" > > > > + " -c, --count <number> Core > count.\n" > > > > + " -h, --help Display > help and exit.\n" > > > > "\n", NO_PATH(progname), > NO_PATH(progname) > > > > ); > > > > } > > > > -- > > > > 1.8.5.3 > > > > > > > > -- > > > > You received this message because you are > subscribed to the Google > > > Groups "LNG ODP Sub-team - lng...@linaro.org > <javascript:>" group. > > > > To unsubscribe from this group and stop > receiving emails from it, send > > > an email to lng-odp+u...@linaro.org <javascript:>. > > > > To post to this group, send email to > lng...@linaro.org <javascript:>. > > > > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/ > <http://groups.google.com/a/linaro.org/group/lng-odp/>. > > > > > > > To view this discussion on the web visit > > > > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/1393414244-17012-1-git-send-email-petri.savolainen%40linaro.org>. > > > > > > > > For more options, visit > > > > https://groups.google.com/a/linaro.org/groups/opt_out > <https://groups.google.com/a/linaro.org/groups/opt_out>. > > > > > > > -- > > You received this message because you are subscribed > to the Google Groups "LNG ODP Sub-team - > lng...@linaro.org" group. > > To unsubscribe from this group and stop receiving > emails from it, send an email to lng-odp+u...@linaro.org. > > To post to this group, send email to lng...@linaro.org. > > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/ > <http://groups.google.com/a/linaro.org/group/lng-odp/>. > > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/c5c0090d-ccc7-4d03-bc50-eea50a7504ec%40linaro.org>. > > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out > <https://groups.google.com/a/linaro.org/groups/opt_out>. > > -- > Anders Roxell > anders...@linaro.org > M: +46 709 71 42 85 | IRC: roxell > > -- > You received this message because you are subscribed to > the Google Groups "LNG ODP Sub-team - lng...@linaro.org > <javascript:>" group. > To unsubscribe from this group and stop receiving emails > from it, send an email to lng-odp+u...@linaro.org > <javascript:>. > To post to this group, send email to lng...@linaro.org > <javascript:>. > Visit this group at > http://groups.google.com/a/linaro.org/group/lng-odp/ > <http://groups.google.com/a/linaro.org/group/lng-odp/>. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a62d9373-1039-4a3f-ac7b-44b5eb08e78f%40linaro.org > <https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a62d9373-1039-4a3f-ac7b-44b5eb08e78f%40linaro.org>. > > > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out > <https://groups.google.com/a/linaro.org/groups/opt_out>. > > > > -- > You received this message because you are subscribed to the Google > Groups "LNG ODP Sub-team - lng-odp@linaro.org" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to lng-odp+unsubscribe@linaro.org. > To post to this group, send email to lng-odp@linaro.org. > Visit this group at http://groups.google.com/a/linaro.org/group/lng-odp/. > To view this discussion on the web visit > https://groups.google.com/a/linaro.org/d/msgid/lng-odp/a4e1bdd8-7320-4c33-8491-cd8914bc91ae%40linaro.org. > For more options, visit > https://groups.google.com/a/linaro.org/groups/opt_out.
diff --git a/test/packet/odp_example_pktio.c b/test/packet/odp_example_pktio.c index 875830e..516fe37 100644 --- a/test/packet/odp_example_pktio.c +++ b/test/packet/odp_example_pktio.c @@ -38,6 +38,7 @@ * Parsed command line application arguments */ typedef struct { + int core_count; int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ @@ -91,7 +92,7 @@ static void *pktio_queue_thread(void *arg) odp_packet_t pkt; odp_buffer_t buf; int ret; - unsigned long pkt_cnt = 0; +/* unsigned long pkt_cnt = 0;*/ unsigned long err_cnt = 0; odp_pktio_params_t params; socket_params_t *sock_params = ¶ms.sock_params; @@ -179,11 +180,13 @@ static void *pktio_queue_thread(void *arg) /* Enqueue the packet for output */ odp_queue_enq(outq_def, buf); - /* Print packet counts every once in a while */ +/* + // Print packet counts every once in a while if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); fflush(NULL); } +*/ } /* unreachable */ @@ -202,9 +205,9 @@ static void *pktio_ifburst_thread(void *arg) thread_args_t *thr_args; int pkts, pkts_ok; odp_packet_t pkt_tbl[MAX_PKT_BURST]; - unsigned long pkt_cnt = 0; +/* unsigned long pkt_cnt = 0;*/ unsigned long err_cnt = 0; - unsigned long tmp = 0; +/* unsigned long tmp = 0;*/ odp_pktio_params_t params; socket_params_t *sock_params = ¶ms.sock_params; @@ -247,16 +250,17 @@ static void *pktio_ifburst_thread(void *arg) if (odp_unlikely(pkts_ok != pkts)) ODP_ERR("Dropped frames:%u - err_cnt:%lu\n", pkts-pkts_ok, ++err_cnt); - - /* Print packet counts every once in a while */ +/* + // Print packet counts every once in a while tmp += pkts_ok; - if (odp_unlikely((tmp >= 100000) || /* OR first print:*/ + if (odp_unlikely((tmp >= 100000) || // OR first print: ((pkt_cnt == 0) && ((tmp-1) < MAX_PKT_BURST)))) { pkt_cnt += tmp; printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); fflush(NULL); tmp = 0; } +*/ } } @@ -274,6 +278,8 @@ int main(int argc, char *argv[]) int num_workers; void *pool_base; int i; + int first_core; + int core_count; /* Init ODP before calling anything else */ if (odp_init_global()) { @@ -295,10 +301,28 @@ int main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); - num_workers = odp_sys_core_count(); + core_count = odp_sys_core_count(); + num_workers = core_count; + + if (args->appl.core_count) + num_workers = args->appl.core_count; + if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; + printf("Num worker threads: %i\n", num_workers); + + /* + * By default core #0 runs Linux kernel background tasks. + * Start mapping thread from core #1 + */ + first_core = 1; + + if (core_count == 1) + first_core = 0; + + printf("First core: %i\n\n", first_core); + /* Init this thread */ thr_id = odp_thread_create(0); odp_init_local(thr_id); @@ -326,7 +350,12 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); for (i = 0; i < num_workers; ++i) { void *(*thr_run_func) (void *); - int if_idx = i % args->appl.if_count; + int core; + int if_idx; + + core = (first_core + i) % core_count; + + if_idx = i % args->appl.if_count; args->thread[i].pktio_dev = args->appl.if_names[if_idx]; args->thread[i].pool = pool; @@ -341,7 +370,7 @@ int main(int argc, char *argv[]) * because each thread might get different arguments. * Calls odp_thread_create(cpu) for each thread */ - odp_linux_pthread_create(thread_tbl, 1, i, thr_run_func, + odp_linux_pthread_create(thread_tbl, 1, core, thr_run_func, &args->thread[i]); } @@ -436,6 +465,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) size_t len; int i; static struct option longopts[] = { + {"count", required_argument, NULL, 'c'}, {"interface", required_argument, NULL, 'i'}, /* return 'i' */ {"mode", required_argument, NULL, 'm'}, /* return 'm' */ {"help", no_argument, NULL, 'h'}, /* return 'h' */ @@ -445,12 +475,16 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->mode = -1; /* Invalid, must be changed by parsing */ while (1) { - opt = getopt_long(argc, argv, "+i:m:h", longopts, &long_index); + opt = getopt_long(argc, argv, "+c:i:m:h", + longopts, &long_index); if (opt == -1) break; /* No more options */ switch (opt) { + case 'c': + appl_args->core_count = atoi(optarg); + break; /* parse packet-io interface names */ case 'i': len = strlen(optarg); @@ -537,8 +571,8 @@ static void print_info(char *progname, appl_args_t *appl_args) "Core count: %i\n" "\n", odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), - odp_sys_cache_line_size(), odp_sys_core_count() - ); + odp_sys_cache_line_size(), odp_sys_core_count()); + printf("Running ODP appl: \"%s\"\n" "-----------------\n" "IF-count: %i\n" @@ -573,7 +607,8 @@ static void usage(char *progname) " 1: Send&receive packets through ODP queues.\n" "\n" "Optional OPTIONS\n" - " -h, --help Display help and exit.\n" + " -c, --count <number> Core count.\n" + " -h, --help Display help and exit.\n" "\n", NO_PATH(progname), NO_PATH(progname) ); }
Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> --- test/packet/odp_example_pktio.c | 63 ++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-)