From patchwork Thu Jul 9 13:46:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 50967 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 97C9C228E5 for ; Thu, 9 Jul 2015 13:54:40 +0000 (UTC) Received: by laar3 with SMTP id r3sf75326856laa.1 for ; Thu, 09 Jul 2015 06:54:39 -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:cc: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=SzkUld1V5tcQ2c7ZK4uiDhtWjl+7xkeS4HmBcFb+PlI=; b=Gqv04KS6PtdL0HTfZE06jZn2kP/B2v1XDgpUH/4nsZ3Ie0foVc4OMi4zjz+her8pZK xNPnOGrbmumULXTNywcu8ZUn7G1MZjEQnqfclaXRWqwY+qk8nkvPJfACQ+jid8zD6EPe mCwGLlUdNfrd7i3mLuLaQGJT/MQUPgY56SnRQXVCTJGqjFaTaDYydJoMUNe57KDP+q+4 LgB6NxpW9VSk0KnGmvFCDARf3hTAmZ6MFP8UoaKPqMVy4hahCIxEoHEe5TDwFGYfArh0 S5s33BSNmjO96TQZuss5r3EaVcprgrCXU1oPLQm73YHRs8h5eUfcsdy7pIGiQdG6qJ+I DCXw== X-Gm-Message-State: ALoCoQlK/NI7gDW6BfWLO1QoPdujgN14EwvoAEAi1y9OQ3al5Y6csJrUfyaBOr6zO301Z1dNtleV X-Received: by 10.112.13.200 with SMTP id j8mr8086407lbc.14.1436450079551; Thu, 09 Jul 2015 06:54:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.164 with SMTP id az4ls1003408lab.16.gmail; Thu, 09 Jul 2015 06:54:39 -0700 (PDT) X-Received: by 10.152.116.76 with SMTP id ju12mr14794822lab.75.1436450079401; Thu, 09 Jul 2015 06:54:39 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id sj10si4570792lac.29.2015.07.09.06.54.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jul 2015 06:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbnk3 with SMTP id k3so75563734lbn.1 for ; Thu, 09 Jul 2015 06:54:39 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr14869157lay.72.1436450079288; Thu, 09 Jul 2015 06:54:39 -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.108.230 with SMTP id hn6csp684422lbb; Thu, 9 Jul 2015 06:54:37 -0700 (PDT) X-Received: by 10.140.217.84 with SMTP id n81mr25948735qhb.100.1436450076852; Thu, 09 Jul 2015 06:54:36 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h1si6686173qhc.6.2015.07.09.06.54.35; Thu, 09 Jul 2015 06:54:36 -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 4B5AC61FD0; Thu, 9 Jul 2015 13:54:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 23C4C61FD1; Thu, 9 Jul 2015 13:48: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 811CF61FD8; Thu, 9 Jul 2015 13:48:23 +0000 (UTC) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by lists.linaro.org (Postfix) with ESMTPS id 9986461FCD for ; Thu, 9 Jul 2015 13:46:48 +0000 (UTC) Received: by wgov12 with SMTP id v12so39471246wgo.1 for ; Thu, 09 Jul 2015 06:46:47 -0700 (PDT) X-Received: by 10.195.11.168 with SMTP id ej8mr31078183wjd.150.1436449607753; Thu, 09 Jul 2015 06:46:47 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id df1sm8414627wib.12.2015.07.09.06.46.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Jul 2015 06:46:47 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 9 Jul 2015 16:46:23 +0300 Message-Id: <1436449585-23252-10-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436449585-23252-1-git-send-email-maxim.uvarov@linaro.org> References: <1436449585-23252-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Cc: Petri Savolainen Subject: [lng-odp] [PATCH 09/11] linux-generic: thread: implemented thrmask_worker and control 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.217.173 as permitted sender) smtp.mail=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 From: Petri Savolainen Signed-off-by: Petri Savolainen Reviewed-and-tested-by: Bill Fischofer Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_thread.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index 42afc5f..9905c78 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -36,6 +36,8 @@ typedef struct { odp_thrmask_t worker; odp_thrmask_t control; uint32_t num; + uint32_t num_worker; + uint32_t num_control; odp_spinlock_t lock; } thread_globals_t; @@ -93,10 +95,13 @@ static int alloc_id(odp_thread_type_t type) if (odp_thrmask_isset(all, thr) == 0) { odp_thrmask_set(all, thr); - if (type == ODP_THREAD_WORKER) + if (type == ODP_THREAD_WORKER) { odp_thrmask_set(&thread_globals->worker, thr); - else + thread_globals->num_worker++; + } else { odp_thrmask_set(&thread_globals->control, thr); + thread_globals->num_control++; + } thread_globals->num++; return thr; @@ -118,10 +123,13 @@ static int free_id(int thr) odp_thrmask_clr(all, thr); - if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) + if (thread_globals->thr[thr].type == ODP_THREAD_WORKER) { odp_thrmask_clr(&thread_globals->worker, thr); - else + thread_globals->num_worker--; + } else { odp_thrmask_clr(&thread_globals->control, thr); + thread_globals->num_control--; + } thread_globals->num--; return thread_globals->num; @@ -192,3 +200,15 @@ int odp_cpu_id(void) { return this_thread->cpu; } + +int odp_thrmask_worker(odp_thrmask_t *mask) +{ + odp_thrmask_copy(mask, &thread_globals->worker); + return thread_globals->num_worker; +} + +int odp_thrmask_control(odp_thrmask_t *mask) +{ + odp_thrmask_copy(mask, &thread_globals->control); + return thread_globals->num_control; +}