From patchwork Tue Jan 10 02:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 90612 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp393333qgi; Mon, 9 Jan 2017 18:52:24 -0800 (PST) X-Received: by 10.55.154.140 with SMTP id c134mr839137qke.21.1484016744144; Mon, 09 Jan 2017 18:52:24 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m36si346589qta.20.2017.01.09.18.52.18; Mon, 09 Jan 2017 18:52:24 -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 0EBCD60CA0; Tue, 10 Jan 2017 02:52:18 +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 5AA5060A6F; Tue, 10 Jan 2017 02:52:14 +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 6DBC860A57; Tue, 10 Jan 2017 02:52:11 +0000 (UTC) Received: from mail-pf0-f180.google.com (mail-pf0-f180.google.com [209.85.192.180]) by lists.linaro.org (Postfix) with ESMTPS id 877DB60A57 for ; Tue, 10 Jan 2017 02:52:09 +0000 (UTC) Received: by mail-pf0-f180.google.com with SMTP id 189so25739222pfu.3 for ; Mon, 09 Jan 2017 18:52:09 -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=W68QcTkLvwfFLPIwpJeaiHa5x47OwtHdQDbwjpO+4Eo=; b=N/5bWHqqHhJ884m/Wx/oMPID+6GarJXFNXB+MZfZra6fLn+B2NG4J1nTh9HPfUjoPU kqPl4EEBPz83h3zv6paj8sPM1aCF+zfJ73hLKJogBwVMMnTgR1JToaiC5bBuEX7n9Uvh J0z2OYQ/7sW6bXTy5Y3crAMZgEj0dEuwHPId09eFGbT1+DPmXRxoCuYC2U7Dt1lG2Y5o jq3T7+vd+hTgbXjmILDGOBOotF/dUKWXRNSOXBDWSsOi02bk35m8pDeCqLqiGYCufzGS ZQpWG8azY4ULFt3wCyUI1qx+ZUY5JHfpm866P3HdNFsGVdVOATtGRSzlDaIxjeQHr21n q1qw== X-Gm-Message-State: AIkVDXL3DSsI8jHE/fF6Nrp/WRlonR6btiE6DU3BbFRfVfWA07h4iHDl56HnvXQNXryxILDZKcE= X-Received: by 10.84.254.74 with SMTP id a10mr1402915pln.57.1484016728895; Mon, 09 Jan 2017 18:52:08 -0800 (PST) Received: from elxahtkds32.localdomain ([61.2.118.77]) by smtp.gmail.com with ESMTPSA id f3sm616430pga.1.2017.01.09.18.52.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 18:52:08 -0800 (PST) From: Balakrishna Garapati To: lng-odp@lists.linaro.org, mike.holmes@linaro.org Date: Tue, 10 Jan 2017 03:52:02 +0100 Message-Id: <1484016722-10558-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCHv3] 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. Fixes: https://bugs.linaro.org/show_bug.cgi?id=2806 Signed-off-by: Balakrishna Garapati --- since v2: Added link to bug example/hello/odp_hello.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) -- 1.9.1 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);