From patchwork Mon Aug 14 22:00:04 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: 110067 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4897839qge; Mon, 14 Aug 2017 15:01:30 -0700 (PDT) X-Received: by 10.200.3.45 with SMTP id q45mr33197114qtg.3.1502748090211; Mon, 14 Aug 2017 15:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502748090; cv=none; d=google.com; s=arc-20160816; b=p+RcsJkthbnHuj8slLxo8zD46yr26t5tk3wVZj2JAVDD9vt3BP5EsCbxqVCbqd7mhQ ozUXPcOPXk48kfo5xJNUiJHaCG7dDE79ysYxVpk4QjjQHOV7NtzLntbeELLoUhM2KyXL hQp8eumEg5FIOxa6GFeCw499PIk0paGusfWtW8JoHVJ1Auo4X8WMKNVOiiwgyvmpc3yq uHdmIreFxTtA5lEShhYdHSDA+qiwjsMbFCaglYKtcS/sfpZtP5nj3iniRlWbDbbxJEz5 O/G2feiVNJxQ3BEUeZn1NqpGK1dn6/IN5/rye3vKyYk7e9sAR4SW9PBAnf6eFFLatATU 5DPg== 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=uNaNQ4ZiwqaJLrk40NKUfaEo4uHrccHDpt4waDT3wnM=; b=cUpypwdhQutL2brzlmCAxxMQSwFouxtXHWH1RQlDJLSDRw+60lgOEMxxTkxqZ3cQHn aMm1VgtC9WgkgAdN0LdJFZADH4kurdiuaVJj6Y3LpCyCmYiLZoYAW7LSgtBFiUdjzJlS 8T1zA5ssV4t+4R0X7GmR4AVzCt7vKX3cUW+ZCxApTRCnC1OWBHNo6BUUpd9XkFlTRp1+ gWmKbnbLYBmgkWfVrkqKiFzlEDUNfjxZOfKHUw7t9qzBH/zSeAYoS3ywMZFrnba2kB11 9f3Hgm2HvtOLfotOcf79dez+RUHL9kXo5HvZRyqqjD7eABQ3St3rNilqauq0wuuTORrb 2A6A== 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 s6si7310466qkc.26.2017.08.14.15.01.29; Mon, 14 Aug 2017 15:01:30 -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 C7E906286D; Mon, 14 Aug 2017 22:01:29 +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, 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 18B2765BE9; Mon, 14 Aug 2017 22:00:34 +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 B266F644DA; Mon, 14 Aug 2017 22:00:25 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id EAACE644D8 for ; Mon, 14 Aug 2017 22:00:23 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 48C23183436 for ; Tue, 15 Aug 2017 01:00:22 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id jl6dwcSK50-0MRmX6V1; Tue, 15 Aug 2017 01:00:22 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Ilh82pUDMK-0LF4Xdwr; Tue, 15 Aug 2017 01:00:21 +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: Tue, 15 Aug 2017 01:00:04 +0300 Message-Id: <1502748005-17591-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502748005-17591-1-git-send-email-odpbot@yandex.ru> References: <1502748005-17591-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 125 Subject: [lng-odp] [PATCH v2 2/3] 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: 6d464aeb30e24833ae787e3997a411103c16c70c **/ 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); }