From patchwork Mon Jan 9 15:43: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: 90485 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp140646qgi; Mon, 9 Jan 2017 07:43:43 -0800 (PST) X-Received: by 10.200.57.75 with SMTP id t11mr14323388qtb.274.1483976623283; Mon, 09 Jan 2017 07:43:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v46si10805137qtb.3.2017.01.09.07.43.43; Mon, 09 Jan 2017 07:43:43 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D082B60C05; Mon, 9 Jan 2017 15:43:42 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 3F40860945; Mon, 9 Jan 2017 15:43:35 +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 83091609B0; Mon, 9 Jan 2017 15:43:33 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 54341607C9 for ; Mon, 9 Jan 2017 15:43:32 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id m78so75727934lfg.2 for ; Mon, 09 Jan 2017 07:43:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=D9E9gi3XaLaO179CE7BfQKg9auy/RSxmjXLXZaABpnQ=; b=hfpomPXvP6kdwkMyqMcIzj1YuemUFVgCQ+Ou7X4A4bVUiYAstv/ooOLOyITe8I47IZ WW0zrv7JnQLaWdoCbFPyjXRp7lCPyJ1Fcq6BgBCwUGYknKTQjVVM6w5/566T3iFNGx5G 5KB2nHIO3Xx+pOiRN0NBEuLyNriIhAZ5J/CF5+NEJsT56FHktrx3MsnN+ppLXd5vDqkV Pt8S34/Cd9spg6TE6oxWqTp3mwrKwI/ommmYJs7MGVV2gr1LyAZd1zSd97leBDJg7erq rNOcc7dutvL0st2Qo2MIyJUDVzuTIJrOeLUMo414q8kqr9tAZSgthtUZQbl62KDunZr4 K62Q== X-Gm-Message-State: AIkVDXLBLRF2FlFix1QP+U9qEsWLLRsGqYbHKZWU921HUZXd1VBGIUwjPOWxIrLhLq4II3y0tZI= X-Received: by 10.25.24.42 with SMTP id o42mr2071827lfi.113.1483976610853; Mon, 09 Jan 2017 07:43:30 -0800 (PST) Received: from [193.168.1.37] (ppp46-138-200-109.pppoe.spdop.ru. [46.138.200.109]) by smtp.gmail.com with ESMTPSA id f25sm1104354lji.26.2017.01.09.07.43.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 07:43:30 -0800 (PST) To: lng-odp@lists.linaro.org References: <1483963391-5959-1-git-send-email-balakrishna.garapati@linaro.org> From: Maxim Uvarov Message-ID: <5873AFA1.50509@linaro.org> Date: Mon, 9 Jan 2017 18:43:29 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: Subject: Re: [lng-odp] [PATCH] example: hello: set cpu affinity from cgroup 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 Krishna, I think in that case it's better to ask ODP for core number for first available control thread number. Like that: On 01/09/17 15:54, Mike Holmes wrote: > On 9 January 2017 at 07:03, Balakrishna Garapati < > balakrishna.garapati@linaro.org> wrote: > >> This will resolve the test in ci when using cgroups >> > > Can you just add a line saying what the issue was, it is easier to decided > if the patch achieves that > > >> Signed-off-by: Balakrishna Garapati > > --- >> example/hello/odp_hello.c | 19 ++++++++++++++++--- >> 1 file changed, 16 insertions(+), 3 deletions(-) >> >> diff --git a/example/hello/odp_hello.c b/example/hello/odp_hello.c >> index 6d114ee..59a31b2 100644 >> --- a/example/hello/odp_hello.c >> +++ b/example/hello/odp_hello.c >> @@ -60,16 +60,29 @@ int main(int argc, char *argv[]) >> options_t opt; >> pid_t pid; >> cpu_set_t cpu_set; >> - int i; >> + int i, ret, first_cpu = 0, cpu; >> + >> + pid = getpid(); >> + ret = sched_getaffinity(pid, sizeof(cpu_set_t), &cpu_set); >> + if (ret < 0) { >> + printf("get CPU affinity failed.\n"); >> + return -1; >> + } >> + >> + for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { >> + if (CPU_ISSET(cpu, &cpu_set)) { >> + first_cpu = cpu; >> + break; >> + } >> + } >> >> memset(&opt, 0, sizeof(opt)); >> - opt.cpu = 0; >> + opt.cpu = first_cpu; >> opt.num = 1; >> >> if (parse_args(argc, argv, &opt)) >> return -1; >> >> - pid = getpid(); >> CPU_ZERO(&cpu_set); >> CPU_SET(opt.cpu, &cpu_set); >> >> -- >> 1.9.1 >> >> > > --- 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;