From patchwork Mon Aug 14 14:00:06 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: 109998 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4372489qge; Mon, 14 Aug 2017 07:01:19 -0700 (PDT) X-Received: by 10.237.35.163 with SMTP id j32mr35499801qtc.29.1502719279628; Mon, 14 Aug 2017 07:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502719279; cv=none; d=google.com; s=arc-20160816; b=AV4Y9eBeYDVdjxet8LXegUZzFVZt0JqTKdAbBtDcak72Uyj5EKzK2VaW+UZJ38EG+5 97ABx3GLttyYqaOgQCEdpP/jSGIcEeLcfJplXkB4G4Q+YZZXbBcrmZo8OKrw8Y8MDSv3 9GlQJjf0bCnSfiZ0AfZ9y2ucPYdMqpWtPiOJMx4zvcNkSs4A5ALGlyoOAt20oELiAtbA ireiTfw8CypWXAfOi46v48h/NZiZGa8B4KKehusvzymZehR2qCnJr8RvhZIMDQxyKDAG EY+uSJwkIQi9Ci5nF3T+E2DfCWr8SxaTM/jFlY0QYK+K2Z1cYWeDpEjkxNCFe1zYe1DA SMLA== 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=Ux6bH6iNgOm5yiU9QboedxzZ/zH4sf2ef6EvwPghobc=; b=IliTYDR4O4h28caVWvKjBdHhC1n1irNbJFD3J4CQcSQ6hL4TGTfd9CY3IPcFlWKifi jccTSfEJPK/9XBSR7AB60jsJ99hopuh2a908Pra9OpX7ixwY0N5iAxGZ4YsQNxL9gXeJ bnNKvJQ0uGSXwEPzrxj3LxAughK6HKHjHo1bhFVj1a4jSCKSqWCMUkr/hm7zSTKqDQpk q46LyecU1+DOF4rpFx8CYB0KgO7l2cYVHm/Pg6uU7z5Qy0LwgydlqlD+ATz0LYQrjsep y5Og2y2kcaEkvnXibFiIDXPzmg1gFR/HrN5o7gvAPMQZHkd3GsVK5JS0suw8Yxg+ZKrm fBCw== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p63si6504181qkd.296.2017.08.14.07.01.19; Mon, 14 Aug 2017 07:01:19 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 1E65260AF7; Mon, 14 Aug 2017 14:01:19 +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 B927062AE7; Mon, 14 Aug 2017 14:00:38 +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 4C93262876; Mon, 14 Aug 2017 14:00:30 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 5CE0960CB2 for ; Mon, 14 Aug 2017 14:00:24 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward100p.mail.yandex.net (Yandex) with ESMTP id E3B255102FF3 for ; Mon, 14 Aug 2017 17:00:22 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id sY1QjJ9HgF-0Mie2cp9; Mon, 14 Aug 2017 17:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id qwktrA2wo0-0L2qV0mp; Mon, 14 Aug 2017 17:00:22 +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: Mon, 14 Aug 2017 17:00:06 +0300 Message-Id: <1502719207-16204-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502719207-16204-1-git-send-email-odpbot@yandex.ru> References: <1502719207-16204-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 125 Subject: [lng-odp] [PATCH v1 1/2] linux-generic: packet: improve packet_init() performance 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 Streamline packet_init() performance by eliminating the redundant initialization of the unshared_len field of the packet hdr. This field is initialized when references are created so this processing is not required here. Signed-off-by: Bill Fischofer --- /** Email created from pull request 125 (Bill-Fischofer-Linaro:pktrefs-opt) ** https://github.com/Linaro/odp/pull/125 ** Patch: https://github.com/Linaro/odp/pull/125.patch ** Base sha: 90d4ce1b3b25ca18446131906007571cc0ed0191 ** Merge commit sha: a2b797cf85fe42d302f94c7ec24cc61959e08a4e **/ platform/linux-generic/include/odp_packet_internal.h | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index d923ee23..48c2463f 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -269,7 +269,6 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len) pkt_hdr->input = ODP_PKTIO_INVALID; /* By default packet has no references */ - pkt_hdr->unshared_len = len; pkt_hdr->ref_hdr = NULL; } From patchwork Mon Aug 14 14:00:07 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: 109999 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4373441qge; Mon, 14 Aug 2017 07:01:55 -0700 (PDT) X-Received: by 10.55.183.197 with SMTP id h188mr31989418qkf.206.1502719315253; Mon, 14 Aug 2017 07:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502719315; cv=none; d=google.com; s=arc-20160816; b=t5A/Dy+xkZqvSsrJHd39WaCtZ9Fes+Wl9jAT0vNbgEfQLOj4C4FDL4l/XVoqSbLTmu GMY5vdzPeV1SnxzYTnRYyD36nxCkanetmbkxlN7W3U9DfIOEz1sBD4P4xeN0t7pCHlOc QSDyf11MVt3a2VbBggUvs1sf+7MIneWJjzh98K/40GaqrYqkyaIFCrMbI76qlOiMxUeL E2xrNy+rD7yPcxmQL+5g1haeC3tWaEBtF3WWu661OkLONVMLxqD+SLt1LlDiuCBD7+MY B2abbaXSWixYvrhwXMOsOt8fkbbj/PiP0sAGo5bvXG7IyIR5rabiRW3zbM+gP9YqM5sk zUWA== 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=d3FUuTBhtLaGS8/PcKmPZmHIQMEFj/OMnHAI3HzBSwo=; b=dlrSha+a0mNCqzlTK8e+NjsiIPmTDuhI6VpzZcJSSD4pX5jO3aOpQ1h4nxES9uJOHT Q/Zc5B23q3grFFCig4Go0DDzX3+X+/AvrztNSZ4rRcn8e14odxw9HgcPYNE+yY4yNfsH MjZddLIOwcrfbqfDJNi3boVzDLa6GKRozaTRfNJvraBXQK3L7JDvUi+Ytks40dON7A87 20KRk57FXVkxSRvlFkClzna2qjyn1CuOmR39gNTmWPQpn1nVw3PtJmXNe4FgGxvnJQIM DLlvbzzG1yjwLGaaSCQhNfW5j/PgqY1Hjqj4OmYlSSpXIN79Bb98INhPPFnFWJALcjqa 9Ygg== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c38si6498111qtc.31.2017.08.14.07.01.54; Mon, 14 Aug 2017 07:01:55 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id D02DA64483; Mon, 14 Aug 2017 14:01:54 +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 1BEE162DA3; Mon, 14 Aug 2017 14:00:46 +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 6ACEA60CB2; Mon, 14 Aug 2017 14:00:30 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 03D3B61C9B for ; Mon, 14 Aug 2017 14:00:25 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 7E50A2A212B6 for ; Mon, 14 Aug 2017 17:00:23 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id RfVwNQzjpG-0Noqwpsl; Mon, 14 Aug 2017 17:00:23 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id qwktrA2wo0-0N2qi65N; Mon, 14 Aug 2017 17:00:23 +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: Mon, 14 Aug 2017 17:00:07 +0300 Message-Id: <1502719207-16204-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502719207-16204-1-git-send-email-odpbot@yandex.ru> References: <1502719207-16204-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 125 Subject: [lng-odp] [PATCH v1 2/2] linux-generic: packet: add branch hints for reference optimization 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 Add odp_likely() and odp_unlikely() hints on critical paths in packet allocation / free processing to optimize reference support. Signed-off-by: Bill Fischofer --- /** Email created from pull request 125 (Bill-Fischofer-Linaro:pktrefs-opt) ** https://github.com/Linaro/odp/pull/125 ** Patch: https://github.com/Linaro/odp/pull/125.patch ** Base sha: 90d4ce1b3b25ca18446131906007571cc0ed0191 ** Merge commit sha: a2b797cf85fe42d302f94c7ec24cc61959e08a4e **/ platform/linux-generic/odp_packet.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index f18bd4dd..a71a5926 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -444,13 +444,14 @@ static inline void free_bufs(odp_packet_hdr_t *pkt_hdr, int first, int num) for (i = 0, nfree = 0; i < num; i++) { odp_packet_hdr_t *hdr = pkt_hdr->buf_hdr.seg[first + i].hdr; - if (packet_ref_count(hdr) == 1 || packet_ref_dec(hdr) == 1) { + if (odp_likely(packet_ref_count(hdr) == 1 || + packet_ref_dec(hdr) == 1)) { ODP_ASSERT((packet_ref_count_set(hdr, 0), 1)); buf_hdr[nfree++] = &hdr->buf_hdr; } } - if (nfree > 0) + if (odp_likely(nfree > 0)) buffer_free_multi(buf_hdr, nfree); } @@ -468,8 +469,8 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, for (i = 0, nfree = 0; i < num; i++) { new_hdr = pkt_hdr->buf_hdr.seg[i].hdr; - if (packet_ref_count(new_hdr) == 1 || - packet_ref_dec(new_hdr) == 1) { + if (odp_likely(packet_ref_count(new_hdr) == 1 || + packet_ref_dec(new_hdr) == 1)) { ODP_ASSERT((packet_ref_count_set(new_hdr, 0), 1)); buf_hdr[nfree++] = &new_hdr->buf_hdr; @@ -492,7 +493,7 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, pkt_hdr = new_hdr; - if (nfree > 0) + if (odp_likely(nfree > 0)) buffer_free_multi(buf_hdr, nfree); } else { /* Free last 'num' bufs */ @@ -658,7 +659,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) ref_hdr = pkt_hdr->ref_hdr; /* Make sure we have enough space for this pkt's segs */ - if (nfree + num_seg > nbufs) { + if (odp_unlikely(nfree + num_seg > nbufs)) { buffer_free_multi(buf_hdr, nfree); nfree = 0; } @@ -681,7 +682,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) } while (pkt_hdr); } - if (nfree > 0) + if (odp_likely(nfree > 0)) buffer_free_multi(buf_hdr, nfree); }