From patchwork Sat Oct 14 15:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 115841 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1866123qgn; Sat, 14 Oct 2017 08:01:16 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R2PPJkKhVxEDrGdkT2Q/OCF2RWxXESa8TU4ZIsN12C24ILqWl/A9Un/A0UsVvqr+2n78IM X-Received: by 10.107.9.203 with SMTP id 72mr6387977ioj.292.1507993276667; Sat, 14 Oct 2017 08:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507993276; cv=none; d=google.com; s=arc-20160816; b=KYeYO661JuLmCk3LP2acGZ+F8npqvc1P6MsZhNfFAww+54JAbQjgmrbwaBU9TGutmP htx/GWhDbqFoK3t9JmMNdX/a4GdJEj+cHGGpr7z8sxh7Es3Ih1yTjuMziaVN0ZOBLk5d 0cI1a4sm2Rt2/iTnTBj9MB0WJb/FAzaRl353pUGjhgrNPcFcW+Ei4QcCY4iCKT8oAckC HHjWqjeWC1Omcg1WHeQKmyrJ2xdf2KFl6Nb2ZPvxvymUIzFNIyams9s/zPrjrw6EmX3n xa29rC6kFsh6ir+jarWLhI0O6Vs9DijBQaz5BrM3sKWmBvOdNxQUMn+wPkWIXWhEr0x4 ubIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=ageUAuyvc0+M0+0NbXaBaPXf6jomFV5V8x4hTJitxts=; b=a09BcVEkBo0eqBL7hhy0yrYuNgk3YUQsTU3MHmb/ZZPC7YyV0Q7MfiWWwjyJLX00+k TPmqTxVTlHit12A7W8lnjuOLSabVnmIarjO5+WFQLx3Mt/5q/fA5QPKgYmzUs5soExeC EsEB5Us53WfHyHn9okJEF3AryA+aHKxiQj7ChshwhNDbyMAUp5vPSQ6el4KneyQdDDSh IIa9zCS0/PY5PUaro5fY0dj5+3/isJWdEV6PO6pGh3kEMWOn5cBEkzQ2UjQySLKRsZQj sxIq0uC3Ovc1nm9/527XGY7/qGY7cLBBuZcztDM6ZlAZwjpuNeXDU5TPbBJqFX0JLamd Bxmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id v15si2509820ioi.41.2017.10.14.08.01.08; Sat, 14 Oct 2017 08:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4D5DB60724; Sat, 14 Oct 2017 15:01:08 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 79F3E606B4; Sat, 14 Oct 2017 15:01:03 +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 E6D5360647; Sat, 14 Oct 2017 15:01:00 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 7641260647 for ; Sat, 14 Oct 2017 15:00:59 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward102j.mail.yandex.net (Yandex) with ESMTP id D63265602770 for ; Sat, 14 Oct 2017 18:00:57 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DpYy2ndYvX-0vnK6dgb; Sat, 14 Oct 2017 18:00:57 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id FjKubIKaLI-0vvuVBYc; Sat, 14 Oct 2017 18:00:57 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 14 Oct 2017 18:00:09 +0300 Message-Id: <1507993210-15088-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507993210-15088-1-git-send-email-odpbot@yandex.ru> References: <1507993210-15088-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 180 Subject: [lng-odp] [PATCH v5 1/2] linux-generic: packet: correct syntax issue 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bill Fischofer Not sure how this got by checkpatch originally, but clean up syntax associated with this code. Signed-off-by: Bill Fischofer --- /** Email created from pull request 180 (Bill-Fischofer-Linaro:pkt-debug) ** https://github.com/Linaro/odp/pull/180 ** Patch: https://github.com/Linaro/odp/pull/180.patch ** Base sha: ae4f1d82ed704992c1d8284c23795b9e076b33b9 ** Merge commit sha: 75ccc68f61089fffbf834b8dacd952c887b70ff8 **/ platform/linux-generic/odp_packet.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index f4a0e0ec9..a3fd0559f 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -389,10 +389,8 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr->buf_hdr.next_seg = NULL; hdr->buf_hdr.last_seg = &hdr->buf_hdr; - if (odp_unlikely(num > 1)) { + if (odp_unlikely(num > 1)) link_segments(pkt_hdr, num); - - } } } From patchwork Sat Oct 14 15:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 115842 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1866621qgn; Sat, 14 Oct 2017 08:01:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Ss8XVg8osfwfALuhKi+EbwflkabuHwEBoq7ONtAqSaRyEvzInFHdJn12Wp1GofKeCykZ/T X-Received: by 10.107.27.137 with SMTP id b131mr6036985iob.2.1507993298011; Sat, 14 Oct 2017 08:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507993298; cv=none; d=google.com; s=arc-20160816; b=ZGBb+qcdVFGancjzQD4M2TCy+esmBvqSm/Q/FQ4xGoQxAuYsUzXBdVR8VmEcwJkEeX L+MkTvBkWvItPd0UfNoFtUPLrfC/w+/ts0LNK4KzFpc5SYioHFx4eHjcQGZbVbw0BSIx 07lgJt9Kn2oZJ0q4DCi31mbeYehyaychSAU7IYgFSfQUqf+mN+tGPBXpC5lMnliKSVyM 3XXnzG/Id+YVGeUeJpx8sYExndudgRW5CowNL2V1FCyUkRvFnr1rWdOaHD+kcSJBregP AouTayPKLh726rpT12GVKLssl/H0ZEIN/8dc6Ku5W5pQFgBntb0N/hedTV4x6tvLLvHg Giyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=cu/uij5WuLHeqHTISQwZi5u4fYyutTm+OaBiI2wPyi8=; b=0t6R9tw2lWfSdfdcGq/HABxegtQ8Zyl6PqpHOaEBJGQ/BmuzK3Rp5n53qk18Dfwn5R FhVDHCMusY5iU3moNpyOkIXHd/6tPwqUR3DmT5+EY4oBlv9yiCu3Y6PfpVTj3mj1Npfw HZAL+2EI4nYPhe1isHqRcNpy95Xq5Arr3sw/Or4uNyRJ8Qz2RpOCT2v/srWSiSvxbDmV 88e7BQNYqJlOKUXOqw0AZ5Mo8ofk5V+Z+pP0eOmaygnNaxjtcv1wZk1t7XB9svastdDc 7sbO+fpHaYnKpQamhN5mtsKfS7gyibuQPAkknfDBmfWh7KY3gVCmvcZT/U3LjXqx/83r CroA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id c28si2479547ioj.48.2017.10.14.08.01.36; Sat, 14 Oct 2017 08:01:37 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5334360718; Sat, 14 Oct 2017 15:01:36 +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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 0B1D2606B3; Sat, 14 Oct 2017 15:01:07 +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 5BBA3606B5; Sat, 14 Oct 2017 15:01:01 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id DA35D606B3 for ; Sat, 14 Oct 2017 15:00:59 +0000 (UTC) Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 665FE2A21CC5 for ; Sat, 14 Oct 2017 18:00:58 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OuFUkETU3h-0wduT92p; Sat, 14 Oct 2017 18:00:58 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id FjKubIKaLI-0vvWZFmx; Sat, 14 Oct 2017 18:00:57 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 14 Oct 2017 18:00:10 +0300 Message-Id: <1507993210-15088-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507993210-15088-1-git-send-email-odpbot@yandex.ru> References: <1507993210-15088-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 180 Subject: [lng-odp] [PATCH v5 2/2] linux-generic: packet: add debugging asserts in packet code 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bill Fischofer Restore the ODP_ASSERTS() that assist application debugging that were lost in the recent packet reference rework. When using --enable-debug insert guards to detect duplicate packet frees as well as attempts to modify known shared data sections of packet references. Signed-off-by: Bill Fischofer --- /** Email created from pull request 180 (Bill-Fischofer-Linaro:pkt-debug) ** https://github.com/Linaro/odp/pull/180 ** Patch: https://github.com/Linaro/odp/pull/180.patch ** Base sha: ae4f1d82ed704992c1d8284c23795b9e076b33b9 ** Merge commit sha: 75ccc68f61089fffbf834b8dacd952c887b70ff8 **/ platform/linux-generic/odp_packet.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 012c9318e..744ee9a34 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -354,6 +354,10 @@ static inline void link_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr->buf_hdr.seg[i].hdr = buf_hdr; hdr->buf_hdr.seg[i].data = buf_hdr->base_data; hdr->buf_hdr.seg[i].len = BASE_LEN; + + ODP_ASSERT(0 == cur || /* init_segments() does this */ + 0 == odp_atomic_fetch_inc_u32( + &pkt_hdr[cur]->buf_hdr.ref_cnt)); cur++; if (cur == num) { @@ -389,6 +393,9 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr->buf_hdr.next_seg = NULL; hdr->buf_hdr.last_seg = &hdr->buf_hdr; + ODP_ASSERT( + odp_atomic_fetch_inc_u32(&hdr->buf_hdr.ref_cnt) == 0); + if (odp_unlikely(num > 1)) link_segments(pkt_hdr, num); } @@ -848,6 +855,8 @@ void odp_packet_free(odp_packet_t pkt) odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); int num_seg = pkt_hdr->buf_hdr.segcount; + ODP_ASSERT(buffer_ref(&pkt_hdr->buf_hdr) > 0); + if (odp_likely(CONFIG_PACKET_MAX_SEGS == 1 || num_seg == 1)) { odp_buffer_hdr_t *buf_hdr[2]; int num = 1; @@ -877,6 +886,8 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt[i]); int num_seg = pkt_hdr->buf_hdr.segcount; + ODP_ASSERT(buffer_ref(&pkt_hdr->buf_hdr) > 0); + if (odp_unlikely(num_seg > 1)) { free_all_segments(pkt_hdr, num_seg); num_freed++; @@ -1057,6 +1068,8 @@ void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) if (len > pkt_hdr->tailroom) return NULL; + ODP_ASSERT(odp_packet_has_ref(pkt) == 0); + old_tail = packet_tail(pkt_hdr); push_tail(pkt_hdr, len); @@ -1072,6 +1085,8 @@ int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, uint32_t tail_off = frame_len; int ret = 0; + ODP_ASSERT(odp_packet_has_ref(*pkt) == 0); + if (len > tailroom) { pool_t *pool = pkt_hdr->buf_hdr.pool_ptr; int num; @@ -1104,6 +1119,8 @@ void *odp_packet_pull_tail(odp_packet_t pkt, uint32_t len) odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); seg_entry_t *last_seg = seg_entry_last(pkt_hdr); + ODP_ASSERT(odp_packet_has_ref(pkt) == 0); + if (len > last_seg->len) return NULL; @@ -1123,6 +1140,8 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t len, if (len > pkt_hdr->frame_len) return -1; + ODP_ASSERT(odp_packet_has_ref(*pkt) == 0); + last = packet_last_seg(pkt_hdr); last_seg = seg_entry_last(pkt_hdr); seg_len = last_seg->len; @@ -1386,6 +1405,8 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, if (align > ODP_CACHE_LINE_SIZE) return -1; + ODP_ASSERT(odp_packet_has_ref(*pkt) == 0); + if (seglen >= len) { misalign = align <= 1 ? 0 : ROUNDUP_ALIGN(uaddr, align) - uaddr; @@ -1423,6 +1444,8 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) uint32_t dst_len = dst_hdr->frame_len; uint32_t src_len = src_hdr->frame_len; + ODP_ASSERT(odp_packet_has_ref(*dst) == 0); + /* Do a copy if packets are from different pools. */ if (odp_unlikely(dst_pool != src_pool)) { if (odp_packet_extend_tail(dst, src_len, NULL, NULL) >= 0) { @@ -1453,6 +1476,8 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail) if (len >= pktlen || tail == NULL) return -1; + ODP_ASSERT(odp_packet_has_ref(*pkt) == 0); + *tail = odp_packet_copy_part(*pkt, len, pktlen - len, odp_packet_pool(*pkt));