Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6107354rdb; Thu, 14 Dec 2023 08:28:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEn6MkP+2JMfIiM5mtIz1gCx98z/M1bav8LEv9Dk5/Q6rjaqJv4DDxOAutljqKPwWy5/zJE X-Received: by 2002:a05:6a20:29a5:b0:18f:97c:977a with SMTP id f37-20020a056a2029a500b0018f097c977amr10236459pzh.98.1702571304373; Thu, 14 Dec 2023 08:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702571304; cv=none; d=google.com; s=arc-20160816; b=ZC6AIyc85BgG4yJNBs7jTB5art1PnHkISK+a2nUK7igoiGiE82+Xm5KwpJAC6IMCIF 3Lr8ThiCKunR4hXtx/rAGXUwv+ZV1hx8VE+A/DVHM0G67cIdzTTLIVg3Y/4Pg6nEwG6+ Bq6WwK9cw4H9ti8fx9yu/AUykd4SmYbYe2I8Rm+7OP+6wFmmMahTQpwzrd/4IWAxwRga 4ctbyd6/4dMVcgVFVp8Vf8BglPlC9uEaEU6EowFTWMdd0sDYz78jgxr15l/j0+k7pyg2 y6KepMzoGOShzu+KYjXvHDlUE3Vk/azfZug01PK5/3fd5HHR3cJWtPfT1NkMXgaooZmP yJmw== 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=c1g7iy2inMi8yBenBLvW1xet6ZL1hPMy4mWA7dcVL40=; fh=u4eoc5VZSAdGL8ZX1UFuzzlQ1MZTtiF+nne2mA5Oqao=; b=UEAYvmTRd06C18K3ktgK6HDGVnhFpmNHlGWMOQJYDD1pwBQNC2C0knbrv8RgUhmB6w sSmp8v41CX6BoIzqDeFPJVlN8UhSwZPpf+oDVZRoLugtXCKTOdloYov/Y5SMFVyiYYSL utrnTxVnQtTsFAa9ZXu5AkeMwOUj3WzAUt1hswkBacsHliq8kxnt0Sn3z4iX8/MNmnPu Y9m0CuYfFEKoBB1+71n6qHrIjEHgrhtJf3lIoWh65YEW68k4Toi00WGwaEkVGCNxUOUh Gl5Y/veiZraDxQrWmLg2dza8JDPYdmb3kYmuShcnXTgX1W9g1Kuw5HAO0jLf987MDRCC NYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="s/HrImuZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p20-20020a056a000a1400b006ce442b10f3si11418646pfh.115.2023.12.14.08.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="s/HrImuZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9DBCB8032344; Thu, 14 Dec 2023 08:28:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbjLNQ2H (ORCPT + 99 others); Thu, 14 Dec 2023 11:28:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbjLNQ2F (ORCPT ); Thu, 14 Dec 2023 11:28:05 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF1911A for ; Thu, 14 Dec 2023 08:28:11 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-54c7744a93fso11502881a12.2 for ; Thu, 14 Dec 2023 08:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702571290; x=1703176090; darn=vger.kernel.org; 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=c1g7iy2inMi8yBenBLvW1xet6ZL1hPMy4mWA7dcVL40=; b=s/HrImuZdghP+VVCQlo9EQiMIkwBNW/JHoA5twbpRN2/39KE91c5BJcEa/rsHChwpJ xr67gIFUWfwNYzwAaaVfRUHxnj6Jh0KKN0cRKvJCq2DAo+UfMIpVLj5wyGPbvnup6yNs fxt3SpE+vgi0ME1ahe9l5u/KupZhopHaAd5Swno9K5+/xjnA0Bmn9kNG81ATG1Gv8DQp Ia/YV7Un34iiSqOLgSXyUXGA4YO5PEBgFHtWRHrFwwFQxJpX1yl1ZefmzJwrKB2mCqGf chYJcpV7Wn/BXnIg2AiT7jGEkMmwYf18sb62fOk/iT5jtZvF7f7c3sthb8tCZl4irFGq 1xVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702571290; x=1703176090; 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=c1g7iy2inMi8yBenBLvW1xet6ZL1hPMy4mWA7dcVL40=; b=MY2DHJy3TGpyEzcUNIPZ3q424mHC/99y+IZqUjuAuIVYZqXfgrWLpx3S9GsTbAFQln oyZmvesRZO9A4k/oC+HJBLy80XSm7BooYuSS3bYy33475Xfd9WiXWgQYQLeKCGeM+rUu 98Tam4OrRBoAg+YcP0frTjtttc8vLKswROweW4nyYNw7dPySiIbChyM7Lclnzd/NdRon GYR5+xXa/xKQMAsbuaEdKvyz2nUxkHCRS1USzFRlpltlQQzKqfyAUs/7jFSDq9AFQajm kH491jneCbSjarjkePYuCdCx9xFIycfht9KIouVfwIqk9ssczh7zmS50PV+TGYMdWuEq AvlQ== X-Gm-Message-State: AOJu0YxjuLrj1V9Ma3kcSjBVw4hGellD/R8Gif4Xh3TrRuhFmvsyeN19 +6L+eZhGGj9wF7S/6rKOd8hsSXDo9pdaj9HX6juRyg== X-Received: by 2002:a17:906:11d3:b0:a19:a1ba:8cf1 with SMTP id o19-20020a17090611d300b00a19a1ba8cf1mr4643725eja.143.1702571289527; Thu, 14 Dec 2023 08:28:09 -0800 (PST) MIME-Version: 1.0 References: <20231214020530.2267499-1-almasrymina@google.com> <20231214020530.2267499-5-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Thu, 14 Dec 2023 08:27:55 -0800 Message-ID: Subject: Re: [RFC PATCH net-next v1 4/4] net: page_pool: use netmem_t instead of struct page in API To: Yunsheng Lin Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Thomas Petazzoni , Marcin Wojtas , Russell King , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Saeed Mahameed , Leon Romanovsky , Horatiu Vultur , UNGLinuxDriver@microchip.com, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Jassi Brar , Ilias Apalodimas , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Jiawen Wu , Mengyuan Lou , Ronak Doshi , VMware PV-Drivers Reviewers , Ryder Lee , Shayne Chen , Kalle Valo , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Stefan Hajnoczi , Stefano Garzarella , Shuah Khan , =?UTF-8?B?TWlja2HDq2wgU2FsYcO8bg==?= , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jason Gunthorpe , Shakeel Butt , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Dec 2023 08:28:21 -0800 (PST) On Thu, Dec 14, 2023 at 4:05=E2=80=AFAM Yunsheng Lin wrote: > > On 2023/12/14 10:05, Mina Almasry wrote: > > ... > > > diff --git a/include/net/page_pool/types.h b/include/net/page_pool/type= s.h > > index ac286ea8ce2d..0faa5207a394 100644 > > --- a/include/net/page_pool/types.h > > +++ b/include/net/page_pool/types.h > > @@ -6,6 +6,7 @@ > > #include > > #include > > #include > > +#include > > > > #define PP_FLAG_DMA_MAP BIT(0) /* Should page_pool do the= DMA > > * map/unmap > > @@ -199,9 +200,9 @@ struct page_pool { > > } user; > > }; > > > > -struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp); > > -struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int= *offset, > > - unsigned int size, gfp_t gfp); > > +struct netmem *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp= ); > > +struct netmem *page_pool_alloc_frag(struct page_pool *pool, unsigned i= nt *offset, > > + unsigned int size, gfp_t gfp); > > Is it possible that we add a thin layer caller on top of the page_pool AP= I? > So that the existing users can still use the old API, the new user suppor= ting > the devmem can use the new API, something like below: > > struct netmem *netmem_pool_alloc(struct netmem_pool *pool, gfp_t gfp) > or > struct devmem *devmem_pool_alloc(struct devmem_pool *pool, gfp_t gfp) > Yes, it can be a thin layer on top of the page_pool API, retaining the support for the old API, so that I don't have to modify existing users. But I have to tweak it slightly, it would be something like: struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp); /* old api unchanged */ +struct netmem *page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp); /* new api added */ The new API can be implemented like this, but I don't need to add it right now, it can be added in the separate devmem series: struct netmem *page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp) { return page_to_netmem(page_pool_alloc_pages(pool, gfp); } Willem I think suggested something similar to this. Drivers can then use the old API while we implement the new API that supports different memory types. To support drivers using the old API I need to add a new skb frag helper rather than modify the existing one: + void skb_add_rx_frag_netmem(struct sk_buff *skb, int i, struct netmem *netmem, int off, + int size, unsigned int truesize) > I perfer the second one personally, as devmem means that it is not > readable from cpu. From my POV it has to be the first one. We want to abstract the memory type from the drivers as much as possible, not introduce N new memory types and ask the driver to implement new code for each of them separately. > Perhaps netmem can be used in the networking core in the future to > indicate the generic type for all types of memory supported by networking > core. > > As the main concern from Jason seems to be about safe type protection for > large driver facing API surface. And touching a lot of existing users doe= s > not seem to bring a lot of benefit when we have not a clear idea how to > proceed yet. --=20 Thanks, Mina