Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6637337rdb; Tue, 2 Jan 2024 08:14:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlEbq5klVCbWSXXILZ00t3fbakISNVW2MlukC68cnuVSexhqNQ/0YuBiY/v7Hz5/k9V810 X-Received: by 2002:a05:620a:218b:b0:781:b44a:7b0d with SMTP id g11-20020a05620a218b00b00781b44a7b0dmr5350234qka.133.1704212087969; Tue, 02 Jan 2024 08:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704212087; cv=none; d=google.com; s=arc-20160816; b=Tc26uxn2Den4+2jFOukjs2PIE7HDsjUQSiUeCWsnS0E/mFALdhxRvcs7Ta+UdtEaVM LlY0odJyoVkxggtFcEV2Mm6tnvW7XtEffz0SnsqaZbrb4MD4gEMlheHDS0hhaOCSG1gx s/1xALbl49yMmTFj9euz29k34Gu4XxriaiSnUITCCrQBGRX+vGpyV9LOHpAYLq/yZFF7 52QoaM9N+JoJnoFetvChE5kS/A5AT6sGWvVxOQXU9kqpQKL1uAss0YMYJQ1HyaKhWtIb r9dhHyr8eRmzn6Ou0bTSadm4+flUl9KbdyyuWxOVUOxLxmFXrgtTAC7+D+9GsHulBNHh bPWA== 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=hd2aplMCet1ULWImTVMnDRzK7TL9hZ+ZX0uPlm9Tbpc=; fh=h0MJ5j3WihNNW6X4RNzDYMB4z6dutAQcQnJtFLy5kKg=; b=cnRDPxmiH6J20ybExC7ozu6TU5aE9Py9gCQCZUNKr4KbY1103BUJNuYL/tO4XIz5jS 0pndiidApBy7sdqSBmOTTw3HNrEK0sSPKcti7WHK3MMb5uZUU31OhFAObF6wIPw9lBis Qb/oqeoD4AaDC4YP+QsWENYIo9dYkkkz6RDHi7BOZOWVTEVFoW2IcZkvEbsV/2MJLstS 4ut0BTddIW77rPJ7Dgy+ZRFilXzX3B/yWN+4rSfWG+gGmQ5Pku4l38WIw/0dDMB/xkty wm6bhtBDu4idBpXEE565RFO+3xIjaWHG6oUFmp0NOedx6A544T2BwHhVXklz0O0S9h2+ nqOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nsYpGk6k; spf=pass (google.com: domain of linux-kernel+bounces-14590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m21-20020a05620a24d500b0077dcab68b0csi28798398qkn.348.2024.01.02.08.14.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 08:14:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=nsYpGk6k; spf=pass (google.com: domain of linux-kernel+bounces-14590-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14590-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A72EE1C222F7 for ; Tue, 2 Jan 2024 16:14:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B41D14F7C; Tue, 2 Jan 2024 16:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nsYpGk6k" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 EFA6314F63 for ; Tue, 2 Jan 2024 16:14:31 +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-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-556996d52e5so785406a12.1 for ; Tue, 02 Jan 2024 08:14:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704212070; x=1704816870; 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=hd2aplMCet1ULWImTVMnDRzK7TL9hZ+ZX0uPlm9Tbpc=; b=nsYpGk6kupUKR1Qxd4pt+MtzmA3B1XsadgguFFYG5Nk6G6jsf/0sK0dla4la28IPYe J68Sc+IIkxrem44lkKnwnmdNtv54oCHSz3aOaOydM9a6va5CTA1yQyUoOR0fP4coORcf 9wCr9dU92Is4MmJNTvkRhNwRAWNCmcwWkBoOfYczAQjx6GnmxK4xwW779G0DNVwAj+++ IaZVzjDcjTxPfmhZJtPS1LmbdfgCD+CQoRrALapZcFfl4wTyO+QnAgdVdlUatSejh6zU In+nuSkIJBwFiSS9NYQ4k0BHLGW7PJzWhuqalMZw0OgsP9yxxJmX1z5hoNzdOMB1LI8L RLUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704212070; x=1704816870; 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=hd2aplMCet1ULWImTVMnDRzK7TL9hZ+ZX0uPlm9Tbpc=; b=amOZEH18RgaSj+OvEaqPDLP5Ki7xyj4aHG0NNsJ+mKmuFaMpKTSJBMUFV4Mn2rGXRR uhSPi+hBdW4wW9Of0e61E2GazM45OktFFgqR2cb+T3rK5Yx/m5iHinBRKtvmH9TxwHhu zEK+h2FPMuAu4uLHGkmD1zsLewqEydLEWK33QcL27plAWX/4mjtJBnX+JSAZVW8pxCwR YToDBInVehBiwo4bdLojOgmN752PeEdR+1xqf9maqtr5t/iuqqm35BuPkGqzBLjchkwe SnMceOD8iVS8M3NjL03tLu3qxbEuJE3PyrePZQjf8VwXbKBSSdQac6YzonCwckHhYPa9 TYpg== X-Gm-Message-State: AOJu0YzDKemseeQt2/dIdEIZYkolmulJDbrX9QRdRRW1JbwsOEcHKHuu 5aICYuYR8qV/PpiB8QqFEqAEDfA/5tVsdXC1k333NcyxSi/Y X-Received: by 2002:a17:906:6a18:b0:a27:4725:6e4f with SMTP id qw24-20020a1709066a1800b00a2747256e4fmr6049949ejc.144.1704212069959; Tue, 02 Jan 2024 08:14:29 -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> <54f226ef-df2d-9f32-fa3f-e846d6510758@huawei.com> <7c6d35e3-165f-5883-1c1b-fce82c976028@huawei.com> In-Reply-To: <7c6d35e3-165f-5883-1c1b-fce82c976028@huawei.com> From: Mina Almasry Date: Tue, 2 Jan 2024 08:14:17 -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: Shakeel Butt , Jakub Kicinski , 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 Thu, Dec 21, 2023 at 10:42=E2=80=AFPM Yunsheng Lin wrote: > > On 2023/12/22 5:22, Mina Almasry wrote: > > On Thu, Dec 21, 2023 at 3:32=E2=80=AFAM Yunsheng Lin wrote: > >> > >> On 2023/12/20 11:01, Mina Almasry wrote: > >> > >> ... > >> > >>>>>> 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 th= e > >>> drivers via inline helpers, these are: > >>> > >>> - skb_frag_page(), which returns NULL if the netmem is not a page, bu= t > >>> needs to do a netmem_to_page() to return the page otherwise. > >> > >> Is it possible to introduce something like skb_frag_netmem() for > >> netmem? so that we can keep most existing users of skb_frag_page() > >> unchanged and avoid adding additional checking overhead for existing > >> users. > >> > > > > In my experience most current skb_frag_page() users need specifically > > the struct page*. Example is illegal_highdma() which > > PageHighMem(skb_frag_page()) > > For illegal_highdma() case, is it possible to use something like > skb_readabe_frag() checking to avoid calling skb_frag_page() for netmem? > Not teh skb_readable_frag() check I think, because illegal_highdma() is not trying to read the SKB per se. But I agree with your general point, and that should be handled correctly in this patch which adds devmem support: https://patchwork.kernel.org/project/netdevbpf/patch/20231218024024.3516870= -10-almasrymina@google.com/ The idea being that skb_frag_page() can return NULL if the frag is not paged, and the relevant callers are modified to handle that. > > > > But RFC v5 adds skb_frag_netmem() for callsites that want a netmem and > > don't care about specifically a page: > > > > https://patchwork.kernel.org/project/netdevbpf/patch/20231218024024.351= 6870-10-almasrymina@google.com/ > > > >>> - The helpers inside skb_add_rx_frag(), which needs to do a > >>> netmem_to_page() to set skb->pfmemalloc. > >> > >> Similar as above, perhaps introduce something like skb_add_rx_netmem_f= rag()? > >> > > > > Yes, v3 of this series adds skb_add_rx_frag_netmem(): > > > > https://patchwork.kernel.org/project/netdevbpf/patch/20231220214505.230= 3297-4-almasrymina@google.com/ --=20 Thanks, Mina