Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp426062rdb; Thu, 21 Dec 2023 13:23:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyOSkiSxld43zSUFPTtAugrgpsmMWbttPUc5czRaA5iE0gbzrEfIthniX5oBcnGQ93AGC/ X-Received: by 2002:a2e:2e14:0:b0:2cc:65e8:1ed1 with SMTP id u20-20020a2e2e14000000b002cc65e81ed1mr96970lju.47.1703193780687; Thu, 21 Dec 2023 13:23:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703193780; cv=none; d=google.com; s=arc-20160816; b=KVKjFExGiP/yyYkxOk2EUyip9XAXqjOEXBX+VFsvnA3vM4ou58RULkMmg8fRle7V6u 191kh+YYX6lG9n8pNR4JcvuJ+Jmg0nYW2NX8YJGFmC0nMnQ09MWwL8MFJjb4QnZM4Rus hgvnhUU2kkktAwpy9YfOaGqePKrmcdv71E3SrwU1+lazkIXwxm+0C0PzIeP/gambJHLu 1AsR+M58PLPM87/rQQXEC+azuG/H3ncnTYhgVTG7fLVYZPrusIRKwTTkd5rNfwVfz6HM sDk6mGfR+6T2PrIJIP8pDqImt94kbKF4D9HwOjNaue0dybXwXA+gyj57gTkLp3c5KA68 jUmg== 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=PYUr/8SYAD8b39z5juYQlTN6Eyhymmps+aUneiJvKeo=; fh=h0MJ5j3WihNNW6X4RNzDYMB4z6dutAQcQnJtFLy5kKg=; b=eYvVpXSgtAM9dPHlMWwvlPbB2FvRXh8ELinYg24/P5KeH4w88ECuoYZuvK1ioBuUVH cK9BIpK3TV3SHMx3fc9VIYrmUVuULUdUFkJV8HgjiuQuadrOO8l9BYr6AxblXaf3L7Da N5sccroUWngZdpB2NOZ7iLWAIMUj+hNwEzpIbFMJ+k991x1ZBwWieTqDRGyNWkwGkz6A yEvs0Mm1d73cJ1H57I9YVseiSyIJKTvlmrfSZNOopDDFeK88NPFtMHXf72DcarSq8amo 9O5/LliUqOfg9x52GpVBAsTNngWW5pK0g/+emd8GSy3g2WvuQ2aqfCxfVAybVC1stqxd mJTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FpmkzEA9; spf=pass (google.com: domain of linux-kernel+bounces-9078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v25-20020a50a459000000b005540d0739b9si1099238edb.135.2023.12.21.13.23.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 13:23:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FpmkzEA9; spf=pass (google.com: domain of linux-kernel+bounces-9078-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9078-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 441481F25B55 for ; Thu, 21 Dec 2023 21:23:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F5EE76DCC; Thu, 21 Dec 2023 21:22:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FpmkzEA9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 C1EBD76DA6 for ; Thu, 21 Dec 2023 21:22:43 +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-f49.google.com with SMTP id a640c23a62f3a-a268836254aso151374666b.1 for ; Thu, 21 Dec 2023 13:22:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703193762; x=1703798562; 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=PYUr/8SYAD8b39z5juYQlTN6Eyhymmps+aUneiJvKeo=; b=FpmkzEA9zPl1p8a8GRZ2EVpHgvpop64pjFzbvtKGeEmVSlITDOSbAwhZmGY+Z3hGQf EfbybPZAetvjfvuKXxyxYj7QxhZ2W+JsgwjTXZ2OUgijqkzKgZkp1uE+/M7m4R7/gk8n d/Y3pzKykKim3eHpFzJlY61a6YdfTYQ91lVfEvmuzRpgIiKqjkP9L6E96qpkDmLbiLOC Q2CdsYR8vd8HgotAH7t2Hu4EZvNGuI+OFtgzFGyUbGbhoVXoJyPkudIkYuf+5Fe5Mp6s SO/qasNNqy8DFA7YxARunFCUD938SijQQvF8tGqKAJvqVSpXtH2pXwDGX5HSMQNByikg S1rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703193762; x=1703798562; 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=PYUr/8SYAD8b39z5juYQlTN6Eyhymmps+aUneiJvKeo=; b=i36poon3plA4Ei1WtoZwa2nNZ+un6WyFTGscc7q0933xPaIHk5MFlxhGM9YJdA1Qy4 oqPaPFeW1ajrt51yD+/Y72ykaKd7c/uJXN6fKy5fs+s0Z94OpQHmn5mn9imeyQaPlRP1 5/x3qieesFa+suN/RWtGtepogCRas3r9d7wwZr/oxlb8EhCx1wxVoGitoUld17EKAWFy Ihir24aYCFOE6r8E1lfE+V7wK7hXk9CSqyy3nm1Jr3RLbuWDSpVnjuXFfjNd3pX4e296 SteT77kFu74E4U9FtB1gS/Kh0AEH8rY536dBLEdqbhU0AVc1Lf55mycpZP1ynNLw0OBC 1PGQ== X-Gm-Message-State: AOJu0Yx42/8CXWxelTihttZqlwlb7dtPi5aE7yJVIMl08aYghRpS98fm HYDpubCpTMnFM8o4c50LSl2dYLsjT0AupZ7IsKKTj8BEgISD X-Received: by 2002:a17:906:fb16:b0:a26:a296:2ba4 with SMTP id lz22-20020a170906fb1600b00a26a2962ba4mr241429ejb.69.1703193761749; Thu, 21 Dec 2023 13:22:41 -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> In-Reply-To: <54f226ef-df2d-9f32-fa3f-e846d6510758@huawei.com> From: Mina Almasry Date: Thu, 21 Dec 2023 13:22:27 -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 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 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. > > 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()) 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.3516870= -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_frag= ()? > Yes, v3 of this series adds skb_add_rx_frag_netmem(): https://patchwork.kernel.org/project/netdevbpf/patch/20231220214505.2303297= -4-almasrymina@google.com/ > > - 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'. > > > --=20 Thanks, Mina