From patchwork Tue Mar 30 23:15:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12174001 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A45C433DB for ; Tue, 30 Mar 2021 23:16:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDF2261996 for ; Tue, 30 Mar 2021 23:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbhC3XQX (ORCPT ); Tue, 30 Mar 2021 19:16:23 -0400 Received: from mail-40131.protonmail.ch ([185.70.40.131]:44226 "EHLO mail-40131.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233112AbhC3XP4 (ORCPT ); Tue, 30 Mar 2021 19:15:56 -0400 Date: Tue, 30 Mar 2021 23:15:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1617146154; bh=zI3QaYD0UyhErTHzJ9xtVjlAtErv7jv4T3mrzGJ1yG8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=hEEInPeZfS46I+eb+l/P+YSFbDIzaO/vmhqGZlKOcsx8ZXI59qVkIwcLof96mmSEE Pi/OjqUIiEyOOoaVLP/qObbLVQvol/hYXquNhPoAWC0gE13BHJx/aSjzHcxy3sF5+o guQh8oCRq799d3V4msfSNjPxeNO2as4vvzS/Klfl7vT74QcmUEJKSLJutw4BTLFYKo 0XQFvm54I970bpX3IAdhVlMJJ94xvNlFjLUtnPI938QbjO3wiJ59v+NBrxRUkDhuon Nldxte0uOVBTO6WOv53ZQvOIzOHEjN2A7+6gfxwKOCaOV3zjnbNLc267XDih9j9XLu LeekmPefi9jmA== To: Alexei Starovoitov , Daniel Borkmann From: Alexander Lobakin Cc: Xuan Zhuo , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Alexander Lobakin , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH bpf-next 1/2] xsk: speed-up generic full-copy xmit Message-ID: <20210330231528.546284-2-alobakin@pm.me> In-Reply-To: <20210330231528.546284-1-alobakin@pm.me> References: <20210330231528.546284-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net There are a few moments that are known for sure at the moment of copying: - allocated skb is fully linear; - its linear space is long enough to hold the full buffer data. So, the out-of-line skb_put(), skb_store_bits() and the check for a retcode can be replaced with plain memcpy(__skb_put()) with no loss. Also align memcpy()'s len to sizeof(long) to improve its performance. Signed-off-by: Alexander Lobakin --- net/xdp/xsk.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) -- 2.31.1 diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index a71ed664da0a..41f8f21b3348 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -517,14 +517,9 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs, return ERR_PTR(err); skb_reserve(skb, hr); - skb_put(skb, len); buffer = xsk_buff_raw_get_data(xs->pool, desc->addr); - err = skb_store_bits(skb, 0, buffer, len); - if (unlikely(err)) { - kfree_skb(skb); - return ERR_PTR(err); - } + memcpy(__skb_put(skb, len), buffer, ALIGN(len, sizeof(long))); } skb->dev = dev;