From patchwork Fri Jan 26 16:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 125996 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp432880ljd; Fri, 26 Jan 2018 08:00:26 -0800 (PST) X-Google-Smtp-Source: AH8x224I/DHm/Tt9A45eFO8om0wY98UQpXg7toRVd7pafEwWDhQcxVdydNhydsOYTsrqiIUl0GQ8 X-Received: by 10.237.38.132 with SMTP id q4mr23699788qtd.134.1516982425855; Fri, 26 Jan 2018 08:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516982425; cv=none; d=google.com; s=arc-20160816; b=iwSVn8nhqVY/K7ynS3V4mNs+9r7kx23lpZl6L5IGqdEyn8i1IXQlbrOrF4sLr/fee2 vOIZakwm5/7HUb+M1j02BFJZdJtHXu8UWtaJW+v0r/E7PIJJyBcDpw/EwlFisAWcdKBt fc7sm2S3OvDTHi7A1vZtKG7Ab5CMfdc675NwuIhtx8PBaYpDLquqiaUNNploQwQcOq4E 3Ry8RsgebJvbZeKGTnO8ocCKYIlJZeRXqoY9pbrdtu5XozpOdLroXdrUoLR0rAYaRzv+ yZY6hQna7dWF+nVLt/A+2O2vEMfsMeRD56SRap6LkSYQX3Ag8TW2Q/D7Fn0Ojuy5qFgv H+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=+avJ7o8NyNSFPefslZFCZRvIpZS/58E4cQJzVM8KBzw=; b=kgfPxfiY0XRwRA6/CzLQMvpaHvufj0Hoc/E5f5G0RezGtbT5tCwaYlfXB1yoiNcT4W iutGJZb+I8hXz5ncgzdh3LDjSzBdVaaHiDjjfkI+vZh7Em3LrlOg1/27bLNpWbCNcbYv mbFzfmwYBFsBTC5QvU++6BZhuNWt03EysiImU7RxUh0KDUsGIbb48ev6j0RSViuJejcN aoyuH6GD+3IGx2s43egSRPjuFpd+/f9RC7wsPBpbaqU8LuB5ZYQ3D8NY9oZ4l7xmS3ii 9nDHRxA6FclwyfN/fO/VMNAm3uhe4Z9iL3WRNpzeaDeoqmrsUPhqICAtknYlap7twhpQ lc0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id m20si5465197qtb.458.2018.01.26.08.00.25; Fri, 26 Jan 2018 08:00:25 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 24690617BA; Fri, 26 Jan 2018 16:00:25 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 E362961701; Fri, 26 Jan 2018 16:00:16 +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 CF36D61727; Fri, 26 Jan 2018 16:00:13 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 16C976152B for ; Fri, 26 Jan 2018 16:00:11 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward104p.mail.yandex.net (Yandex) with ESMTP id AD9B718519E for ; Fri, 26 Jan 2018 19:00:09 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DSGin3v6Bu-09umIOIp; Fri, 26 Jan 2018 19:00:09 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id DoB1D1wBxs-08F8ZnB6; Fri, 26 Jan 2018 19:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 26 Jan 2018 19:00:06 +0300 Message-Id: <1516982407-9893-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516982407-9893-1-git-send-email-odpbot@yandex.ru> References: <1516982407-9893-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 433 Subject: [lng-odp] [PATCH v1 1/2] linux-gen: thread: inline thread and cpu id 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" From: Petri Savolainen Inline thread and cpu id functions as application may use those often. Signed-off-by: Petri Savolainen --- /** Email created from pull request 433 (psavol:master-thread-inline) ** https://github.com/Linaro/odp/pull/433 ** Patch: https://github.com/Linaro/odp/pull/433.patch ** Base sha: 6be7adab1a16a62e871bc4ed4f3c926645b2ecd0 ** Merge commit sha: 81e939496b96b0bf1c85e197d4aa70c21870ecf7 **/ include/Makefile.am | 1 + include/odp/api/cpu.h | 2 + include/odp/api/spec/thread.h | 28 ---------- include/odp/api/spec/thread_types.h | 59 ++++++++++++++++++++++ include/odp/api/thread.h | 2 + platform/linux-generic/Makefile.am | 3 ++ .../linux-generic/include-abi/odp/api/abi/thread.h | 4 ++ .../include/odp/api/plat/thread_inlines.h | 46 +++++++++++++++++ .../include/odp/api/plat/thread_inlines_api.h | 41 +++++++++++++++ platform/linux-generic/odp_thread.c | 36 +++---------- platform/linux-generic/odp_thread_api.c | 15 ++++++ 11 files changed, 181 insertions(+), 56 deletions(-) create mode 100644 include/odp/api/spec/thread_types.h create mode 100644 platform/linux-generic/include/odp/api/plat/thread_inlines.h create mode 100644 platform/linux-generic/include/odp/api/plat/thread_inlines_api.h create mode 100644 platform/linux-generic/odp_thread_api.c diff --git a/include/Makefile.am b/include/Makefile.am index c3452ef33..aa330b8d4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -96,6 +96,7 @@ odpapispecinclude_HEADERS = \ odp/api/spec/sync.h \ odp/api/spec/system_info.h \ odp/api/spec/thread.h \ + odp/api/spec/thread_types.h \ odp/api/spec/threshold.h \ odp/api/spec/thrmask.h \ odp/api/spec/ticketlock.h \ diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h index 7229857a5..41c21b8a6 100644 --- a/include/odp/api/cpu.h +++ b/include/odp/api/cpu.h @@ -19,6 +19,8 @@ extern "C" { #include +/* Thread inline file implements cpu API function */ +#include #include #ifdef __cplusplus diff --git a/include/odp/api/spec/thread.h b/include/odp/api/spec/thread.h index 5fe74c69d..125e7a117 100644 --- a/include/odp/api/spec/thread.h +++ b/include/odp/api/spec/thread.h @@ -30,34 +30,6 @@ extern "C" { * which depend on system configuration and may be lower than this number. */ -/** - * Thread type - */ -typedef enum odp_thread_type_e { - /** - * Worker thread - * - * Worker threads do most part of ODP application packet processing. - * These threads provide high packet and data rates, with low and - * predictable latency. Typically, worker threads are pinned to isolated - * CPUs and packets are processed in a run-to-completion loop with very - * low interference from the operating system. - */ - ODP_THREAD_WORKER = 0, - - /** - * Control thread - * - * Control threads do not participate the main packet flow through the - * system, but e.g. control or monitor the worker threads, or handle - * exceptions. These threads may perform general purpose processing, - * use system calls, share the CPU with other threads and be interrupt - * driven. - */ - ODP_THREAD_CONTROL -} odp_thread_type_t; - - /** * Get thread identifier * diff --git a/include/odp/api/spec/thread_types.h b/include/odp/api/spec/thread_types.h new file mode 100644 index 000000000..a5ddb78ea --- /dev/null +++ b/include/odp/api/spec/thread_types.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP thread API types + */ + +#ifndef ODP_API_SPEC_THREAD_TYPES_H_ +#define ODP_API_SPEC_THREAD_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup odp_thread ODP THREAD + * @{ + */ + +/** + * Thread type + */ +typedef enum odp_thread_type_e { + /** + * Worker thread + * + * Worker threads do most part of ODP application packet processing. + * These threads provide high packet and data rates, with low and + * predictable latency. Typically, worker threads are pinned to isolated + * CPUs and packets are processed in a run-to-completion loop with very + * low interference from the operating system. + */ + ODP_THREAD_WORKER = 0, + + /** + * Control thread + * + * Control threads do not participate the main packet flow through the + * system, but e.g. control or monitor the worker threads, or handle + * exceptions. These threads may perform general purpose processing, + * use system calls, share the CPU with other threads and be interrupt + * driven. + */ + ODP_THREAD_CONTROL +} odp_thread_type_t; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/odp/api/thread.h b/include/odp/api/thread.h index 85af314be..d11c1671a 100644 --- a/include/odp/api/thread.h +++ b/include/odp/api/thread.h @@ -17,6 +17,8 @@ extern "C" { #endif +#include + #include #include diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index da5540fed..a1cfc6976 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -34,6 +34,8 @@ odpapiplatinclude_HEADERS = \ include/odp/api/plat/std_clib_inlines.h \ include/odp/api/plat/strong_types.h \ include/odp/api/plat/sync_inlines.h \ + include/odp/api/plat/thread_inlines.h \ + include/odp/api/plat/thread_inlines_api.h \ include/odp/api/plat/ticketlock_inlines.h \ include/odp/api/plat/ticketlock_inlines_api.h @@ -206,6 +208,7 @@ __LIB__libodp_linux_la_SOURCES += \ odp_packet_flags_api.c \ odp_std_clib.c \ odp_sync.c \ + odp_thread_api.c \ odp_ticketlock.c endif diff --git a/platform/linux-generic/include-abi/odp/api/abi/thread.h b/platform/linux-generic/include-abi/odp/api/abi/thread.h index dc29a7dac..eb92d43c4 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/thread.h +++ b/platform/linux-generic/include-abi/odp/api/abi/thread.h @@ -5,3 +5,7 @@ */ #include + +#define _ODP_INLINE static inline +#include +#include diff --git a/platform/linux-generic/include/odp/api/plat/thread_inlines.h b/platform/linux-generic/include/odp/api/plat/thread_inlines.h new file mode 100644 index 000000000..048df50bb --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/thread_inlines.h @@ -0,0 +1,46 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_THREAD_INLINES_H_ +#define ODP_PLAT_THREAD_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +typedef struct { + int thr; + int cpu; + odp_thread_type_t type; + +} _odp_thread_state_t; + +extern __thread _odp_thread_state_t *_odp_this_thread; + +static inline int _odp_thread_id(void) +{ + return _odp_this_thread->thr; +} + +static inline odp_thread_type_t _odp_thread_type(void) +{ + return _odp_this_thread->type; +} + +static inline int _odp_cpu_id(void) +{ + return _odp_this_thread->cpu; +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/thread_inlines_api.h b/platform/linux-generic/include/odp/api/plat/thread_inlines_api.h new file mode 100644 index 000000000..1c282a5cf --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/thread_inlines_api.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + */ + +#ifndef ODP_PLAT_THREAD_INLINES_API_H_ +#define ODP_PLAT_THREAD_INLINES_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +_ODP_INLINE int odp_thread_id(void) +{ + return _odp_thread_id(); +} + +_ODP_INLINE odp_thread_type_t odp_thread_type(void) +{ + return _odp_thread_type(); +} + +_ODP_INLINE int odp_cpu_id(void) +{ + return _odp_cpu_id(); +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index ffc247a4b..971837b00 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -19,20 +19,14 @@ #include #include #include +#include #include #include #include typedef struct { - int thr; - int cpu; - odp_thread_type_t type; -} thread_state_t; - - -typedef struct { - thread_state_t thr[ODP_THREAD_COUNT_MAX]; + _odp_thread_state_t thr[ODP_THREAD_COUNT_MAX]; struct { odp_thrmask_t all; @@ -46,14 +40,15 @@ typedef struct { odp_spinlock_t lock; } thread_globals_t; - /* Globals */ static thread_globals_t *thread_globals; +#include /* Thread local */ -static __thread thread_state_t *this_thread; +__thread _odp_thread_state_t *_odp_this_thread; +#include int odp_thread_init_global(void) { @@ -162,7 +157,7 @@ int odp_thread_init_local(odp_thread_type_t type) thread_globals->thr[id].cpu = cpu; thread_globals->thr[id].type = type; - this_thread = &thread_globals->thr[id]; + _odp_this_thread = &thread_globals->thr[id]; sched_fn->thr_add(ODP_SCHED_GROUP_ALL, id); @@ -177,8 +172,8 @@ int odp_thread_init_local(odp_thread_type_t type) int odp_thread_term_local(void) { int num; - int id = this_thread->thr; - odp_thread_type_t type = this_thread->type; + int id = _odp_this_thread->thr; + odp_thread_type_t type = _odp_this_thread->type; sched_fn->thr_rem(ODP_SCHED_GROUP_ALL, id); @@ -199,11 +194,6 @@ int odp_thread_term_local(void) return num; /* return a number of threads left */ } -int odp_thread_id(void) -{ - return this_thread->thr; -} - int odp_thread_count(void) { return thread_globals->num; @@ -214,16 +204,6 @@ int odp_thread_count_max(void) return ODP_THREAD_COUNT_MAX; } -odp_thread_type_t odp_thread_type(void) -{ - return this_thread->type; -} - -int odp_cpu_id(void) -{ - return this_thread->cpu; -} - int odp_thrmask_worker(odp_thrmask_t *mask) { odp_thrmask_copy(mask, &thread_globals->worker); diff --git a/platform/linux-generic/odp_thread_api.c b/platform/linux-generic/odp_thread_api.c new file mode 100644 index 000000000..ee5beb162 --- /dev/null +++ b/platform/linux-generic/odp_thread_api.c @@ -0,0 +1,15 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include +#include +#include + +/* Include non-inlined versions of API functions */ +#define _ODP_INLINE +#include From patchwork Fri Jan 26 16:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 125997 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp434400ljd; Fri, 26 Jan 2018 08:02:02 -0800 (PST) X-Google-Smtp-Source: AH8x2274m2LBKmXp1OWSIk3hZkR8fQU0KMQQbvar0jCkHN4lXyWq9d5edEs5WWUGSrq5g0EOI9ir X-Received: by 10.55.51.18 with SMTP id z18mr21340362qkz.103.1516982522580; Fri, 26 Jan 2018 08:02:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516982522; cv=none; d=google.com; s=arc-20160816; b=HTwy2EaPGWQR8DG5/LYzkFLl96M2ecYhHVXlFB7mke7y92Bry1kR7WWHPjlg+yqHae ndy/Aq4nqzK2waYRcE7D2GPeigNAuYe1s7kiMqvdV1A0PzlQ5NyBLJb6FHwtQgv5V+YS 7qq1k3B6Q7bXYaF2AFh5ctSA1XF3nrUryqERO+tYeL02SGsh8LOKCEszSJZA4+EdWm8a MH7JFutDC4H3mrpIFK/rj5QnOxiDSQkQbMuDSoKjujYEuEvkndaqWbksMvLpsL9cnMPi cb7WKEeotNx91SuZaCbOeOeuO1hNDPBuen5j2kxdZtmHCvTycunV0LHPzr7cqBRuAuQk PNRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=WA/sxVxwWXF06gfKeKpOrn0kyM5aprbRFNNx+Gf+daw=; b=dyK/DY8PeD9RjCF0vb52kUR/MWLUBgb58rsJANzWOMxU7gjugM65155bXjRZjnC2qm lR6tceew1nMr+4AGjGanPIuMrZeUzuOBn3WRF0MYJBOl/ddTDmnWqxsBMiEIy8Ia/+EX 0jY9ZBENTtW/muNCQL/HP3Hw+8O6d1oX6+emfVOLi8iTySWIAO7HezBgUeTa8UVfuNlB 6FWFwV7J6fl7sMlHpsx0xJXkNOVXAnBPphrQc8Bx2iG5bK5tzplTc+cfd0GFWc4pM5YL +8XceFSZTcLytl6H3oOJ8pko0irjMH03lWO4B0RZ3Ue4WQ6YZUmD8QxI3uG5pUIglNTn ZgfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id y37si5781073qty.45.2018.01.26.08.02.02; Fri, 26 Jan 2018 08:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 46C37617B3; Fri, 26 Jan 2018 16:02:02 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 AF4B261701; Fri, 26 Jan 2018 16:00: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 0266A61764; Fri, 26 Jan 2018 16:00:18 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 3C3E0616F5 for ; Fri, 26 Jan 2018 16:00:12 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 70DE15A026F6 for ; Fri, 26 Jan 2018 19:00:10 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PHyPY5XkS6-0AqiiKp7; Fri, 26 Jan 2018 19:00:10 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id DoB1D1wBxs-09FKIMAg; Fri, 26 Jan 2018 19:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 26 Jan 2018 19:00:07 +0300 Message-Id: <1516982407-9893-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516982407-9893-1-git-send-email-odpbot@yandex.ru> References: <1516982407-9893-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 433 Subject: [lng-odp] [PATCH v1 2/2] linux-gen: locks: use inlined thread id 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" From: Petri Savolainen Use internally always the inlined version of thread id function. Signed-off-by: Petri Savolainen --- /** Email created from pull request 433 (psavol:master-thread-inline) ** https://github.com/Linaro/odp/pull/433 ** Patch: https://github.com/Linaro/odp/pull/433.patch ** Base sha: 6be7adab1a16a62e871bc4ed4f3c926645b2ecd0 ** Merge commit sha: 81e939496b96b0bf1c85e197d4aa70c21870ecf7 **/ platform/linux-generic/odp_rwlock_recursive.c | 11 ++++++----- platform/linux-generic/odp_spinlock_recursive.c | 7 ++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_rwlock_recursive.c b/platform/linux-generic/odp_rwlock_recursive.c index 1f93df35d..d484ba5ae 100644 --- a/platform/linux-generic/odp_rwlock_recursive.c +++ b/platform/linux-generic/odp_rwlock_recursive.c @@ -8,6 +8,7 @@ #include #include +#include #include #define NO_OWNER (-1) @@ -22,7 +23,7 @@ void odp_rwlock_recursive_init(odp_rwlock_recursive_t *rlock) /* Multiple readers can recurse the lock concurrently */ void odp_rwlock_recursive_read_lock(odp_rwlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->rd_cnt[thr]) { rlock->rd_cnt[thr]++; @@ -36,7 +37,7 @@ void odp_rwlock_recursive_read_lock(odp_rwlock_recursive_t *rlock) /* Multiple readers can recurse the lock concurrently */ int odp_rwlock_recursive_read_trylock(odp_rwlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->rd_cnt[thr]) { rlock->rd_cnt[thr]++; @@ -53,7 +54,7 @@ int odp_rwlock_recursive_read_trylock(odp_rwlock_recursive_t *rlock) void odp_rwlock_recursive_read_unlock(odp_rwlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); rlock->rd_cnt[thr]--; @@ -66,7 +67,7 @@ void odp_rwlock_recursive_read_unlock(odp_rwlock_recursive_t *rlock) /* Only one writer can recurse the lock */ void odp_rwlock_recursive_write_lock(odp_rwlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->wr_owner == thr) { rlock->wr_cnt++; @@ -81,7 +82,7 @@ void odp_rwlock_recursive_write_lock(odp_rwlock_recursive_t *rlock) /* Only one writer can recurse the lock */ int odp_rwlock_recursive_write_trylock(odp_rwlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->wr_owner == thr) { rlock->wr_cnt++; diff --git a/platform/linux-generic/odp_spinlock_recursive.c b/platform/linux-generic/odp_spinlock_recursive.c index 5293c04b1..d6d914201 100644 --- a/platform/linux-generic/odp_spinlock_recursive.c +++ b/platform/linux-generic/odp_spinlock_recursive.c @@ -8,6 +8,7 @@ #include #include +#include #define NO_OWNER (-1) @@ -20,7 +21,7 @@ void odp_spinlock_recursive_init(odp_spinlock_recursive_t *rlock) void odp_spinlock_recursive_lock(odp_spinlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->owner == thr) { rlock->cnt++; @@ -34,7 +35,7 @@ void odp_spinlock_recursive_lock(odp_spinlock_recursive_t *rlock) int odp_spinlock_recursive_trylock(odp_spinlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->owner == thr) { rlock->cnt++; @@ -63,7 +64,7 @@ void odp_spinlock_recursive_unlock(odp_spinlock_recursive_t *rlock) int odp_spinlock_recursive_is_locked(odp_spinlock_recursive_t *rlock) { - int thr = odp_thread_id(); + int thr = _odp_thread_id(); if (rlock->owner == thr) return 1;