From patchwork Thu Jul 30 08:02:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 51682 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id A367822DB5 for ; Thu, 30 Jul 2015 08:03:08 +0000 (UTC) Received: by wilm20 with SMTP id m20sf15061396wil.2 for ; Thu, 30 Jul 2015 01:03:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=9nOnZ8V3drmSYZc1nz2Yr8YbY2+S1QB2ns9H3j1TTR0=; b=hAd1lTu7Sim/J9ANoRpMIkLrEk63ahvCCK6zOkRR8DAGlJGD+s67GUF/e2usUoUotm 05GtF7K/lDWOKH2JVAkr85c1qxTEBXo2xgCxXQncCedvd5Cl7o+iENgnJJNGJ08SErIf 4twzKOvzfq5z6RQyo0zu/DkliX6ozrTRNDJgbJuq+BsTuEJcLQ6JI1D7k+JE1VEhdjP/ 5qOxjLCZPANY0yiWDoDUtX/oOl5xaH7Al1Sz1ClD3h1r/KBJ8wlFWNyvBFHPxEQSPkgW Jbqwj9rVyB7Sdcv9h+5ZdgtKOuKiXjDwnKaps+b4kYk3A++jglt03uJ66IoLMAx/y4N6 BHKg== X-Gm-Message-State: ALoCoQl5lk1niH7XsMuk4RGWypfH7ATLyGrhpcaZbP6FUMDeHVq3gyjictSfZuBr+6mgB/sbFzBd X-Received: by 10.112.189.131 with SMTP id gi3mr17470173lbc.6.1438243387935; Thu, 30 Jul 2015 01:03:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.219.4 with SMTP id pk4ls147624lac.90.gmail; Thu, 30 Jul 2015 01:03:07 -0700 (PDT) X-Received: by 10.152.29.97 with SMTP id j1mr43384091lah.104.1438243387787; Thu, 30 Jul 2015 01:03:07 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id re5si180646lbb.150.2015.07.30.01.03.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 01:03:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbst4 with SMTP id st4so21666553lbb.1 for ; Thu, 30 Jul 2015 01:03:07 -0700 (PDT) X-Received: by 10.152.203.134 with SMTP id kq6mr43106590lac.106.1438243387422; Thu, 30 Jul 2015 01:03:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp390744lba; Thu, 30 Jul 2015 01:03:06 -0700 (PDT) X-Received: by 10.107.137.95 with SMTP id l92mr8442120iod.2.1438243385749; Thu, 30 Jul 2015 01:03:05 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w14si897660icl.37.2015.07.30.01.03.04; Thu, 30 Jul 2015 01:03:05 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id BC30561F14; Thu, 30 Jul 2015 08:03:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3200E61B2C; Thu, 30 Jul 2015 08:03:00 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1868161EFC; Thu, 30 Jul 2015 08:02:57 +0000 (UTC) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 1D17761B1B for ; Thu, 30 Jul 2015 08:02:56 +0000 (UTC) Received: by lahh5 with SMTP id h5so20263933lah.2 for ; Thu, 30 Jul 2015 01:02:55 -0700 (PDT) X-Received: by 10.152.9.5 with SMTP id v5mr42305186laa.111.1438243375004; Thu, 30 Jul 2015 01:02:55 -0700 (PDT) Received: from elxahtkds32.localdomain (host-95-192-16-37.mobileonline.telia.com. [95.192.16.37]) by smtp.gmail.com with ESMTPSA id uf7sm57295lbb.29.2015.07.30.01.02.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Jul 2015 01:02:54 -0700 (PDT) From: "Balakrishna.Garapati" To: stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Thu, 30 Jul 2015 10:02:46 +0200 Message-Id: <1438243366-588-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCH] example:generator:option to supply core mask X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: balakrishna.garapati@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Balakrishna.Garapati --- This patch also includes changes to enable the option to support number of workers. example/generator/odp_generator.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index d6ec758..08cd577 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -42,6 +42,7 @@ */ typedef struct { int cpu_count; /**< system CPU count */ + const char *mask; /**< core mask */ int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ char *if_str; /**< Storage for interface names */ @@ -633,18 +634,27 @@ int main(int argc, char *argv[]) if (args->appl.cpu_count) num_workers = args->appl.cpu_count; - /* ping mode need two worker */ - if (args->appl.mode == APPL_MODE_PING) - num_workers = 2; + if (args->appl.mask) { + (void)odp_cpumask_from_str(&cpumask, args->appl.mask); + num_workers = odp_cpumask_count(&cpumask); + } else { + num_workers = odp_cpumask_def_worker(&cpumask, num_workers); + } - /* Get default worker cpumask */ - num_workers = odp_cpumask_def_worker(&cpumask, num_workers); (void)odp_cpumask_to_str(&cpumask, cpumaskstr, sizeof(cpumaskstr)); printf("num worker threads: %i\n", num_workers); printf("first CPU: %i\n", odp_cpumask_first(&cpumask)); printf("cpu mask: %s\n", cpumaskstr); + /* ping mode need two workers */ + if (args->appl.mode == APPL_MODE_PING) { + if (num_workers < 2) { + EXAMPLE_ERR("Need at least two worker threads\n"); + exit(EXIT_FAILURE); + } + } + /* Create packet pool */ memset(¶ms, 0, sizeof(params)); params.pkt.seg_len = SHM_PKT_POOL_BUF_SIZE; @@ -812,6 +822,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) static struct option longopts[] = { {"interface", required_argument, NULL, 'I'}, {"workers", required_argument, NULL, 'w'}, + {"coremask", required_argument, NULL, 'k'}, {"srcmac", required_argument, NULL, 'a'}, {"dstmac", required_argument, NULL, 'b'}, {"srcip", required_argument, NULL, 'c'}, @@ -831,7 +842,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->timeout = -1; while (1) { - opt = getopt_long(argc, argv, "+I:a:b:c:d:s:i:m:n:t:w:h", + opt = getopt_long(argc, argv, "+I:a:b:c:d:s:i:m:n:t:w:k:h", longopts, &long_index); if (opt == -1) break; /* No more options */ @@ -840,6 +851,15 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) case 'w': appl_args->cpu_count = atoi(optarg); break; + case 'k': + len = strlen(optarg); + if (len == 0) { + usage(argv[0]); + exit(EXIT_FAILURE); + } + + appl_args->mask = optarg; + break; /* parse packet-io interface names */ case 'I': len = strlen(optarg); @@ -1029,6 +1049,9 @@ static void usage(char *progname) " -t, --timeout only for ping mode, wait ICMP reply timeout seconds\n" " -i, --interval wait interval ms between sending each packet\n" " default is 1000ms. 0 for flood mode\n" + " -w, --workers specify number of workers need to be assigned to application\n" + " default is to assign all\n" + " -k, --coremask to set on cores\n" "\n" "Optional OPTIONS\n" " -h, --help Display help and exit.\n"