From patchwork Mon Jan 9 13:35:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 90449 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp618686obz; Mon, 9 Jan 2017 05:35:33 -0800 (PST) X-Received: by 10.237.59.19 with SMTP id p19mr13001082qte.90.1483968933670; Mon, 09 Jan 2017 05:35:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i32si46336871qtb.105.2017.01.09.05.35.33; Mon, 09 Jan 2017 05:35:33 -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 4DB9E60A19; Mon, 9 Jan 2017 13:35:33 +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_H2, 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 3769A60801; Mon, 9 Jan 2017 13:35:28 +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 2757F60802; Mon, 9 Jan 2017 13:35:14 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by lists.linaro.org (Postfix) with ESMTPS id 38400607FA for ; Mon, 9 Jan 2017 13:35:13 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id f144so21572883pfa.2 for ; Mon, 09 Jan 2017 05:35:13 -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:subject:date:message-id; bh=NVsjQBYJJbaMT9jrMLOW+o7pH/abrTghWHJjI8WUjf0=; b=uZT8Oz0XTeTUFdpV2WeGFOLVxKvf9A5z+PLRDm5G6C50kxORPvofFxTUrAZJgJCprl SNSAHeCOHCjW/8uAZT8xGodrdcI8sAUadxxJax3d4wGcjpPMpqjMZ0gnhZ2kKkeP6Cva 92R/3sHJHoDjMJo9nQ1HC3oxKD3HnarLrgjgdppOgziVzqIhHtTJzlTyvdelHw6Dvx2g a6lkLowo0OjPvnc7jZBMDKvYssUdx0qiv+SfXWLu5Y4GcPKzuLdw4o1AuumtQHt37G1l K3i/LeRjfvb+F+JUC8FbkIEwgV708bc5gqBETcjafzSsZL51kq2OcRn9fNfa96Fj40I4 ycVw== X-Gm-Message-State: AIkVDXIg4+YSLVa+PlAZJjGVJASlsmV9sJWKRJFJJbWlpgXT0SUkvfI53BAAg5wnC+7a+HJVm04= X-Received: by 10.99.237.17 with SMTP id d17mr18426037pgi.82.1483968912283; Mon, 09 Jan 2017 05:35:12 -0800 (PST) Received: from elxahtkds32.localdomain ([61.2.118.77]) by smtp.gmail.com with ESMTPSA id v1sm181176209pgv.33.2017.01.09.05.35.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 05:35:11 -0800 (PST) From: Balakrishna Garapati To: lng-odp@lists.linaro.org, mike.holmes@linaro.org Date: Mon, 9 Jan 2017 14:35:04 +0100 Message-Id: <1483968904-21625-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCHv2] 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" This will resolve the test in ci when using cgroups. odp_hello app fails to set cpu affinity to zero all ways when cgroup doesn't include that cpu in the set. Signed-off-by: Balakrishna Garapati --- example/hello/odp_hello.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 1.9.1 Reviewed-by: Bill Fischofer 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);