From patchwork Mon Jan 9 12:03:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 90415 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp45710qgi; Mon, 9 Jan 2017 04:03:31 -0800 (PST) X-Received: by 10.55.17.68 with SMTP id b65mr84406152qkh.60.1483963411762; Mon, 09 Jan 2017 04:03:31 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 63si46463831qkq.244.2017.01.09.04.03.31; Mon, 09 Jan 2017 04:03:31 -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 26015607C9; Mon, 9 Jan 2017 12:03:31 +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 421FC60658; Mon, 9 Jan 2017 12:03:27 +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 2C4B060658; Mon, 9 Jan 2017 12:03:25 +0000 (UTC) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by lists.linaro.org (Postfix) with ESMTPS id 9BE8660658 for ; Mon, 9 Jan 2017 12:03:20 +0000 (UTC) Received: by mail-pf0-f182.google.com with SMTP id f144so21070003pfa.2 for ; Mon, 09 Jan 2017 04:03:20 -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=SGDDXp4R9SQAsmWs3E1WAwru4eiYfl/GOR7w4so/q24=; b=TOh/82yyH5Vs78njEoGqeXp0u+dWdL/XDN1YO5yow6DQp65Q/W1WTTV4OU/J6bGaGK pcczso+d+uwIR9IIKKaNiuHELfEPPr41poOALjXTcTffzV/roxqaFIG9B45yQLxLKAFo pOfZ0zD56Uf1eb02RdQAM0aMhbYity3aYqDy81l3nOaOkmGRPdk39aEbv6+CSZntk7pW XDr0jLAiwFUTKtauaEsFrY4/btSabjw0lRDMJf4ApvkOTOEkAYfzpfGKM2fMzmsWl5Wz Xq+NtHwZrjLufZwG+6tL4erXmRXt5qCDn9mIo7SkAyVk1b4ieftAAv1rBKYDMgRO+v/Q iJ8w== X-Gm-Message-State: AIkVDXJ3X8qKtsROC4idj1fNSebhJFiEH/JARTuvl4+faIyONSPO8wOkaXNGYwaxiFhZBY7qSCw= X-Received: by 10.98.16.7 with SMTP id y7mr81744261pfi.55.1483963399822; Mon, 09 Jan 2017 04:03:19 -0800 (PST) Received: from elxahtkds32.localdomain ([61.2.118.77]) by smtp.gmail.com with ESMTPSA id y15sm180275738pgc.43.2017.01.09.04.03.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 04:03:19 -0800 (PST) From: Balakrishna Garapati To: lng-odp@lists.linaro.org, mike.holmes@linaro.org Date: Mon, 9 Jan 2017 13:03:11 +0100 Message-Id: <1483963391-5959-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [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" This will resolve the test in ci when using cgroups Signed-off-by: Balakrishna Garapati --- 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);