From patchwork Mon Aug 3 22:29:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 51889 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 1BE52228F2 for ; Mon, 3 Aug 2015 22:37:39 +0000 (UTC) Received: by wibdx1 with SMTP id dx1sf31924512wib.2 for ; Mon, 03 Aug 2015 15:37:38 -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: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=2ldzN+6x2kg7U4fcSvCsedV9uZe+I9BtOLd92UwDgpk=; b=EXccuuIPzv5wGyMaAfrNaoGiqTMfBF2lHnSpt/2dOecIl/L/TyGzdGyuzKseQftdqZ eA9SY1f6JlwQhGCR1RF2CV1q6kpE6hcE2BcJBvWh94Qy4uQKeXBdriiTQj0X0ODxO/OS nZ8AhqqcwANXEXlVFcWYDUFqGWzdgoXMGC+p0PZd49gGtGkfTWztDHUCoP72KY7Fjuyx 90wH+irgew+tbUItFW7QN8f92DDwsZtfYQQgo9bp8DSd3qqI3OSbt29X9jy6Yka0f4JV tY0lFByIURNr8htHePCMnAnM8wKMviea/yr6S8RzQjRNCguwFP3q9SkASQUuQIHqDeL0 +Y5A== X-Gm-Message-State: ALoCoQnaytwbCv6+FDPAHf3EYn5LuIUqFkgbUQqyUkP2LqkMoxW1f7o9Mx9lK2Hy2kFTGbclS6Q7 X-Received: by 10.194.184.6 with SMTP id eq6mr129380wjc.4.1438641458453; Mon, 03 Aug 2015 15:37:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.73 with SMTP id 9ls544406lak.17.gmail; Mon, 03 Aug 2015 15:37:38 -0700 (PDT) X-Received: by 10.112.185.66 with SMTP id fa2mr344273lbc.42.1438641458083; Mon, 03 Aug 2015 15:37:38 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id db8si13185237lad.159.2015.08.03.15.37.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 15:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbbud7 with SMTP id ud7so81528780lbb.3 for ; Mon, 03 Aug 2015 15:37:37 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr298467laa.76.1438641457629; Mon, 03 Aug 2015 15:37:37 -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.7.198 with SMTP id l6csp2098923lba; Mon, 3 Aug 2015 15:37:36 -0700 (PDT) X-Received: by 10.55.33.151 with SMTP id f23mr651357qki.83.1438641455910; Mon, 03 Aug 2015 15:37:35 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c102si11379517qge.99.2015.08.03.15.37.35; Mon, 03 Aug 2015 15:37:35 -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 2F11961EF2; Mon, 3 Aug 2015 22:37: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=-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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id F192761F24; Mon, 3 Aug 2015 22:30:51 +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 D235C61EFB; Mon, 3 Aug 2015 22:30:35 +0000 (UTC) Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by lists.linaro.org (Postfix) with ESMTPS id 51F0C61836 for ; Mon, 3 Aug 2015 22:29:54 +0000 (UTC) Received: by oigu133 with SMTP id u133so35262439oig.1 for ; Mon, 03 Aug 2015 15:29:53 -0700 (PDT) X-Received: by 10.202.180.133 with SMTP id d127mr301000oif.104.1438640993644; Mon, 03 Aug 2015 15:29:53 -0700 (PDT) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by smtp.gmail.com with ESMTPSA id fw2sm8211222obb.24.2015.08.03.15.29.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Aug 2015 15:29:53 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Mon, 3 Aug 2015 17:29:38 -0500 Message-Id: <1438640978-16334-12-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438640978-16334-1-git-send-email-bill.fischofer@linaro.org> References: <1438640978-16334-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv6 11/11] linux-generic: schedule: implement order copying and sustaining 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: bill.fischofer@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.182 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 Signed-off-by: Bill Fischofer --- .../linux-generic/include/odp_buffer_internal.h | 1 + platform/linux-generic/odp_queue.c | 43 +++++++++++++++++++--- platform/linux-generic/odp_schedule.c | 24 ++++++++++++ 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 30f061e..c9b8409 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -119,6 +119,7 @@ typedef struct odp_buffer_hdr_t { struct { uint32_t zeroized:1; /* Zeroize buf data on free */ uint32_t hdrdata:1; /* Data is in buffer hdr */ + uint32_t sustain:1; /* Sustain order */ }; } flags; int16_t allocator; /* allocating thread id */ diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index e56da71..e92ef57 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -376,7 +376,7 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) } else { odp_buffer_hdr_t *reorder_prev = NULL; - while (buf_hdr->order > reorder_buf->order) { + while (buf_hdr->order >= reorder_buf->order) { reorder_prev = reorder_buf; reorder_buf = reorder_buf->next; if (!reorder_buf) @@ -404,7 +404,8 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) } /* We're in order, so account for this and proceed with enq */ - origin_qe->s.order_out++; + if (!buf_hdr->flags.sustain) + origin_qe->s.order_out++; /* if this element is linked, restore the linked chain */ buf_tail = buf_hdr->link; @@ -494,8 +495,9 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr) reorder_prev = reorder_buf; } + if (!reorder_buf->flags.sustain) + release_count++; reorder_buf = next_buf; - release_count++; } else if (!reorder_buf->target_qe) { if (reorder_prev) reorder_prev->next = next_buf; @@ -694,6 +696,7 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) if (queue->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED) { buf_hdr->origin_qe = queue; buf_hdr->order = queue->s.order_in++; + buf_hdr->flags.sustain = 0; } else { buf_hdr->origin_qe = NULL; } @@ -740,6 +743,7 @@ int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) if (queue->s.param.sched.sync == ODP_SCHED_SYNC_ORDERED) { buf_hdr[i]->origin_qe = queue; buf_hdr[i]->order = queue->s.order_in++; + buf_hdr[i]->flags.sustain = 0; } else { buf_hdr[i]->origin_qe = NULL; } @@ -808,8 +812,8 @@ void odp_queue_param_init(odp_queue_param_t *params) memset(params, 0, sizeof(odp_queue_param_t)); } -/* This routine exists here rather than in odp_schedule - * because it operates on queue interenal structures +/* These routines exists here rather than in odp_schedule + * because they operate on queue interenal structures */ int odp_schedule_release_ordered(odp_event_t ev) { @@ -831,7 +835,8 @@ int odp_schedule_release_ordered(odp_event_t ev) */ if (buf_hdr->order <= origin_qe->s.order_out + 1) { buf_hdr->origin_qe = NULL; - origin_qe->s.order_out++; + if (!buf_hdr->flags.sustain) + origin_qe->s.order_out++; /* check if this release allows us to unblock waiters */ reorder_buf = origin_qe->s.reorder_head; @@ -891,3 +896,29 @@ int odp_schedule_release_ordered(odp_event_t ev) UNLOCK(&origin_qe->s.lock); return 0; } + +int odp_schedule_order_copy(odp_event_t src_event, odp_event_t dst_event) +{ + odp_buffer_hdr_t *src = + odp_buf_to_hdr(odp_buffer_from_event(src_event)); + odp_buffer_hdr_t *dst = + odp_buf_to_hdr(odp_buffer_from_event(dst_event)); + queue_entry_t *origin_qe = src->origin_qe; + + if (!origin_qe || dst->origin_qe) + return -1; + + LOCK(&origin_qe->s.lock); + + if (src->origin_qe != origin_qe) { + UNLOCK(&origin_qe->s.lock); + return -1; + } + + dst->origin_qe = origin_qe; + dst->order = src->order; + src->flags.sustain = 1; + + UNLOCK(&origin_qe->s.lock); + return 0; +} diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 4d594a0..548ed25 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -746,3 +746,27 @@ int odp_schedule_group_count(odp_schedule_group_t group) void odp_schedule_prefetch(int num ODP_UNUSED) { } + +int odp_schedule_order_sustain(odp_event_t ev) +{ + odp_buffer_hdr_t *buf_hdr = + odp_buf_to_hdr(odp_buffer_from_event(ev)); + + if (buf_hdr->origin_qe) + return buf_hdr->flags.sustain; + + return -1; +} + +int odp_schedule_order_sustain_set(odp_event_t ev, odp_bool_t sustain) +{ + odp_buffer_hdr_t *buf_hdr = + odp_buf_to_hdr(odp_buffer_from_event(ev)); + + if (buf_hdr->origin_qe && (sustain & 1) == sustain) { + buf_hdr->flags.sustain = sustain; + return 0; + } + + return -1; +}