Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4741515pxf; Tue, 30 Mar 2021 16:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEfeQlME2GXnh51NU4Ev/KH2Zx3PAirBSepXjFV8B0vYwbMvFc23sq4uFLQtBxn1ZVoc/S X-Received: by 2002:a17:906:405b:: with SMTP id y27mr576413ejj.332.1617146271170; Tue, 30 Mar 2021 16:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617146271; cv=none; d=google.com; s=arc-20160816; b=Y/Udybu0ZbTbVA0+gZsBAjuIUphQ0LRFM+Aj1M5yoamvoQ+dA35n7Asq2lBO+Mde6I zGpWrTXvAfXkCasD2p2NAQ3wI+7M9AgFXTwCYt9JXIQ3chDB/14G2dyk9dBKvKg/L64i E8bKnM3zi2zMyv4AhsPnQZT2nwZ9ue58h6084cmqQnIkqpzohncy5HM8cF5yD9hap23N kxAK1BC+XM+lliqAS60J1+Dw0N6D1IH/kqwUyL9sWO/RPb34mzJDVXkl5j6/eX6xuuSW sw8QjjbCssDVTPGXjr55nsRCE8lQrk5QqhfwjJ7vV11VD0W+Q38/LmXk+iXlVus/v28q KiuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=zI3QaYD0UyhErTHzJ9xtVjlAtErv7jv4T3mrzGJ1yG8=; b=t98PCIxg4vgJLTxQCcxbWoVPAFxlz8CDEmJT5GIqCZVE8mPBaHFghkmCuemRUCxSuE 9bId31BDwOSsiud4qG4C6ugmm/FITUs9vC5ICf7amV30YpCzx7kqTWnbSFIP5syVt/1z 9Apusz8kPxZnMCmLnmtyjF4SRCePq0x3yyckZLyD/G8gYOpDnOtEFIk1vRTQFc+EGNTu ZJ41JBl8P4Kr9AVsLwVyBe6pJ1VHle7Y+W522XnAGVelN9OQUlZcaujzlZeUIUgZElJi euO+HLTEyTjtYyYJ/P6uoh/fK9YwSRs9jRt8w39lkAd//8voU1lRXkNn27v6H7IlwiZZ foYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=hEEInPeZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb23si195956ejb.496.2021.03.30.16.17.28; Tue, 30 Mar 2021 16:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=hEEInPeZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233096AbhC3XQ0 (ORCPT + 99 others); Tue, 30 Mar 2021 19:16:26 -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?Q?Bj=C3=B6rn_T=C3=B6pel?= , 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) 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, =09=09=09return ERR_PTR(err); =09=09skb_reserve(skb, hr); -=09=09skb_put(skb, len); =09=09buffer =3D xsk_buff_raw_get_data(xs->pool, desc->addr); -=09=09err =3D skb_store_bits(skb, 0, buffer, len); -=09=09if (unlikely(err)) { -=09=09=09kfree_skb(skb); -=09=09=09return ERR_PTR(err); -=09=09} +=09=09memcpy(__skb_put(skb, len), buffer, ALIGN(len, sizeof(long))); =09} =09skb->dev =3D dev; -- 2.31.1