Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp314946rdb; Tue, 19 Dec 2023 19:01:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFk7loR5/nhknJ4BAvzVqBkZ2MKB0/JzQJaSRA2hzbbuvPWMyIjSfAw7q4ymlylB0lS8Yhn X-Received: by 2002:a05:6870:c106:b0:1fb:75a:6d27 with SMTP id f6-20020a056870c10600b001fb075a6d27mr21258726oad.78.1703041306667; Tue, 19 Dec 2023 19:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703041306; cv=none; d=google.com; s=arc-20160816; b=XH8AV/6IB+wvC89fYf35fbN1jJ8RxbveKujXoA5SKMq5MyzoUeXbXjisc64OiB25Ko EZYMpnQxePsHNwl7TF9xQgFn78lNYYMOftZITTH9Vuol/CM7Lm8vh8v4nKlUsrQEljQi 1mptM6V2WR7jXrA+zG3JpvE01V6PVgaJbk2r5VaKZpLNcxIY3f17eIr/DGREhIuc4DEi tIfuByX/ildfU6FsdAeL06na41THdx++BPPl4J+pCT/9TqVMLXwP9xWMJoR+0VFoXCt6 uI5xAaEFs2OBJnqZBrCJWVQc/AlstbE/dConZMvEncAidsHEayGR2PveFDoU/NlmSF5x ppGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=pH2MC+JCVirOX6aXBHXvKDTSAfz8y1doyFVsXiJxsJk=; fh=OfLTHDC0vaGtIpyp3kspSuh1JNSG2zLbx1m74UejaC8=; b=vqkDu3fT61oUmInbW1OZBdNKVZ7AI+TOhfuzokQNIX9bjKLLBE9NOwB86FofFvVdLv M2IFqsuG3YipD8PZ16JJdpr/KsZHH5YcKHrjc+8Pn1J3f8yxapMCTtJknGP3blmQtF0c L3qQy55l0G8uGMDAY6FQeSHs7PxjCIchw+EWp7kuu1njh9Ypj+BhZ9PQ248+FedhWhMc mgR+MU3d5CToSFoUDT538rjbtTqwBGbvOltB/0RDvwlG6bdWd64yJKuR0+u3nxYayz2w n75cp56ceL8OxPQBoNb1dpklkwzGfeffy5Vm8n2uSBmioTZoBpyULRzYC2Jpkzj+4mj0 M4vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=p7DU9Wi+; spf=pass (google.com: domain of linux-kernel+bounces-6309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v19-20020a631513000000b005c6b0557950si20066639pgl.76.2023.12.19.19.01.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 19:01:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=p7DU9Wi+; spf=pass (google.com: domain of linux-kernel+bounces-6309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B0556282495 for ; Wed, 20 Dec 2023 03:01:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A99B8F6D; Wed, 20 Dec 2023 03:01:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p7DU9Wi+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02E838BEB for ; Wed, 20 Dec 2023 03:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a2371eae8f1so192724666b.1 for ; Tue, 19 Dec 2023 19:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703041287; x=1703646087; 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=pH2MC+JCVirOX6aXBHXvKDTSAfz8y1doyFVsXiJxsJk=; b=p7DU9Wi+ja7LZCfbmD8ln7S2AfqmXk3Y1DZtYbDRkFoe+uBmzXrXa128XRaSxb63IO AL1HsirLfnxTnJuDr9noON9nEYKvmH/cHBl/322cNWjMy+soC9kv+5oJPMCOu2lVb49w TejbBN4/F+khsFeYCv65rMGUA8ChBMIhsetl0UwZ91RxdtIPTGyfEr2CysDIEwZUHx0Q jPR1FsEjE31b03CtKqJnX9l88UN9knsrp9tlQOGP0krI3kRcix6jo9BIZu8L7wR2ml0N E3fi7jeX7jgExS6u1i1aXttuwnVUfF0emAbfGm/KL4mkurzotnUh0jRD6V5f/J7kFZjM 1y+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703041287; x=1703646087; 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=pH2MC+JCVirOX6aXBHXvKDTSAfz8y1doyFVsXiJxsJk=; b=p+6/CY0z5w7WJRZ+Tqk5neVTXMrFvqLsQ9HNhoHCpJw/a5iAiNzvX41Hab21E3nhSD DlGzVCJrX/od1bjv+vrnpTQwhfy6lLMwe/Mnw+cFgWXm/ubKzlpexsxiORrtU1E19fwT OeXIGIuXT7RGC6p99YyFg5BuODDppKKrQGruTlkgNNKWxkW7wK4gAxZa9pmaNaOJhIrH 1J4Ry5TKMY3OWPJN5RJ7gSD9TCFVpZ20M9eVr6GXRBkM5fOeEapy24CxtO3IoLbOZzG0 cRNUXg1txwrvsDwKmXDuP51ngOiHCbReJK4fpBo2K15fBvqX6CRS5+WC5LNGkMGiidd+ AACQ== X-Gm-Message-State: AOJu0YxUcCJzCJIshjftRD5xf26Wgj7Bb1+j2nY38Q6Uu9ws/2mfszCO CQ9o6roJTKGXdXMBfQeSf3ITuaIrd91Zk8MySDh5CA== X-Received: by 2002:a17:906:86:b0:a1f:a27f:d58d with SMTP id 6-20020a170906008600b00a1fa27fd58dmr7450375ejc.105.1703041286894; Tue, 19 Dec 2023 19:01:26 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231214020530.2267499-1-almasrymina@google.com> <20231214020530.2267499-5-almasrymina@google.com> <20231215021114.ipvdx2bwtxckrfdg@google.com> <20231215190126.1040fa12@kernel.org> In-Reply-To: From: Mina Almasry Date: Tue, 19 Dec 2023 19:01:14 -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: Shakeel Butt Cc: Jakub Kicinski , Yunsheng Lin , 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 , 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 , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 16, 2023 at 2:06=E2=80=AFPM Mina Almasry wrote: > > On Sat, Dec 16, 2023 at 11:47=E2=80=AFAM Shakeel Butt wrote: > > > > On Fri, Dec 15, 2023 at 7:01=E2=80=AFPM Jakub Kicinski wrote: > > > > > > On Fri, 15 Dec 2023 02:11:14 +0000 Shakeel Butt wrote: > > > > > From my POV it has to be the first one. We want to abstract the m= emory > > > > > type from the drivers as much as possible, not introduce N new me= mory > > > > > types and ask the driver to implement new code for each of them > > > > > separately. > > > > > > > > Agree with Mina's point. Let's aim to decouple memory types from > > > > drivers. > > > > > > What does "decouple" mean? Drivers should never convert netmem > > > to pages. Either a path in the driver can deal with netmem, > > > i.e. never touch the payload, or it needs pages. > > > > I'm guessing the paths in the driver that need pages will have to be > disabled for non-paged netmem, which is fine. > > One example that I ran into with GVE is that it calls page_address() > to copy small packets instead of adding them as a frag. I can add a > netmem_address() that returns page_address() for pages, and NULL for > non-pages (never passing non-pages to mm code). The driver can detect > that the netmem has no address, and disable the optimization for > non-paged netmem. > > > "Decouple" might not be the right word. What I wanted to say was to > > avoid too much specialization such that we have to have a new API for > > every new fancy thing. > > > > > > > > Perhaps we should aim to not export netmem_to_page(), > > > prevent modules from accessing it directly. > > > > +1. > I looked into this, but it turns out it's a slightly bigger change that needs some refactoring to make it work. There are few places where I believe I need to add netmem_to_page() that are exposed to the drivers via inline helpers, these are: - skb_frag_page(), which returns NULL if the netmem is not a page, but needs to do a netmem_to_page() to return the page otherwise. - The helpers inside skb_add_rx_frag(), which needs to do a netmem_to_page() to set skb->pfmemalloc. - Some of the page_pool APIs are exposed to the drivers as static inline helpers, and if I want the page_pool to use netmem internally the page_pool needs to do a netmem_to_page() in these helpers. The refactor is not an issue, but I was wondering if not exporting netmem_to_page() was worth moving the code around. I was thinking in the interim until netmem is adopted and has actual driver users we may prefer to just add a comment on the netmem_to_page() helper that says 'try not to use this directly and use the netmem helpers instead'. > This is an aggressive approach and I like it. I'll try to make it work > (should be fine). > > > -- > Thanks, > Mina -- Thanks, Mina