Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8048359rwd; Tue, 20 Jun 2023 09:26:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rB0AkaFR6/UFyx2Y6B6LovZuoSjE3S+fuddo3OL8dAN+bGvWhz3eWhUOwtoc+3S0PGT68 X-Received: by 2002:a17:903:25cf:b0:1b0:499f:7a8d with SMTP id jc15-20020a17090325cf00b001b0499f7a8dmr7657218plb.9.1687278411851; Tue, 20 Jun 2023 09:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687278411; cv=none; d=google.com; s=arc-20160816; b=FX7vJIxxeh0DiJt8rtSWCKNvkTkNkpYJu1+0lwwKxfgxUlXsADiRPfRundho1Ref28 ij8AD+TgWlRIo8uKTGK5YQLbui/tm1zoijAj/6lGtOR8IS6ozIFYnZFs9KsZUjbGUx5e 4YyZ/HjRbxYI507UvehiFK2TATSTANL27dikYjuqvbdHNODg1BV95EFVXM+l32GRwo/F bUazAzbJ9FjZ8AEjQqB/NN/+M1ohHlcUbQspAg38fsqkzYmikN2qhX9zAc8Q7L26JFzp C1Sl2kjxB7oCGyt/ESuYeOXI9wivmEyhBwnyls/4yvvt4jeBfaHZzzeXFl9fTkbLKCk1 AZIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=qxeRKqZloEV05cBOWmo0jqMiX1LFFLYwZEnNITp6IQQ=; b=sYhHbN/yXv16t+nvgkchn9Wvonjcao/8tZXMUeIIHAeM1QgX6/CYfy/hutHehFvm5P m2pFUYAwmOIg3RP3qgrXJvssatH05cbSCkBq7PARh5IrNPmlC8+oz71nA4jQ7mp6Y2kI wfX+fMHapnj6bBnBm/vjwp6/zLW6Niy0GLk4hVsTGukRd3FtREokiztG1ErMkznpsVb/ QEixWxQGcC3lIJ4VfwR+JUvMeEBJdp6culWxTayCOIKcdPw36sYQePjMcl0L6TrY0ucY VQ6p/jwY0r14imAIaco/34JEl4wF8FiDlmnpTLLmwMwtcGKmOLX11CcSAMrQT+V83Zux ie5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RsFgKJIz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a170902d50b00b001ae4c933bd4si2327108plg.446.2023.06.20.09.26.37; Tue, 20 Jun 2023 09:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RsFgKJIz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230080AbjFTQTo (ORCPT + 99 others); Tue, 20 Jun 2023 12:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjFTQTm (ORCPT ); Tue, 20 Jun 2023 12:19:42 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB28F4; Tue, 20 Jun 2023 09:19:41 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-54fac329a71so2568340a12.1; Tue, 20 Jun 2023 09:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687277981; x=1689869981; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qxeRKqZloEV05cBOWmo0jqMiX1LFFLYwZEnNITp6IQQ=; b=RsFgKJIz6dEbL9T/u+OdGLsZkW+w40m/B5JsO6fhgVd8Yn/1tMuxVJ6zQpPxINhMPK gFG7JfjEmEmjBHumUpy3Po9LSXnI4kNZIWiOPyQ1/Jvu15UbhdVPqKHj5RrDkjpG1nnb cwRACe93rFACWTRBfEV1edY0sDgzaphWQHwZDAfNGifBJj/lvw9IUA5Py6m08fHNIar6 lBAGm64DY/42NEyYvkWH3Pjjx3XJhfsZlmvWPQSfg0NlcU7vYDkp8YYVxmTVAua8Q+BH e8VsbdTerUBY+OpFzgZocGu+gybSTMzwqLfgZyRy3WiHf11rZDy2kqN/tZIvlT8eDN/b mUcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687277981; x=1689869981; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxeRKqZloEV05cBOWmo0jqMiX1LFFLYwZEnNITp6IQQ=; b=kJ1kQMdbIEvOwMmBGUXB4fCKbwUcvxOoRMcwogwKqls39sIi/YI0ITS2dUB0wR5kU8 JsR7Ih0iWyZtm0DF3yhbzY0kafPZRhREriEDKed56J7Wk8FxUL21QEiL0/GvohdUklgZ kFEbgXYQSkN1HtxuaOCrVZdv8Mdszsmnkbt2cqs4p5ISBiFJCrRTvQhsKBMleHrYLxaN M0Rc7swto8mckIYE1rXM+oKg03bMuQO2q6btXRkAR24B0EkeRVH2J3mb3YlAPDFYc1BE LNz09pcR3ewZZc7mv2kOIl9rP14MzF6hyT+vSN9dzMnA1coMtAwIDflxvYLe7gNINnDF Vhgg== X-Gm-Message-State: AC+VfDyUrN35n29ZceXlGeQ9K5iXZ3Ht7nbPxmfJVb8Cvt9+88kJk4AR 0hOTdzAUCxgCPnG5uOrfDo2A4CTGeOlM792VZHE= X-Received: by 2002:a05:6a20:394a:b0:121:b1fc:1a48 with SMTP id r10-20020a056a20394a00b00121b1fc1a48mr5233275pzg.3.1687277980691; Tue, 20 Jun 2023 09:19:40 -0700 (PDT) MIME-Version: 1.0 References: <36366741-8df2-1137-0dd9-d498d0f770e4@huawei.com> <0ba1bf9c-2e45-cd44-60d3-66feeb3268f3@redhat.com> <699563f5-c4fa-0246-5e79-61a29e1a8db3@redhat.com> In-Reply-To: From: Alexander Duyck Date: Tue, 20 Jun 2023 09:19:03 -0700 Message-ID: Subject: Re: [PATCH net-next v3 3/4] page_pool: introduce page_pool_alloc() API To: Lorenzo Bianconi Cc: Jesper Dangaard Brouer , brouer@redhat.com, Yunsheng Lin , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jesper Dangaard Brouer , Ilias Apalodimas , Eric Dumazet , Maryam Tahhan , bpf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 18, 2023 at 8:05=E2=80=AFAM Lorenzo Bianconi wrote: > > [...] > > > > > > Yes, precisely. > > > I distinctly remember what I tried to poke you and Eric on this appro= ach > > > earlier, but I cannot find a link to that email. > > > > > > I would really appreciate, if you Alex, could give the approach in > > > veth_convert_skb_to_xdp_buff() some review, as I believe that is a hu= ge > > > potential for improvements that will lead to large performance > > > improvements. (I'm sure Maryam will be eager to help re-test performa= nce > > > for her use-cases). > > > > Well just looking at it the quick and dirty answer would be to look at > > making use of something like page_frag_cache. I won't go into details > > since it isn't too different from the frag allocator, but it is much > > simpler since it is just doing reference count hacks instead of having > > to do the extra overhead to keep the DMA mapping in place. The veth > > would then just be sitting on at most an order 3 page while it is > > waiting to fully consume it rather than waiting on a full pool of > > pages. > > Hi, > > I did some experiments using page_frag_cache/page_frag_alloc() instead of > page_pools in a simple environment I used to test XDP for veth driver. > In particular, I allocate a new buffer in veth_convert_skb_to_xdp_buff() = from > the page_frag_cache in order to copy the full skb in the new one, actuall= y > "linearizing" the packet (since we know the original skb length). > I run an iperf TCP connection over a veth pair where the > remote device runs the xdp_rxq_info sample (available in the kernel sourc= e > tree, with action XDP_PASS): > > TCP clietn -- v0 =3D=3D=3D v1 (xdp_rxq_info) -- TCP server > > net-next (page_pool): > - MTU 1500B: ~ 7.5 Gbps > - MTU 8000B: ~ 15.3 Gbps > > net-next + page_frag_alloc: > - MTU 1500B: ~ 8.4 Gbps > - MTU 8000B: ~ 14.7 Gbps > > It seems there is no a clear "win" situation here (at least in this envir= onment > and we this simple approach). Moreover: For the 1500B packets it is a win, but for 8000B it looks like there is a regression. Any idea what is causing it? > - can the linearization introduce any issue whenever we perform XDP_REDIR= ECT > into a destination device? It shouldn't. If it does it would probably point to an issue w/ the destination driver rather than an issue with the code doing this. > - can the page_frag_cache introduce more memory fragmentation (IIRC we we= re > experiencing this issue in mt76 before switching to page_pools). I think it largely depends on where the packets are ending up. I know this is the approach we are using for sockets, see skb_page_frag_refill(). If nothing else, if you took a similar approach to it you might be able to bypass the need for the page_frag_cache itself, although you would likely still end up allocating similar structures.