From patchwork Fri May 27 03:22:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 68726 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp719656qge; Thu, 26 May 2016 20:22:23 -0700 (PDT) X-Received: by 10.140.96.67 with SMTP id j61mr11230783qge.74.1464319343214; Thu, 26 May 2016 20:22:23 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q68si15749559qkb.227.2016.05.26.20.22.22; Thu, 26 May 2016 20:22:23 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9CA616178E; Fri, 27 May 2016 03:22:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 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 [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 472EB61731; Fri, 27 May 2016 03:22:18 +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 1985861737; Fri, 27 May 2016 03:22:16 +0000 (UTC) Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by lists.linaro.org (Postfix) with ESMTPS id 0219B61722 for ; Fri, 27 May 2016 03:22:15 +0000 (UTC) Received: by mail-oi0-f53.google.com with SMTP id b65so155085120oia.1 for ; Thu, 26 May 2016 20:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0c49EgHGYjzTGoS/49kuD+0qhQjWKUR+i9edWYOGINw=; b=Ax1gqBxyGfaCFQZFIcfp73gdFiQ893pMTSpZRomTKOk7pQ6ND7wKarUaT52cSvjj2S Al6k8PFqksHUTFivFFqCYfiWgHj8+blExU8XQ7e5JJxU2oh9k+AwNn12NQ4FbuUvdha8 67kfmDPvJLRgrLZnDIv18H5+nrGeo1JqFDhSMQjHloZDamL8RmOezyFMtdIGMwzexy+Q fLO+sQwm2rX8+CdZFJCLx3jGQU//4fp/fM6wXk67iFWzqO9FzXgMXSP8LKE48Wa9r7PI ZA3clZSJB/sG+xaVnvf3anu2WsQ+uv00+RKdwuQgmTvh3gQmThXC7nrWKljAPm7b+1j6 8LTw== X-Gm-Message-State: ALyK8tKSbUt3wuZ4iMV+Hoe7c7M9tomp2MyEc2znOBSmDMTMyqudR1VNvwt/lcpJQkN/mbQ8onY= X-Received: by 10.157.49.76 with SMTP id v12mr8557228otd.97.1464319334377; Thu, 26 May 2016 20:22:14 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id v13sm5927935ota.0.2016.05.26.20.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 May 2016 20:22:13 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 26 May 2016 22:22:11 -0500 Message-Id: <1464319331-31936-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCH] example: l2fwd: use parameterized array to avoid memory corruption X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" The switch to agnostic threads requires that arrays be passed to odph_odpthreads_create() and odph_pthreads_join(). Even though l2fwd uses only a single worker, this must be declared as an array of size 1 for consistency. This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2272 Signed-off-by: Bill Fischofer --- example/l2fwd_simple/odp_l2fwd_simple.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/example/l2fwd_simple/odp_l2fwd_simple.c b/example/l2fwd_simple/odp_l2fwd_simple.c index daae038..8a14e7d 100644 --- a/example/l2fwd_simple/odp_l2fwd_simple.c +++ b/example/l2fwd_simple/odp_l2fwd_simple.c @@ -16,6 +16,7 @@ #define POOL_NUM_PKT 8192 #define POOL_SEG_LEN 1856 #define MAX_PKT_BURST 32 +#define MAX_WORKERS 1 struct { odp_pktio_t if0, if1; @@ -119,7 +120,7 @@ int main(int argc, char **argv) odp_pool_t pool; odp_pool_param_t params; odp_cpumask_t cpumask; - odph_odpthread_t thd; + odph_odpthread_t thd[MAX_WORKERS]; odp_instance_t instance; odph_odpthread_params_t thr_params; int opt; @@ -183,7 +184,7 @@ int main(int argc, char **argv) global.if1 = create_pktio(argv[optind + 1], pool, &global.if1in, &global.if1out); - odp_cpumask_default_worker(&cpumask, 1); + odp_cpumask_default_worker(&cpumask, MAX_WORKERS); memset(&thr_params, 0, sizeof(thr_params)); thr_params.start = run_worker; @@ -191,8 +192,8 @@ int main(int argc, char **argv) thr_params.thr_type = ODP_THREAD_WORKER; thr_params.instance = instance; - odph_odpthreads_create(&thd, &cpumask, &thr_params); - odph_odpthreads_join(&thd); + odph_odpthreads_create(thd, &cpumask, &thr_params); + odph_odpthreads_join(thd); return 0; }