From patchwork Thu Oct 29 02:32:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 55738 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp283312lbr; Wed, 28 Oct 2015 19:32:51 -0700 (PDT) X-Received: by 10.50.67.79 with SMTP id l15mr7375465igt.9.1446085971337; Wed, 28 Oct 2015 19:32:51 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id mf1si24325277igb.68.2015.10.28.19.32.50; Wed, 28 Oct 2015 19:32:51 -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; 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 8CA496201A; Thu, 29 Oct 2015 02:32:50 +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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 106766200D; Thu, 29 Oct 2015 02:32:44 +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 2B22562013; Thu, 29 Oct 2015 02:32:42 +0000 (UTC) Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com [209.85.214.181]) by lists.linaro.org (Postfix) with ESMTPS id 0251A6200A for ; Thu, 29 Oct 2015 02:32:41 +0000 (UTC) Received: by obbwb3 with SMTP id wb3so23135255obb.0 for ; Wed, 28 Oct 2015 19:32:40 -0700 (PDT) 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; bh=WAU3b4fn0arji2qJ5oGhQ0lJbeZgttO8GNw7kXx5EGU=; b=tTlmcBEiBYQhmioF7SaH5KNp4zQp/NqLsPIYfgVpbQOtKHVF6d6cySLkkUl7t262WQ qZhjq7F2XVzKRCGOJEeqg5XlpLzRJJH9lHznBdQeFMs+V3hOwFawDHa0JXIANjtPwlQi TaM8TAr88HJmpJxhvclW1fai0oWGBIO2t+EHxPwok9v30IIV5BkTLTRzeGKZyw+b4+Io 0lPNTQ/CgX5dawaVO2dTs9feC7x0+anQi7KufFqb/Kt05a+/eosoHGsBddPLtYMYBemK 9NwAynbfyf8O0KQiVK2O52RUyJuT28QfP0cPUnpJhPkZu6VgoAx5XoWDLd1StIVSAsHx ri/g== 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; bh=WAU3b4fn0arji2qJ5oGhQ0lJbeZgttO8GNw7kXx5EGU=; b=ma7ehDgeSkL1CB9z1X62Euo06YpcxvAE/5ou24eQvOyShJcPAs5iv5SV8WCtJ1+BYa dngUTmiIAoErn+/oSyNDD9VV4fCJVX3DJXa9bQ/CbScHbWhia8KqTXBal6rfKvaDFcEO 0NmxcJJMlh0VqIzjE5ORCmdKWaFBqUG4Al2mQFQ2Adzl/jhlC8eweqWcPXbHtwW8V5uo k2TZZVD1ZjsLDW3K7OncXCUHlLpt9JNEu/3/y012f6fCnsKqEH/+B6KGxJtjJs1dzPOc NmF6CN8sU5RtVYGTb2lkH2ydfXbcftkC2wcor13c6KWr61zefaXqmaGPmUUSI73nwIpb h34w== X-Gm-Message-State: ALoCoQky9w4AjV4ObwqWFhDI7cXjvLB7+Or21ix5gQ1j0PdWM/+2u/cPyRsMLwJ+CKtLD9wr1L9y X-Received: by 10.60.40.133 with SMTP id x5mr34050495oek.34.1446085960375; Wed, 28 Oct 2015 19:32:40 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id ny9sm21326320obc.23.2015.10.28.19.32.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 19:32:39 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org, maxim.uvarov@linaro.org Date: Wed, 28 Oct 2015 21:32:34 -0500 Message-Id: <1446085955-14366-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.4 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 1/2] linux-generic: queue: avoid race condition during order release 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" During odp_schedule_release_ordered() processing in order elements on a reorder queue should be processed even if they are marked sustain since no further elements with the current order will be enqueued. This fixes Bug https://bugs.linaro.org/show_bug.cgi?id=1824 Signed-off-by: Bill Fischofer --- platform/linux-generic/include/odp_queue_internal.h | 5 +++-- platform/linux-generic/odp_queue.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index c322e6a..6322948 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -291,7 +291,8 @@ static inline int reorder_deq(queue_entry_t *queue, static inline void reorder_complete(queue_entry_t *origin_qe, odp_buffer_hdr_t **reorder_buf_return, odp_buffer_hdr_t **placeholder_buf, - int placeholder_append) + int placeholder_append, + int order_released) { odp_buffer_hdr_t *reorder_buf = origin_qe->s.reorder_head; odp_buffer_hdr_t *next_buf; @@ -311,7 +312,7 @@ static inline void reorder_complete(queue_entry_t *origin_qe, reorder_buf = next_buf; order_release(origin_qe, 1); - } else if (reorder_buf->flags.sustain) { + } else if (!order_released && reorder_buf->flags.sustain) { reorder_buf = next_buf; } else { *reorder_buf_return = origin_qe->s.reorder_head; diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index a7022cf..a27af0b 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -478,7 +478,8 @@ int queue_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr, int sustain) * other queues, appending placeholder bufs as needed. */ UNLOCK(&queue->s.lock); - reorder_complete(origin_qe, &reorder_buf, &placeholder_buf, 1); + reorder_complete(origin_qe, &reorder_buf, &placeholder_buf, + 1, 0); UNLOCK(&origin_qe->s.lock); if (reorder_buf) @@ -844,7 +845,7 @@ int queue_pktout_enq(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr, order_release(origin_qe, release_count + placeholder_count); /* Now handle sends to other queues that are ready to go */ - reorder_complete(origin_qe, &reorder_buf, &placeholder_buf, 1); + reorder_complete(origin_qe, &reorder_buf, &placeholder_buf, 1, 0); /* We're fully done with the origin_qe at last */ UNLOCK(&origin_qe->s.lock); @@ -921,13 +922,16 @@ int release_order(queue_entry_t *origin_qe, uint64_t order, if (order <= origin_qe->s.order_out) { order_release(origin_qe, 1); - /* Check if this release allows us to unblock waiters. - * At the point of this call, the reorder list may contain - * zero or more placeholders that need to be freed, followed - * by zero or one complete reorder buffer chain. + /* Check if this release allows us to unblock waiters. At the + * point of this call, the reorder list may contain zero or + * more placeholders that need to be freed, followed by zero + * or one complete reorder buffer chain. Note that since we + * are releasing order, we know no further enqs for this order + * can occur, so ignore the sustain bit to clear out our + * element(s) on the reorder queue */ reorder_complete(origin_qe, &reorder_buf, - &placeholder_buf_hdr, 0); + &placeholder_buf_hdr, 0, 1); /* Now safe to unlock */ UNLOCK(&origin_qe->s.lock);