From patchwork Wed Mar 5 07:42:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 25737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 80AB520540 for ; Wed, 5 Mar 2014 07:40:53 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id e16sf1514679qcx.6 for ; Tue, 04 Mar 2014 23:40:53 -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=KZ1yYmehWdUJ9gShKORtenY8I/svcf/hVDCXO+6FbNI=; b=Ie6T3PH0EY66XClcmiIhAYgCd8kG6frOBBtbWt/wfuF0qeGXl0XtKY/9sc6eM0EHFX 5q8kq+PPAsOViH1aA8Ccb3XIYzHIIYa/JJTQg13/x4yjA6jwts8ABM6Mc+8wx3fFSXzm 4XBO1A3CWdNOlfU4Pzxoo4weZtcIK6DP1C6IKmQ3/ybc4gFq1n0Ljp+MaFN+yu07MSw1 KaFK6B/Mqqi8olPS96vYxy+WbkKhlxMC5mTJHijtyQcV+Hz8biv+jlZh1WbNNHbZa0Q0 abMMW66zli1Y347OtBMj0tdjRhHXgwX/TBdQEeYUxm+xaOEY4J4id1zE/49y3VIhlHQF x6Fw== X-Gm-Message-State: ALoCoQmwQtK+G0NuR/x8Nux8PzKGv6BqcVdZw2TFAlaAfcO+jQrJXKPzZprWr8hz+YspWrA4RDMi X-Received: by 10.58.111.202 with SMTP id ik10mr1898840veb.4.1394005252990; Tue, 04 Mar 2014 23:40:52 -0800 (PST) MIME-Version: 1.0 X-BeenThere: lng-odp@linaro.org Received: by 10.140.89.136 with SMTP id v8ls214345qgd.17.gmail; Tue, 04 Mar 2014 23:40:52 -0800 (PST) X-Received: by 10.140.23.209 with SMTP id 75mr4473013qgp.89.1394005252677; Tue, 04 Mar 2014 23:40:52 -0800 (PST) Received: from mail-qc0-f171.google.com (mail-qc0-f171.google.com [209.85.216.171]) by mx.google.com with ESMTPS id j77si748801qge.44.2014.03.04.23.40.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Mar 2014 23:40:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.171 is neither permitted nor denied by best guess record for domain of petri.savolainen@linaro.org) client-ip=209.85.216.171; Received: by mail-qc0-f171.google.com with SMTP id x13so718344qcv.16 for ; Tue, 04 Mar 2014 23:40:52 -0800 (PST) X-Received: by 10.140.86.202 with SMTP id p68mr4458065qgd.81.1394005252447; Tue, 04 Mar 2014 23:40:52 -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 g20sm5277117qaq.4.2014.03.04.23.40.49 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 04 Mar 2014 23:40:51 -0800 (PST) From: Petri Savolainen To: lng-odp@linaro.org Cc: Petri Savolainen Subject: [lng-odp] [PATCH v2] Packet IO test core count option Date: Wed, 5 Mar 2014 09:42:08 +0200 Message-Id: <1394005328-4251-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.171 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 | 46 ++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/test/packet/odp_example_pktio.c b/test/packet/odp_example_pktio.c index 875830e..85bbdd7 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 */ @@ -274,6 +275,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 +298,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 +347,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 +367,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 +462,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 +472,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 +568,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 +604,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) ); }