From patchwork Tue Sep 8 10:31:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 53259 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id B972522B18 for ; Tue, 8 Sep 2015 10:33:37 +0000 (UTC) Received: by wisv5 with SMTP id v5sf35088610wis.0 for ; Tue, 08 Sep 2015 03:33:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=p2Wz281/tmsomc+z2XBvYHeoiz5mNS457h+urAZL3bw=; b=YEEUUW31ewEJ6Krody4eNcP7Sx2cxfwOomgSvLEY9p0wyHKRx5I7GhC2myla15N7cJ 2jCJV2nyxB26ud50L+jj8U7iagdpuwDoUtebrwYCBVHhG0N4fM9kejTXBCADxFwgXEFW SXHAV9ICZvqkib4dsHPnl5/7Oyl1rwDT0Lkxm2fsgehHuHD7CeSq05lVUv/Lqgo/Tgki HIAmtlXB12ddwTKY02ueb8b6ZU9COnEZQesKum3V8M//nXp/grUJvoyf+iPQbGBOGv8L hK3OBurvHpff7p/G4efJotZZMyPt4wGa3VeZSgQmn2VWuLVpS7b4EnkUa70wbrXou3Uc 8hqg== X-Gm-Message-State: ALoCoQnNGAeUlFeB/g0ssHm9b59Wg6hgyIV4UFoJHdSsKAus9+f6rT9wAVrG9eoHSe91LhYNJIzO X-Received: by 10.180.96.226 with SMTP id dv2mr6370336wib.2.1441708417070; Tue, 08 Sep 2015 03:33:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.129 with SMTP id 1ls575289lau.58.gmail; Tue, 08 Sep 2015 03:33:36 -0700 (PDT) X-Received: by 10.112.52.138 with SMTP id t10mr19226840lbo.99.1441708416896; Tue, 08 Sep 2015 03:33:36 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id n5si2817739lbl.45.2015.09.08.03.33.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Sep 2015 03:33:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by lagj9 with SMTP id j9so66719985lag.2 for ; Tue, 08 Sep 2015 03:33:36 -0700 (PDT) X-Received: by 10.152.43.198 with SMTP id y6mr21014917lal.41.1441708416747; Tue, 08 Sep 2015 03:33:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp880395lbq; Tue, 8 Sep 2015 03:33:35 -0700 (PDT) X-Received: by 10.140.134.196 with SMTP id 187mr35675177qhg.24.1441708414781; Tue, 08 Sep 2015 03:33:34 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a51si3140367qge.64.2015.09.08.03.33.33; Tue, 08 Sep 2015 03:33:34 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id A241F61997; Tue, 8 Sep 2015 10:33: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=-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 50BE76199D; Tue, 8 Sep 2015 10:31:46 +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 B713261946; Tue, 8 Sep 2015 10:31:37 +0000 (UTC) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by lists.linaro.org (Postfix) with ESMTPS id 5257C6180A for ; Tue, 8 Sep 2015 10:31:34 +0000 (UTC) Received: by lbcjc2 with SMTP id jc2so50592883lbc.0 for ; Tue, 08 Sep 2015 03:31:33 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr21647507lbc.112.1441708293313; Tue, 08 Sep 2015 03:31:33 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id c6sm810079lbp.2.2015.09.08.03.31.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Sep 2015 03:31:32 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 8 Sep 2015 13:31:22 +0300 Message-Id: <1441708283-29002-4-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441708283-29002-1-git-send-email-maxim.uvarov@linaro.org> References: <1441708283-29002-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 3/4] api: odp_cpumask_default_ mask argument can be null X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Functions odp_cpumask_default_worker and odp_cpumask_default_control can be used for calculation number of worker and control threads. In that case mask parameter can be optional. Signed-off-by: Maxim Uvarov --- include/odp/api/cpumask.h | 2 +- platform/linux-generic/odp_cpumask_task.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/odp/api/cpumask.h b/include/odp/api/cpumask.h index 4835a6c..633e106 100644 --- a/include/odp/api/cpumask.h +++ b/include/odp/api/cpumask.h @@ -199,7 +199,7 @@ int odp_cpumask_next(const odp_cpumask_t *mask, int cpu); * Initializes cpumask with CPUs available for worker threads. Sets up to 'num' * CPUs and returns the count actually set. Use zero for all available CPUs. * - * @param[out] mask CPU mask to initialize + * @param[out] mask CPU mask to initialize or NULL. * @param num Number of worker threads, zero for all available CPUs * @return Actual number of CPUs used to create the mask */ diff --git a/platform/linux-generic/odp_cpumask_task.c b/platform/linux-generic/odp_cpumask_task.c index 535891c..f8e4da4 100644 --- a/platform/linux-generic/odp_cpumask_task.c +++ b/platform/linux-generic/odp_cpumask_task.c @@ -23,7 +23,8 @@ int odp_cpumask_default_worker(odp_cpumask_t *mask, int num) if (ret != 0) ODP_ABORT("failed to read CPU affinity value\n"); - odp_cpumask_zero(mask); + if (mask) + odp_cpumask_zero(mask); /* * If no user supplied number or it's too large, then attempt @@ -35,7 +36,8 @@ int odp_cpumask_default_worker(odp_cpumask_t *mask, int num) /* build the mask, allocating down from highest numbered CPU */ for (cpu = 0, i = CPU_SETSIZE - 1; i >= 0 && cpu < num; --i) { if (CPU_ISSET(i, &cpuset)) { - odp_cpumask_set(mask, i); + if (mask) + odp_cpumask_set(mask, i); cpu++; } } @@ -45,8 +47,10 @@ int odp_cpumask_default_worker(odp_cpumask_t *mask, int num) int odp_cpumask_default_control(odp_cpumask_t *mask, int num ODP_UNUSED) { - odp_cpumask_zero(mask); - /* By default all control threads on CPU 0 */ - odp_cpumask_set(mask, 0); + if (mask) { + odp_cpumask_zero(mask); + /* By default all control threads on CPU 0 */ + odp_cpumask_set(mask, 0); + } return 1; }