From patchwork Tue Feb 28 03:22:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Forrest Shi X-Patchwork-Id: 94600 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1162980qgi; Mon, 27 Feb 2017 20:45:54 -0800 (PST) X-Received: by 10.237.34.8 with SMTP id n8mr503820qtc.98.1488257154367; Mon, 27 Feb 2017 20:45:54 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 21si574046qkg.228.2017.02.27.20.45.53; Mon, 27 Feb 2017 20:45:54 -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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 70BDA63631; Tue, 28 Feb 2017 04:45:53 +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=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,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 94BD760E6D; Tue, 28 Feb 2017 04:45:35 +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 96DBB60E6D; Tue, 28 Feb 2017 04:45:30 +0000 (UTC) Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0118.outbound.protection.outlook.com [104.47.38.118]) by lists.linaro.org (Postfix) with ESMTPS id 850C660E6D for ; Tue, 28 Feb 2017 04:39:35 +0000 (UTC) Received: from BN3PR03CA0108.namprd03.prod.outlook.com (10.174.66.26) by BN6PR03MB2977.namprd03.prod.outlook.com (10.175.126.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Tue, 28 Feb 2017 04:39:33 +0000 Received: from BN1AFFO11FD035.protection.gbl (2a01:111:f400:7c10::154) by BN3PR03CA0108.outlook.office365.com (2603:10b6:400:4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12 via Frontend Transport; Tue, 28 Feb 2017 04:39:33 +0000 Received-SPF: Neutral (protection.outlook.com: 192.88.168.50 is neither permitted nor denied by domain of freescale.com) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Tue, 28 Feb 2017 04:39:33 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v1S4dVOA009951; Mon, 27 Feb 2017 21:39:32 -0700 From: To: Date: Tue, 28 Feb 2017 11:22:16 +0800 Message-ID: <1488252137-14939-1-git-send-email-forrest.shi@linaro.org> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39860400002)(39850400002)(39840400002)(39450400003)(39410400002)(2980300002)(199003)(189002)(9170700003)(110136004)(50986999)(5003940100001)(305945005)(38730400002)(356003)(76506005)(8936002)(57986006)(48376002)(42882006)(6916009)(53936002)(626004)(36756003)(50466002)(6666003)(104016004)(189998001)(54906002)(92566002)(8656002)(77096006)(50226002)(2351001)(33646002)(81166006)(106466001)(105586002)(5660300001)(2906002)(47776003)(4326007)(8676002)(2876002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN6PR03MB2977; H:tx30smr01.am.freescale.net; FPR:; SPF:Neutral; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD035; 1:v57pWyfD5QPVaUs+DUwzEJRwI9z/sWYGRJwC+cjp6Uy5GOcCoUtkZAXaAplGXIpGoVtaXIu+8T+DZteKEy7WLWOMANwrlBsleKEmwml2EyNShHG7103oiEGTkVR5am1jwOCFANLsdbKl551hhyp8NFO5dtLTnd664IT8Vov7z62BVprtCc7/rmnyjh07Zxi0Wr0fUwPV+855uLT1mLRZ3z9Um8WzMweUJmZBX4G5h6RwO6Nd5L60dYNNy0JeG4UcDcCBHsTyBW3OvF9uoBz5o6LzuN6Ixyzx+0K+bDEEqZbEy4VQKXkwSBefQKOkisUQREHPVRgDPaoa0WuxXRR3jsi2IchnUEpnLeewEIUATu683hq35VhVcmAuhcN0qzns/tv/7iUKVWYsjEkq3kdjjXO+juES9eTNmupV4+H7T5DQao+Aen3KU3plqJjK098Ov9u4BAHpFoQ9rZUqmyHZEKmWAp4AkUoBcd2E+m9q3NFhDFJoZziCSf2VvBCM1QWzyy8AnN0wD4lYKOhJ/ahtLa9t14pwH2jLUsHIcpb6PaBn9S9ENn1H6ymV1mKlhGo64VxWlobTVRX2brkjQFdWStO3AglaSZdeM42l4/JCJ6U= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5f139f7b-4eaa-4148-8eb8-08d45f93cafd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR03MB2977; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2977; 3:mh93mzv6z28fVWvXnkzQEyyRPDj3T9A2+5ChRbGkMLFe6L9J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lP7IvwcjUxEXZ20k5jKRTyXTsH13uVm4t93IGHio5746dpaTJ0+TD01wzxQlg7LOMCsGHNsvsH5svFzyokzKXw/5xS+fYm4Jvgz/l1z9PmhuGf5skqV6lURv7qquJu2ns=; 20:wRRjaGwXVnVWj7ql2uZJ4FXoTWIKzn9E3I23ZNuc+po2/3FDCBrwNQCjQ49CgvqKOBfypVMz8O+lRdOFk/9wpXmlQ3HPZYyTGwtvs/ssWENbwFKSu9JhkRRYH4BwYToluVdx1unc3J1i9XDpHQJFxyBPeOOlRgaPcGVi7CXuq/2tu5agry3+M8ikd7k7hkTQisCDm8w1zTd+aU9w+UTi+S+kKx1Egfjg+mywD1c3q/WgHYdyifyPKuTWoo4xEMygDCiVLxPt7FjiLZiCyYZjSQdwoWCK3+FctKei7K3npoUHVRhSsxKovTdaPK10gLJOATG2edPE96ruzYLpIMXKzcerCuMVvh1RgZxSqkkr/+pLSRADYF0JAWP650E5ry7yRQlV8kNPQ2jv2LgFwobgjj+12bSMlKKlPJfLbK8siz81W1+FMSCVM0H6NAbXomCB5SjiGuV7N6ejS52rZol/Wt+0n7lNnZ+iQonpZhjBnDQKs/NywwlS55Fdrr4rixVxuk8RsWBu3UU/AgzwG6SXuBpWb16Z4RC3gazEnTuVU3KNj6YfvFlApCRc7ZMNI0NC7nDC0SimaAkuRRnu/kuWZjCNMNLoETaixUZrrla5AH8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13017025)(13015025)(13018025)(13023025)(13024025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(6072148); SRVR:BN6PR03MB2977; BCL:0; PCL:0; RULEID:; SRVR:BN6PR03MB2977; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2977; 4:j0aLbCx6l6mhoCgyU7GYiNjEnzvhlQbUpP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Ui7cuvR261ntJ27dJliMNmxoSvUSN1oHBO8GUtQjgYwcrTb8GE7y9/3YhfFZuEGSaE1P2BHh1qzyCz+9W/wxu5tlpd9495eUB6IcR5jN1XNWoC4Fm03z/BlriXQWjkFnsd8YpaPZ3KAjLohEAvrRUvHk7w8Goj/33uvKLiFVFFsdwg2bF6dyZgI0fLVKnLwpIvOJbzKzCHUj8gAQRk4tbaNcOZYf4a71C0=; 5:zsXU0UKy1XvT9d0UZEB4ye8XlhuZ/ccpfSjxVfKvqzY5xjPrycY38qp/It/ec0yOk714oxuaI8XLVL3qecJGoniP8bdnou/wbc5P7NwAFRtmyabSlHJf4kwDp9ZHFWnIHDlWK/iub8uszBxk6V1+BA==; 24:p2OWxlmUEVDGJHO936JHZk20hZvweadAOJ+qrWtk3IIeyOp026/MF9YvOkq9StMxrebK22p6QAwEHXqRj7aqeK7EY3M2Vr1FQ6zV+nUJHZE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2977; 7:/AvdtjGGypBjChD0SiOczo71PINv4GEN66KgtzaUXPnqjlSO1b9a4+NIzBmBFELHArGZ3znLOZ//Xny86RmpfeeGOPBrp6vHyqLFVp3nXMpjrg+6tAs8ntYK6vL2Udsld+Wl7MCH7Eeofu6tH7UA5Xrh1vxr+W2A5Oe8oKhagwQ5VWXL8RUhleLHRBorXK3mWNC2US+SVmkfc9hJ4fX8kTRJ4rgweeAZ7QA/CBcLpj4dLdA3mNwfb0KCPVWqCYkF5XzZWASba9uwmbM0wkwIqQSWpGO76ctfHKpaCo37BKRpx/Z+pdAbG5aVpjv53JGMw5BXXoZ6f71w6GB1P+PruQ== X-OriginatorOrg: freescale.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2017 04:39:33.4812 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2977 Cc: xuelin.shi@nxp.com Subject: [lng-odp] [PATCH 1/2 v3] linux-gen: traffic_mgmr: support termination in barrier. 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: Xuelin Shi While the tm_group(thread) is waiting for enquing at barrier, it may receive destroy call. In this case, need a mechanism to exit. This patch adds a variant of odp_barrier_wait to enable it. Signed-off-by: Xuelin Shi --- platform/linux-generic/odp_traffic_mngr.c | 93 ++++++++++++++++++++++++------- 1 file changed, 73 insertions(+), 20 deletions(-) -- 1.8.3.1 diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 309f237..9b61c50 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -91,6 +91,8 @@ static int g_main_thread_cpu = -1; static int g_tm_cpu_num; /* Forward function declarations. */ +static int _odp_tm_group_remove(_odp_tm_group_t odp_tm_group, odp_tm_t odp_tm); + static void tm_queue_cnts_decrement(tm_system_t *tm_system, tm_wred_node_t *tm_wred_node, uint32_t priority, @@ -2326,6 +2328,58 @@ static int thread_affinity_get(odp_cpumask_t *odp_cpu_mask) return 0; } +static tm_system_t *tm_system_find_run(tm_system_group_t *grp, + tm_system_t *tm_system) +{ + while (tm_system && odp_atomic_load_u64(&tm_system->destroying)) { + tm_system_t *odp_tm; + + odp_tm = tm_system->next; + odp_barrier_wait(&tm_system->tm_system_destroy_barrier); + _odp_tm_group_remove(MAKE_ODP_TM_SYSTEM_GROUP(grp), + MAKE_ODP_TM_HANDLE(tm_system)); + tm_system = odp_tm; + if (!grp->num_tm_systems) + tm_system = NULL; + } + + return tm_system; +} + +static bool odp_barrier_wait_stop(tm_system_group_t *grp, + bool (*stop)(tm_system_group_t *grp)) +{ + uint32_t count; + int wasless; + odp_barrier_t *barrier = &grp->tm_group_barrier; + + odp_mb_full(); + + count = odp_atomic_fetch_inc_u32(&barrier->bar); + wasless = count < barrier->count; + + if (count == 2 * barrier->count - 1) { + /* Wrap around *atomically* */ + odp_atomic_sub_u32(&barrier->bar, 2 * barrier->count); + } else { + while ((odp_atomic_load_u32(&barrier->bar) < barrier->count) + == wasless) + if (!stop(grp)) + odp_cpu_pause(); + else + return true; + } + + odp_mb_full(); + + return false; +} + +static bool try_stop_tm_group(tm_system_group_t *grp) +{ + return tm_system_find_run(grp, grp->first_tm_system) == NULL; +} + static void *tm_system_thread(void *arg) { _odp_timer_wheel_t _odp_int_timer_wheel; @@ -2333,7 +2387,7 @@ static void *tm_system_thread(void *arg) tm_system_group_t *tm_group; tm_system_t *tm_system; uint64_t current_ns; - uint32_t destroying, work_queue_cnt, timer_cnt; + uint32_t work_queue_cnt, timer_cnt; int rc; rc = odp_init_local((odp_instance_t)odp_global_data.main_pid, @@ -2341,20 +2395,28 @@ static void *tm_system_thread(void *arg) ODP_ASSERT(rc == 0); tm_group = arg; - tm_system = tm_group->first_tm_system; - _odp_int_timer_wheel = tm_system->_odp_int_timer_wheel; - input_work_queue = tm_system->input_work_queue; + /* Wait here until we have seen the first enqueue operation + or destroy. */ + if (odp_barrier_wait_stop(tm_group, try_stop_tm_group)) { + odp_term_local(); + return NULL; + } - /* Wait here until we have seen the first enqueue operation. */ - odp_barrier_wait(&tm_group->tm_group_barrier); main_loop_running = true; + tm_system = tm_system_find_run(tm_group, tm_group->first_tm_system); + if (!tm_system) { + odp_term_local(); + return NULL; + } - destroying = odp_atomic_load_u64(&tm_system->destroying); - + _odp_int_timer_wheel = tm_system->_odp_int_timer_wheel; current_ns = odp_time_to_ns(odp_time_local()); _odp_timer_wheel_start(_odp_int_timer_wheel, current_ns); - while (destroying == 0) { + while (tm_system) { + _odp_int_timer_wheel = tm_system->_odp_int_timer_wheel; + input_work_queue = tm_system->input_work_queue; + /* See if another thread wants to make a configuration * change. */ check_for_request(); @@ -2392,16 +2454,12 @@ static void *tm_system_thread(void *arg) tm_system->current_time = current_ns; tm_system->is_idle = (timer_cnt == 0) && (work_queue_cnt == 0); - destroying = odp_atomic_load_u64(&tm_system->destroying); /* Advance to the next tm_system in the tm_system_group. */ - tm_system = tm_system->next; - _odp_int_timer_wheel = tm_system->_odp_int_timer_wheel; - input_work_queue = tm_system->input_work_queue; + tm_system = tm_system_find_run(tm_group, tm_system->next); } - - odp_barrier_wait(&tm_system->tm_system_destroy_barrier); odp_term_local(); + return NULL; } @@ -2992,11 +3050,6 @@ int odp_tm_destroy(odp_tm_t odp_tm) odp_atomic_inc_u64(&tm_system->destroying); odp_barrier_wait(&tm_system->tm_system_destroy_barrier); - /* Remove ourselves from the group. If we are the last tm_system in - * this group, odp_tm_group_remove will destroy any service threads - * allocated by this group. */ - _odp_tm_group_remove(tm_system->odp_tm_group, odp_tm); - input_work_queue_destroy(tm_system->input_work_queue); _odp_sorted_pool_destroy(tm_system->_odp_int_sorted_pool); _odp_queue_pool_destroy(tm_system->_odp_int_queue_pool);