From patchwork Wed Aug 5 22:55:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 51989 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 2D14822A15 for ; Wed, 5 Aug 2015 23:05:08 +0000 (UTC) Received: by wibdx1 with SMTP id dx1sf211444wib.2 for ; Wed, 05 Aug 2015 16:05:07 -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=JehBR4uJ2ja4w0m/bB1Ouehd4jePrTOUf9/A9ogJVcNms7OYDETJtgUt+LlH6EzqDQ LPUZ3MNFfTGK6jI6xo33kas1WtRxipNO6OSLoO/M5lOSILIYBe9/ygA//YhLeXb0vB0M lmv0qx1jnYIGdZDbuzfepDZG59/0evGq5xCWAiQ3NKrgCHAGeO+wqNUcE7xdPNnv+KR0 RN6xmkOYqL3ppU7OqwWVhclslr6pcBHicZF8C6Hc93dWT9r3bg/xJXOcKta5mvurZ2sw qCm7xACpFbDsGHRUXvtkYX2MARVsym3YM1BC9hj9DEkDifH44iyD4VDNEbFA9uxHawtU X2ig== X-Gm-Message-State: ALoCoQlMq8fy+ZdJw6dp2MBMsjtG6nz8WMJi6Kt4LgMCdSfJl2GQlGr5/U/jvNBXpEVTH7zQcVDW X-Received: by 10.180.205.198 with SMTP id li6mr28528wic.5.1438815907451; Wed, 05 Aug 2015 16:05:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.133 with SMTP id v5ls259151lae.63.gmail; Wed, 05 Aug 2015 16:05:07 -0700 (PDT) X-Received: by 10.152.178.193 with SMTP id da1mr10425630lac.53.1438815907281; Wed, 05 Aug 2015 16:05:07 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id tk5si3321129lbb.14.2015.08.05.16.05.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Aug 2015 16:05:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labgo9 with SMTP id go9so38206040lab.3 for ; Wed, 05 Aug 2015 16:05:07 -0700 (PDT) X-Received: by 10.152.6.69 with SMTP id y5mr11739210lay.72.1438815907003; Wed, 05 Aug 2015 16:05:07 -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 l6csp616002lba; Wed, 5 Aug 2015 16:05:05 -0700 (PDT) X-Received: by 10.141.23.84 with SMTP id z81mr22741641qhd.14.1438815905268; Wed, 05 Aug 2015 16:05:05 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b76si4069511qkh.26.2015.08.05.16.05.03; Wed, 05 Aug 2015 16:05:05 -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 4487661FCA; Wed, 5 Aug 2015 23:05:03 +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 194F1620A1; Wed, 5 Aug 2015 22:56: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 0B3BB620CF; Wed, 5 Aug 2015 22:56:47 +0000 (UTC) Received: from mail-ob0-f171.google.com (mail-ob0-f171.google.com [209.85.214.171]) by lists.linaro.org (Postfix) with ESMTPS id 5CD6B620A1 for ; Wed, 5 Aug 2015 22:55:37 +0000 (UTC) Received: by obnw1 with SMTP id w1so42992938obn.3 for ; Wed, 05 Aug 2015 15:55:37 -0700 (PDT) X-Received: by 10.182.86.72 with SMTP id n8mr10788016obz.9.1438815336851; Wed, 05 Aug 2015 15:55:36 -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 u81sm2658477oie.11.2015.08.05.15.55.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Aug 2015 15:55:36 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 5 Aug 2015 17:55:19 -0500 Message-Id: <1438815321-12344-12-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438815321-12344-1-git-send-email-bill.fischofer@linaro.org> References: <1438815321-12344-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv8 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.42 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; +}