Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp365485pxf; Wed, 31 Mar 2021 05:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYye2aEwz81RhdU5QrGPZCS6s4X1VcgNWFbLIJi6Uha8z2QGr03YmUrONx0dsLwZdVzr0p X-Received: by 2002:a17:906:aada:: with SMTP id kt26mr3174753ejb.137.1617193856578; Wed, 31 Mar 2021 05:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617193856; cv=none; d=google.com; s=arc-20160816; b=QYwSnCyJgMRxUt+7pL0rQkSvOImht6vkJ/03qWBVuq36PNALAtVd9dDMaUW2vGgpg9 ar4k7Ux4iwE/NHVnqdC9CpgG61fCqR2C9/k6KqF/3TRZ0OikXt+pemauzlJ0eBg/5Vnm 1fr8sPJARPg428sx5pBxJWoOCKpFUCp2psR2gnitQD3lRelHU6g6i67IhruPv2HR/QVg ICFYmJOnHlURKMVOw/r+X092Ztf5TixAKiE/5GrljjAd84phdAwnI/1T6qmt87Yc/RTM G+oMm5dnI1nRlXfTsd7NMqtifApwJzaOVL1WXtY0UBcRKOjQX4eaZvMpqOagalJbDXvy IvnA== 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=nHxlih6HcipAfANzxHjjUQPmqNRmwOKHx/tTRooft/SEzz12ExJ2hoIE89uA8ZPKye i/TnIjJw5t80t3b8UdXChBjj8GN2F+CQQM52VcPa21bh7f7/t14HRW+KkuOCpd1W6a1J 54leqyNnaz4CKji3Og0EmsBzX3GJCBBivfyfYsT/ZFzCoSM6kDATXKEbp/cCvdzXScJB ZhegTYxLRAWANR1LnshbLhNkERqxNUEehjQR0Bji5djAOlm1+dlCaDtZIUBmse63H66p ThBRaEYzUMAoAGDQ+eseryGheirEURLEyifmgvsRtZmphU+f2ongASb2OKOrbk7DALZz RLVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail header.b=c84tXW1g; 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 c8si1710025edq.326.2021.03.31.05.30.33; Wed, 31 Mar 2021 05:30:56 -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=c84tXW1g; 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 S235584AbhCaM3X (ORCPT + 99 others); Wed, 31 Mar 2021 08:29:23 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:27629 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235724AbhCaM2l (ORCPT ); Wed, 31 Mar 2021 08:28:41 -0400 Date: Wed, 31 Mar 2021 12:28:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1617193719; bh=zI3QaYD0UyhErTHzJ9xtVjlAtErv7jv4T3mrzGJ1yG8=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=c84tXW1g3EszL3GXgeXUMymQ0g5Zg9NaGGhLaxp3OI1aGtitirwU50pNTmtC57J7F 8uyuZz4xQtRNHkpA5LDrPLYxlLcv6acHSbabi7lczADJ9VQffjOgPXX6TvuboORA6x ZFYAEh2IyrGDfs0Zk3oCLPkJimyPwpbv1YleOMgfhCmWQCTYXsSioWuJrFNcAlmwQR sjGSswH3MvgbPsH/nvBnc6w3DJxSMwAWxBDrs3pKTQuYBCoia2Re0sd9zYQ4gl41Mu IiVqf9FqLY5Wccqd9NpuGzHkhjzEuyZYn5Q3Hyni2Wprffnt5Stg20RNv0jNk2Zm2v YygrVsSlVR4ZA== 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 v2 bpf-next 1/2] xsk: speed-up generic full-copy xmit Message-ID: <20210331122820.6356-1-alobakin@pm.me> In-Reply-To: <20210331122602.6000-1-alobakin@pm.me> References: <20210331122602.6000-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