From patchwork Wed Feb 26 11:30:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 25346 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 830AA20636 for ; Wed, 26 Feb 2014 11:30:13 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id o6sf2587729oag.2 for ; Wed, 26 Feb 2014 03:30:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=wF53LMANu9eDtFFAiUbHtTio9imCzHUsCCSAJHON5qg=; b=KitdKB2w+qLi7abf7ROHThX05oriAtIXcPb3DV2r8hzqhNJiIK95Fftiy7T84YriMP 3OfyWz+YBBp+ZumGe8qYSskeNY+R5v+Jsxk71M6Y1kNXnpKYBrcXJqAQkGHfKR3iUS4Q k81AEimhrXRniYI6/wQV9ji0QTVLCbUN8OTWDQO+qq8SkMIUC6FFqs3MdTgPUQnCfMdt 62DDVKMes7uUWQku+IGPZtrl/Yt5XGjiiicJSlhAgTBfPImgM50P/WJk0YnDuoJlZOpa 501SGOZsVpLSyF/E5lB7wITyBxzRjF0JT50LXPyXPpIbPFeLlnMio1ZmmxUoC//CzDAs 9BbA== X-Gm-Message-State: ALoCoQkfe5/aUGFd5AyqLi0qkzCy2kGqtDBnWNdDgJ7+TmtBbzHpXmhAsOgvLxgg8fI6PW042Pob X-Received: by 10.182.28.67 with SMTP id z3mr1183547obg.12.1393414212614; Wed, 26 Feb 2014 03:30:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.140.36.200 with SMTP id p66ls184879qgp.74.gmail; Wed, 26 Feb 2014 03:30:12 -0800 (PST) X-Received: by 10.224.138.10 with SMTP id y10mr7080201qat.17.1393414212312; Wed, 26 Feb 2014 03:30:12 -0800 (PST) Received: from mail-qa0-f48.google.com (mail-qa0-f48.google.com [209.85.216.48]) by mx.google.com with ESMTPS id u90si299791qge.153.2014.02.26.03.30.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 03:30:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.48 is neither permitted nor denied by best guess record for domain of petri.savolainen@linaro.org) client-ip=209.85.216.48; Received: by mail-qa0-f48.google.com with SMTP id o15so2072631qap.35 for ; Wed, 26 Feb 2014 03:30:12 -0800 (PST) X-Received: by 10.224.75.73 with SMTP id x9mr7289680qaj.36.1393414212186; Wed, 26 Feb 2014 03:30:12 -0800 (PST) Received: from localhost.localdomain (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id u10sm1574162qar.21.2014.02.26.03.30.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Feb 2014 03:30:11 -0800 (PST) From: Petri Savolainen To: lng-odp@linaro.org Cc: Petri Savolainen Subject: [lng-odp] [PATCH] Packet IO test core count option Date: Wed, 26 Feb 2014 13:30:44 +0200 Message-Id: <1393414244-17012-1-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 1.8.5.3 X-Original-Sender: petri.savolainen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.48 is neither permitted nor denied by best guess record for domain of petri.savolainen@linaro.org) smtp.mail=petri.savolainen@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Signed-off-by: Petri Savolainen --- 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;*/ 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 Core count.\n" + " -h, --help Display help and exit.\n" "\n", NO_PATH(progname), NO_PATH(progname) ); }