From patchwork Fri Jan 13 13:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 91424 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp135507obz; Fri, 13 Jan 2017 05:26:07 -0800 (PST) X-Received: by 10.36.7.85 with SMTP id f82mr2394874itf.10.1484313967014; Fri, 13 Jan 2017 05:26:07 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z201si1545995itc.24.2017.01.13.05.26.06; Fri, 13 Jan 2017 05:26:07 -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 86DB260C2A; Fri, 13 Jan 2017 13:26:06 +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 6427B60886; Fri, 13 Jan 2017 13:26:02 +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 3FD5A60B29; Fri, 13 Jan 2017 13:26:00 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 1F59C6083B for ; Fri, 13 Jan 2017 13:25:59 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id v186so37412325lfa.1 for ; Fri, 13 Jan 2017 05:25:59 -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=399In+J+awMcgzAKN2NBz6eBj7MHEvwwC9zrDbFDGSs=; b=UTnGPJWsTU1q+pyYoyR/xd5Vj84xoxu0hbAGx0om9hRg6odmKorkIV8QP1Tt0RkMTt rdz1ZTUt26dc5L1zBSMaOyij/hHYDEbHhX2UMDkiI7miBdVAubYYdB8U8AMSff2YYd4u rlZmKEftur4SmK0idM0C56Dx0BJFkqJajgB3oyIZ2gcDsyrHAKPx/FrAdW7xlBgJl0ud Z6Fa/vEIqDX8GerJG374TYyf7w63D5ElDTIjRwLZI9eDm5WZYNuUXueG7VFhAwnswHR6 P7XB6MBV6jR/K7cnDwo/o/1mYKlHJcHw/hcwsjOE5Qy9XYbwh/c6hro7azL8WEd8F+HN UgVQ== X-Gm-Message-State: AIkVDXIIO9WYfh1HntKIeG6Poour+5naqcW7qH5Fp4pIa+eyAXc3NsyjplG/HyLLY3t7JAHhSGs= X-Received: by 10.46.69.7 with SMTP id s7mr7591559lja.44.1484313957858; Fri, 13 Jan 2017 05:25:57 -0800 (PST) Received: from localhost.localdomain (ppp46-138-200-109.pppoe.spdop.ru. [46.138.200.109]) by smtp.gmail.com with ESMTPSA id j11sm3405631lfd.23.2017.01.13.05.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 05:25:57 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 13 Jan 2017 16:25:29 +0300 Message-Id: <20170113132529.25320-1-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce Subject: [lng-odp] [PATCH] example: hello: do not pin control thread 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" hello word app should not use any linux specific things. Pinning thread to core is also optional and should not be in minimal app. This also fixes bug with cgroups env where core 0 is not available. Signed-off-by: Maxim Uvarov --- example/hello/odp_hello.c | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) -- 2.11.0.295.gd7dffce diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c index 6d114eea..0b75b58f 100644 --- a/example/hello/odp_hello.c +++ b/example/hello/odp_hello.c @@ -10,21 +10,12 @@ * anything else than the ODP API header file. */ -/* Linux CPU affinity */ -#define _GNU_SOURCE -#include - -/* Linux PID */ -#include -#include - #include #include #include typedef struct { - int cpu; int num; } options_t; @@ -36,17 +27,12 @@ static int parse_args(int argc, char *argv[], options_t *opt) for (i = 1; i < argc; i++) { if ((strcmp(argv[i], args[0]) == 0) && (sscanf(argv[i + 1], "%i", &tmp) == 1)) { - opt->cpu = tmp; - i++; - } else if ((strcmp(argv[i], args[1]) == 0) && - (sscanf(argv[i + 1], "%i", &tmp) == 1)) { opt->num = tmp; i++; } else { printf("\nUsage:\n" - " %s CPU number\n" " %s Number of iterations\n\n", - args[0], args[1]); + args[0]); return -1; } } @@ -58,26 +44,14 @@ int main(int argc, char *argv[]) { odp_instance_t inst; options_t opt; - pid_t pid; - cpu_set_t cpu_set; int i; memset(&opt, 0, sizeof(opt)); - opt.cpu = 0; opt.num = 1; if (parse_args(argc, argv, &opt)) return -1; - pid = getpid(); - CPU_ZERO(&cpu_set); - CPU_SET(opt.cpu, &cpu_set); - - if (sched_setaffinity(pid, sizeof(cpu_set_t), &cpu_set)) { - printf("Set CPU affinity failed.\n"); - return -1; - } - if (odp_init_global(&inst, NULL, NULL)) { printf("Global init failed.\n"); return -1; @@ -85,6 +59,7 @@ int main(int argc, char *argv[]) if (odp_init_local(inst, ODP_THREAD_CONTROL)) { printf("Local init failed.\n"); + (void)odp_term_global(inst); return -1; }