From patchwork Fri Aug 7 11:47:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 52036 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 1A10220539 for ; Fri, 7 Aug 2015 11:56:14 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf17052948wic.1 for ; Fri, 07 Aug 2015 04:56:13 -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=TJVS0UA68ckRuxtzRBYMVzN2MwUS79eKmTTeScV5A8E=; b=RnoxrhaIzr+a6Z7VC4d21gzdO0/ow9eYJ1CgNZ0rKvl8g0XpjHbR8FRd/PCH5w50Yn Hw0QwvNIwVZPITT7p/iGIUwdt2apFelqSyOhJTMMU1zkzQqcWeInUHXVEV+VUMd/n8hX TtMfeRkm7jmhi3Hro5XEBMdyUvgkTS51NQKXNnBl3vkwoDwXggXTKFrN6yEmakWrQrTp WARHWWwFBjetvBujHEuwU2xLa89q42AH81U27Rl86PYnMNbTYpoUVXl9suuXOo0dmQu3 rSeHM6xX/kYHqaWc8CBy3L0DBinsGzwvIrxoy+ssWvpbJk/i1Z+LbykWkd6RPCp47Hdg I/eA== X-Gm-Message-State: ALoCoQl0giUP+fbxlkJMvO3hdeoLh5NguO8t9967S0/RDlooh+Xy+nhF5g7ptQzeRifICNl58MeF X-Received: by 10.112.130.200 with SMTP id og8mr2011678lbb.21.1438948573368; Fri, 07 Aug 2015 04:56:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.2 with SMTP id s2ls427767lal.86.gmail; Fri, 07 Aug 2015 04:56:13 -0700 (PDT) X-Received: by 10.152.8.234 with SMTP id u10mr7104799laa.8.1438948573215; Fri, 07 Aug 2015 04:56:13 -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 ld1si7306585lab.51.2015.08.07.04.56.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2015 04:56:13 -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 lagz9 with SMTP id z9so20621008lag.3 for ; Fri, 07 Aug 2015 04:56:13 -0700 (PDT) X-Received: by 10.112.166.2 with SMTP id zc2mr7064637lbb.29.1438948573099; Fri, 07 Aug 2015 04:56:13 -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 l6csp323063lba; Fri, 7 Aug 2015 04:56:12 -0700 (PDT) X-Received: by 10.140.106.137 with SMTP id e9mr12116181qgf.106.1438948571524; Fri, 07 Aug 2015 04:56:11 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 67si17501335qkq.38.2015.08.07.04.56.10; Fri, 07 Aug 2015 04:56:11 -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 D030361EF8; Fri, 7 Aug 2015 11:56:10 +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 97F9062204; Fri, 7 Aug 2015 11:48:55 +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 8B214621E4; Fri, 7 Aug 2015 11:48:49 +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 9086362189 for ; Fri, 7 Aug 2015 11:47:31 +0000 (UTC) Received: by obbfr1 with SMTP id fr1so40390902obb.1 for ; Fri, 07 Aug 2015 04:47:31 -0700 (PDT) X-Received: by 10.182.20.141 with SMTP id n13mr6554117obe.26.1438948051094; Fri, 07 Aug 2015 04:47:31 -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 f128sm338865oig.2.2015.08.07.04.47.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Aug 2015 04:47:30 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 7 Aug 2015 06:47:14 -0500 Message-Id: <1438948036-31868-12-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438948036-31868-1-git-send-email-bill.fischofer@linaro.org> References: <1438948036-31868-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv9 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 f7388c7..ec1f797 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; @@ -688,6 +690,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; } @@ -734,6 +737,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; } @@ -802,8 +806,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) { @@ -825,7 +829,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; @@ -885,3 +890,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; +}