From patchwork Tue Aug 4 22:41:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 51926 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 92F4022E8E for ; Tue, 4 Aug 2015 22:52:55 +0000 (UTC) Received: by lbcjf8 with SMTP id jf8sf7677603lbc.0 for ; Tue, 04 Aug 2015 15:52:54 -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=P82Kr13owyXpuFut61pv6mAM8tH4akTCPOQBilYftgriYnSCT/Vz+QlX+t8af3io+5 dbxohKDR2VauYLA5DQVYoCqo6WAkVkd/XmPb8N5hz5botJsabJk/Z/W3zrVLpckcMGT/ fwcfxOX409vfREXZkinSgIXikTSpt0luRD3XKY/62NYSYukZjr4bQ25YUnTeg1vSKls4 KqQzEwyFlhEaXiBlPUyy778un6o0aL2Kp4mRG7eoTKqdTzqexegqHkljhtcpC8dhwjwV a3MotA6lOpADTJrM/GCLFW4oP3un5zXvbNyEzHAadfaD1t/ayxlnSXho8CfhcwnLyANi N5KQ== X-Gm-Message-State: ALoCoQk7GtbA+WP314RHbjHv++UJgHEdm61V+Q5r6hEtHqUH6jBk1JAQZi8Pf/oax4psfFjF9IjO X-Received: by 10.180.205.202 with SMTP id li10mr480770wic.5.1438728774554; Tue, 04 Aug 2015 15:52:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.34 with SMTP id n2ls110734laj.15.gmail; Tue, 04 Aug 2015 15:52:54 -0700 (PDT) X-Received: by 10.112.144.199 with SMTP id so7mr6654417lbb.109.1438728774387; Tue, 04 Aug 2015 15:52:54 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id qg4si891637lbb.25.2015.08.04.15.52.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 15:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by labsr2 with SMTP id sr2so17171359lab.2 for ; Tue, 04 Aug 2015 15:52:54 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr6678103lbc.19.1438728774233; Tue, 04 Aug 2015 15:52:54 -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 l6csp36456lba; Tue, 4 Aug 2015 15:52:53 -0700 (PDT) X-Received: by 10.107.134.81 with SMTP id i78mr7093440iod.6.1438728772607; Tue, 04 Aug 2015 15:52:52 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c19si1605440igr.84.2015.08.04.15.52.51; Tue, 04 Aug 2015 15:52:52 -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 959D861E45; Tue, 4 Aug 2015 22:52:51 +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_H3, RCVD_IN_MSPIKE_WL, 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 881A461FB7; Tue, 4 Aug 2015 22:45:45 +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 38E1561F39; Tue, 4 Aug 2015 22:43:18 +0000 (UTC) Received: from mail-ob0-f182.google.com (mail-ob0-f182.google.com [209.85.214.182]) by lists.linaro.org (Postfix) with ESMTPS id 7DA3761FAB for ; Tue, 4 Aug 2015 22:41:40 +0000 (UTC) Received: by obnw1 with SMTP id w1so18490513obn.3 for ; Tue, 04 Aug 2015 15:41:40 -0700 (PDT) X-Received: by 10.182.213.68 with SMTP id nq4mr5393949obc.16.1438728100119; Tue, 04 Aug 2015 15:41:40 -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 sx2sm519170obc.0.2015.08.04.15.41.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Aug 2015 15:41:39 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 4 Aug 2015 17:41:23 -0500 Message-Id: <1438728085-3240-12-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438728085-3240-1-git-send-email-bill.fischofer@linaro.org> References: <1438728085-3240-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv7 11/13] 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.215.54 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; +}