From patchwork Tue Jul 26 00:49:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 72751 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1416780qga; Mon, 25 Jul 2016 17:49:55 -0700 (PDT) X-Received: by 10.55.162.138 with SMTP id l132mr24577081qke.85.1469494194960; Mon, 25 Jul 2016 17:49:54 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o10si19470680qtb.120.2016.07.25.17.49.48; Mon, 25 Jul 2016 17:49:51 -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; 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 AB612684D7; Tue, 26 Jul 2016 00:49:47 +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_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 634D8684CC; Tue, 26 Jul 2016 00:49:43 +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 CFA80684D0; Tue, 26 Jul 2016 00:49:40 +0000 (UTC) Received: from mail-io0-f180.google.com (mail-io0-f180.google.com [209.85.223.180]) by lists.linaro.org (Postfix) with ESMTPS id B25A168214 for ; Tue, 26 Jul 2016 00:49:39 +0000 (UTC) Received: by mail-io0-f180.google.com with SMTP id m101so185364813ioi.2 for ; Mon, 25 Jul 2016 17:49: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:from:to:cc:subject:date:message-id; bh=UQzE/h8XUdB3aBcWSsPqd8zxsDtbN+ZIQ9Dx6QfENh4=; b=aNTH5I+YXSR5CAO+AWxG85JwyZgHkPgbxHkyZLeHFsyhvy25nRvAHXNfFO59zMaXcS t5J/egZgREcpSSek8LBuiUZpgoR7v264avsQx+OmNZA4u0umibMbfUOTKNxD2jXbZpuF 6BYsPJobLFdjyI9ChkkM7Uuw/3xGixuXmNfI7r4yS2nZ7ixJo4cd6Ei1AOaq/6kEPzm2 hC9irgOZU6BhKW8C1oqqAohHMlKBJPKEPzYXyHCLrPOaBuuFI11XvnL0f49VQl+g+/Xt 9SVE9ha2lgeabc3gZtqwwu2jd83pT7DwehGHCdUZkb6FzEXHyo0EHlr9B2phNq/ZbLVG s55g== X-Gm-Message-State: AEkoouvwMxMDqiKhtAVRz9OWTQ+rlJq6km5vlWhqGpjRyXCRTyRJb0qR9+wVGNtRC0wRv1CVUio= X-Received: by 10.157.54.176 with SMTP id h45mr12259603otc.104.1469494179096; Mon, 25 Jul 2016 17:49:39 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id b29sm3503778otb.11.2016.07.25.17.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Jul 2016 17:49:38 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 25 Jul 2016 19:49:36 -0500 Message-Id: <1469494176-5436-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [API-NEXT RFC PATCH] api: thread: add service thread types and related functions 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" Add ODP_THREAD_SERVICE as a third type of ODP thread along with related cpumask APIs that allow cores to be designated for running service threads. Service threads are intended to be used internally by ODP implementations or library functions such as OpenFastPath rather than ODP applications. Signed-off-by: Bill Fischofer --- include/odp/api/spec/cpumask.h | 13 +++++++++++++ include/odp/api/spec/init.h | 17 +++++++++++++++++ include/odp/api/spec/thread.h | 15 ++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/include/odp/api/spec/cpumask.h b/include/odp/api/spec/cpumask.h index 22d8e8f..dca0255 100644 --- a/include/odp/api/spec/cpumask.h +++ b/include/odp/api/spec/cpumask.h @@ -233,6 +233,19 @@ int odp_cpumask_default_worker(odp_cpumask_t *mask, int num); int odp_cpumask_default_control(odp_cpumask_t *mask, int num); /** + * Default cpumask for service threads + * + * Initializes cpumask with CPUs available for ODP service 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 num Number of service threads, zero for all available CPUs + * @return Actual number of CPUs used to create the mask + */ +int odp_cpumask_default_service(odp_cpumask_t *mask, int num); + +/** * Report all the available CPUs * * All the available CPUs include both worker CPUs and control CPUs diff --git a/include/odp/api/spec/init.h b/include/odp/api/spec/init.h index 154cdf8..a39bff2 100644 --- a/include/odp/api/spec/init.h +++ b/include/odp/api/spec/init.h @@ -123,6 +123,12 @@ typedef struct odp_init_t { Valid range is from 0 to platform specific maximum. Set both num_worker and num_control to zero for default number of threads. */ int num_control; + /** Maximum number of service threads available to the ODP + implementation. Valid range is from 0 to platform specific + maximum. Set to 0 (recommended) to accept default number of + threads. ODP init may fail or certain functions may not be + available if this number is set too low. */ + int num_service; /** Pointer to bit mask mapping CPUs available to this ODP instance for running worker threads. Initialize to a NULL pointer to use default CPU mapping. @@ -149,6 +155,17 @@ typedef struct odp_init_t { worker and control masks do not overlap. */ const odp_cpumask_t *control_cpus; + /** Pointer to bit mask mapping CPUs available to this ODP instance + for running ODP service threads. + Initialize to a NULL pointer to use default CPU mapping. + When the mask is defined, odp_cpumask_default_service() + uses it instead of returning a default mask. + Applications code should not access this cpumask directly. + Valid range of CPUs and optimal CPU selection + are platform specific, but generally it is recommended that + service masks do not overlap either worker or control masks. + */ + const odp_cpumask_t *service_cpus; /** Replacement for the default log fn */ odp_log_func_t log_fn; /** Replacement for the default abort fn */ diff --git a/include/odp/api/spec/thread.h b/include/odp/api/spec/thread.h index 689ba59..0f2963f 100644 --- a/include/odp/api/spec/thread.h +++ b/include/odp/api/spec/thread.h @@ -54,7 +54,20 @@ typedef enum odp_thread_type_e { * use system calls, share the CPU with other threads and be interrupt * driven. */ - ODP_THREAD_CONTROL + ODP_THREAD_CONTROL, + + /** + * Service thread + * + * Service threads are used internally by ODP implementations and/or + * libraries. They may process packets or perform other housekeeping + * functions. These threads may prefer to be bound to dedicated cores + * but may also share cores depending on resource availabilty. ODP + * applications should not use service threads but should be aware + * of their existence since they may subtract from the total number + * of cores available to the ODP application. + */ + ODP_THREAD_SERVICE, } odp_thread_type_t;