From patchwork Thu Feb 16 16:52:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 94099 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2592233qgi; Thu, 16 Feb 2017 08:52:28 -0800 (PST) X-Received: by 10.200.47.217 with SMTP id m25mr3386797qta.283.1487263948555; Thu, 16 Feb 2017 08:52:28 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v34si5606292qtv.218.2017.02.16.08.52.27; Thu, 16 Feb 2017 08:52:28 -0800 (PST) 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DBFAD635AB; Thu, 16 Feb 2017 16:52:27 +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, RCVD_IN_DNSWL_NONE, 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 E84F560C1B; Thu, 16 Feb 2017 16:52:23 +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 A858C60C4C; Thu, 16 Feb 2017 16:52:22 +0000 (UTC) Received: from mail-ot0-f174.google.com (mail-ot0-f174.google.com [74.125.82.174]) by lists.linaro.org (Postfix) with ESMTPS id ACC2960BEE for ; Thu, 16 Feb 2017 16:52:21 +0000 (UTC) Received: by mail-ot0-f174.google.com with SMTP id 45so14932658otd.2 for ; Thu, 16 Feb 2017 08:52:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oCod+YVKx8DUxcz2ekhso2hvaIS+jG7vhwLZ6gnkLPs=; b=hx2IkH+vf7GXsZjzFZxe9PE6TZMFlo9tzncDrm5DjiV2cLlJviybWFzb56+U2L3WQ1 muOnDeL7VV1Vl79IFUeveIwQI6mlMOu7KBF5GLjYGFLvRxW2Dp9H0XAtI8BVSy8E2WKT Kljydsls3Rw+E4A0i7U89c6gFxpvDxpbjHVj9z8taVfgnMMexE3ZxSGwU/s/U0ZDb7Fj NYLQmpv3+zHhdAM8G5PSI6dBzlk3Yf6WzH8vuVzLQrZ0MzHX+lvqjNSfJMEZD5TFkkLA q/VgCbszxjhJT4OH33elm33/wA7+JBxg6gb5Bzi7ssZipJs6WDPluOMNS9RRA6HccOol lkeQ== X-Gm-Message-State: AMke39mKgbhhLJ3OERMO1KAaCUU72+lmhrAECV3XtcWpOTwlICX+/o0ETMArb1gKi/NroRmLBFY= X-Received: by 10.157.21.72 with SMTP id z8mr1936936otz.131.1487263940945; Thu, 16 Feb 2017 08:52:20 -0800 (PST) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id v14sm3217600otv.0.2017.02.16.08.52.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 08:52:20 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 16 Feb 2017 10:52:16 -0600 Message-Id: <20170216165216.10951-1-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.12.0.rc1 Subject: [lng-odp] [API-NEXT PATCH] linux-generic: packet: improve packet init efficiency 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" Atomic operations are relatively expensive because they involve implicit memory synchronizations and pipeline flushes. During packet_init() processing we know that there are no other references to this packet, so avoid this overhead via a controlled breach of the atomic type to set the initial reference count directly. Signed-off-by: Bill Fischofer --- platform/linux-generic/include/odp_packet_internal.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.12.0.rc1 diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 2db042e0..593f30dd 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -262,7 +262,12 @@ static inline uint32_t packet_ref_count(odp_packet_hdr_t *pkt_hdr) static inline void packet_ref_count_set(odp_packet_hdr_t *pkt_hdr, uint32_t n) { - odp_atomic_init_u32(&pkt_hdr->ref_count, n); + /* Only used during init when there are no other possible + * references to this pkt, so avoid the "atomic" overhead by + * a controlled breach of the atomic type here. This saves + * over 10% of the pathlength in routines like packet_alloc(). + */ + pkt_hdr->ref_count.v = n; } static inline void packet_set_len(odp_packet_hdr_t *pkt_hdr, uint32_t len)