From patchwork Thu Jan 19 14:34:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 91935 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp305483qgi; Thu, 19 Jan 2017 06:35:14 -0800 (PST) X-Received: by 10.107.166.18 with SMTP id p18mr8628103ioe.15.1484836514237; Thu, 19 Jan 2017 06:35:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q35si4471138ioi.243.2017.01.19.06.35.13; Thu, 19 Jan 2017 06:35:14 -0800 (PST) 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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BEF2A607B8; Thu, 19 Jan 2017 14:35:13 +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 A5D5D60652; Thu, 19 Jan 2017 14:35:09 +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 6292460653; Thu, 19 Jan 2017 14:35:03 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 7E87260652 for ; Thu, 19 Jan 2017 14:35:01 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id k86so37824499lfi.0 for ; Thu, 19 Jan 2017 06:35:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ceEGwwYkHCyhxDkFqwUgTjdcriV6PKuiRLAe4/2UG8w=; b=fECtzy6h/IAbqdo7oXLWaxxdDmM4jYlm52qG5EfSVVy43IynD0DFp+AZbQ2p60+yQi iiYftIdSTnMYcVFL1WTjOF97PJQmW4AMQLlCn8s29TalVzR6Y8s+MUntdKi4c78dfii+ laPM0/R34nrApj2+diQjpS2e0tsz6mW2Lyg4iavVTi7NYz4O0mFF/d28ljqWF3QqKymz Z5h/qeeu+iUIg/w+toj23WNK+FAddyvaVq8fIEHn4wJ290Oc8tQkszXvNfkZT0KIzaa1 8RzezG1KI3Tlh7cPKJqGB9zS/ZeL1lax0sf79eg2kTMEWOnhAp2PEY3PALrWpQaLqlB9 8G8w== X-Gm-Message-State: AIkVDXIo+LMPhrh3Hs+dgTzFQ1m1hJBTRVUbe61E5WUnVZPq1xaXlQQcWExOpd7mgX2CDvBzbbE= X-Received: by 10.46.84.6 with SMTP id i6mr4215829ljb.8.1484836499978; Thu, 19 Jan 2017 06:34:59 -0800 (PST) Received: from localhost.localdomain (ppp85-141-97-165.pppoe.mtu-net.ru. [85.141.97.165]) by smtp.gmail.com with ESMTPSA id 28sm1942290ljw.17.2017.01.19.06.34.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 06:34:59 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:34:50 +0300 Message-Id: <20170119143450.21473-1-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce Subject: [lng-odp] [PATCH] example: hello: ask odp for available core 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Core 0 might be not available and app should ask for available core before pinning to it. https://bugs.linaro.org/show_bug.cgi?id=2806 Signed-off-by: Maxim Uvarov --- example/hello/odp_hello.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.11.0.295.gd7dffce Reviewed-by: Mike Holmes diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c index 6d114eea..dba34954 100644 --- a/example/hello/odp_hello.c +++ b/example/hello/odp_hello.c @@ -61,6 +61,7 @@ int main(int argc, char *argv[]) pid_t pid; cpu_set_t cpu_set; int i; + odp_cpumask_t mask; memset(&opt, 0, sizeof(opt)); opt.cpu = 0; @@ -70,6 +71,15 @@ int main(int argc, char *argv[]) return -1; pid = getpid(); + + if (odp_init_global(&inst, NULL, NULL)) { + printf("Global init failed.\n"); + return -1; + } + + odp_cpumask_default_control(&mask, 0); + opt.cpu = odp_cpumask_first(&mask); + CPU_ZERO(&cpu_set); CPU_SET(opt.cpu, &cpu_set); @@ -78,11 +88,6 @@ int main(int argc, char *argv[]) return -1; } - if (odp_init_global(&inst, NULL, NULL)) { - printf("Global init failed.\n"); - return -1; - } - if (odp_init_local(inst, ODP_THREAD_CONTROL)) { printf("Local init failed.\n"); return -1;