From patchwork Tue Nov 10 14:46:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 56328 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp813765lbb; Tue, 10 Nov 2015 06:50:27 -0800 (PST) X-Received: by 10.140.237.68 with SMTP id i65mr5010753qhc.55.1447167027225; Tue, 10 Nov 2015 06:50:27 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c34si3199329qgd.5.2015.11.10.06.50.26; Tue, 10 Nov 2015 06:50:27 -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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id CE07B61D55; Tue, 10 Nov 2015 14:50:26 +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.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID,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 9326361D0F; Tue, 10 Nov 2015 14:48:17 +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 C586261D0A; Tue, 10 Nov 2015 14:48:10 +0000 (UTC) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by lists.linaro.org (Postfix) with ESMTPS id 30AC561952 for ; Tue, 10 Nov 2015 14:47:08 +0000 (UTC) Received: by pacdm15 with SMTP id dm15so212134653pac.3 for ; Tue, 10 Nov 2015 06:47:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gIWo/Q4zKa4xX1eF7YM9gdMf0JR2qIRT9BO7pbVzaIk=; b=G6fFtser+i/5xANeiS6rPEOTIPCCklNje016KfarPU65ibtE42eouTa1OVB6w9bPCk QRNPAZ/HFkC3yH7jX5rXolTO5ko3Z475EsCh+XAVGJipXsLOVgvRxEovMqpDkcsHbkgP puoQHM0y0Ooepknxkmq0A/rvo79uZws8Tzct5KKABl2KL117n9dJ5fKruBvANtHWhV69 zj2IKyg4aQfsm5OWl4Th9yiPLIWN3brjQxar3eqAUBrIlsof/8AhBfXjoYOhXBZo8IDf qDZKilSaR1L1jOctrdN9z3as/9386b2YvhLWDqBd8Zed6DirAQV/6bbIxGlZ1LjoDxzB 7ADA== 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:in-reply-to :references; bh=gIWo/Q4zKa4xX1eF7YM9gdMf0JR2qIRT9BO7pbVzaIk=; b=YjAtu92ouHK0eh6k5rWKA/eRT5N4aQxHsIuWP94SxpzN4o8rKDlEIw7v45Q5VieOs5 3vJ3ohxiglrsf4Ro2QUR3GcVxL3R3ySTbCPemv+A9mwRudj3XeHvmxVoo9zYsjP8zeg8 yMM6teCbd7taK43FqdnlzXy1L7OGTIxfqMImI14FFivKQ5EDohIGAamuAmayrd2s828I 75iq8Yjl2622iHcLKVNSJ1lUfwDOMlj8xxvoP3mqzDMR5b2rzWOtEy7k3Cbzc1z9O/pm TEabAbUnrgfEgyXteTyU47QXXt0Hgrnp2bZfAFVzQIfBNxiu2nRg3JqS7R8/SUbk9COU 8Qfw== X-Gm-Message-State: ALoCoQmNXig4o4Q4YfTrGTiJzAnszZDwu3/DsJ9eVjAhcWj0A2gA1m/vJRoMoMk45kVl0Wg8ooo7 X-Received: by 10.66.140.79 with SMTP id re15mr6166648pab.127.1447166827412; Tue, 10 Nov 2015 06:47:07 -0800 (PST) Received: from Ubuntu15.localdomain ([40.139.248.3]) by smtp.gmail.com with ESMTPSA id w11sm4531237pbs.87.2015.11.10.06.47.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Nov 2015 06:47:06 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 10 Nov 2015 06:46:54 -0800 Message-Id: <1447166821-24585-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447166821-24585-1-git-send-email-bill.fischofer@linaro.org> References: <1447166821-24585-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 1/8] linux-generic: schedule: move ordered lock routines to odp_schedule.c 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Move the odp_schedule_order_lock() and odp_schedule_order_unlock() routines from odp_queue.c to odp_schedule.c Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_queue.c | 31 ------------------------ platform/linux-generic/odp_schedule.c | 45 ++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 1c15e17..2071870 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -22,7 +22,6 @@ #include #include #include -#include #ifdef USE_TICKETLOCK #include @@ -1015,33 +1014,3 @@ int release_order(queue_entry_t *origin_qe, uint64_t order, UNLOCK(&origin_qe->s.lock); return 0; } - -void odp_schedule_order_lock(unsigned lock_index) -{ - queue_entry_t *origin_qe; - uint64_t *sync; - - get_sched_sync(&origin_qe, &sync, lock_index); - if (!origin_qe || lock_index >= origin_qe->s.param.sched.lock_count) - return; - - /* Wait until we are in order. Note that sync_out will be incremented - * both by unlocks as well as order resolution, so we're OK if only - * some events in the ordered flow need to lock. - */ - while (*sync > odp_atomic_load_u64(&origin_qe->s.sync_out[lock_index])) - odp_spin(); -} - -void odp_schedule_order_unlock(unsigned lock_index) -{ - queue_entry_t *origin_qe; - uint64_t *sync; - - get_sched_sync(&origin_qe, &sync, lock_index); - if (!origin_qe || lock_index >= origin_qe->s.param.sched.lock_count) - return; - - /* Release the ordered lock */ - odp_atomic_fetch_inc_u64(&origin_qe->s.sync_out[lock_index]); -} diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 6df8073..195240e 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -22,6 +22,7 @@ #include #include +#include odp_thrmask_t sched_mask_all; @@ -793,6 +794,44 @@ void odp_schedule_prefetch(int num ODP_UNUSED) { } +void odp_schedule_order_lock(unsigned lock_index) +{ + queue_entry_t *origin_qe; + uint64_t sync, sync_out; + + origin_qe = sched_local.origin_qe; + if (!origin_qe || lock_index >= origin_qe->s.param.sched.lock_count) + return; + + sync = sched_local.sync[lock_index]; + sync_out = odp_atomic_load_u64(&origin_qe->s.sync_out[lock_index]); + ODP_ASSERT(sync >= sync_out); + + /* Wait until we are in order. Note that sync_out will be incremented + * both by unlocks as well as order resolution, so we're OK if only + * some events in the ordered flow need to lock. + */ + while (sync != sync_out) { + odp_spin(); + sync_out = + odp_atomic_load_u64(&origin_qe->s.sync_out[lock_index]); + } +} + +void odp_schedule_order_unlock(unsigned lock_index) +{ + queue_entry_t *origin_qe; + + origin_qe = sched_local.origin_qe; + if (!origin_qe || lock_index >= origin_qe->s.param.sched.lock_count) + return; + ODP_ASSERT(sched_local.sync[lock_index] == + odp_atomic_load_u64(&origin_qe->s.sync_out[lock_index])); + + /* Release the ordered lock */ + odp_atomic_fetch_inc_u64(&origin_qe->s.sync_out[lock_index]); +} + void sched_enq_called(void) { sched_local.enq_called = 1; @@ -804,12 +843,6 @@ void get_sched_order(queue_entry_t **origin_qe, uint64_t *order) *order = sched_local.order; } -void get_sched_sync(queue_entry_t **origin_qe, uint64_t **sync, uint32_t ndx) -{ - *origin_qe = sched_local.origin_qe; - *sync = &sched_local.sync[ndx]; -} - void sched_order_resolved(odp_buffer_hdr_t *buf_hdr) { if (buf_hdr)