Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7293131rdb; Wed, 3 Jan 2024 10:39:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaWuYHVnbTj2hY477+hUUZOqj9Yh7TBBHcL4CpZIk91CdVItYS4GU98mB9suZ6gk9DJIEg X-Received: by 2002:aa7:ce1a:0:b0:556:9b0a:80d0 with SMTP id d26-20020aa7ce1a000000b005569b0a80d0mr1425330edv.11.1704307157671; Wed, 03 Jan 2024 10:39:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704307157; cv=none; d=google.com; s=arc-20160816; b=Vz39KzgQx+QYogkNwbkK+BPvUT+2HHz+vGxqg/SsI1N9jjpBZOzDT9aubpJxNPKoYQ LAyZe40IQEjLkF3qL+hNA8hr8oWIYv3vkLrtROQMzWomQi4o8bUGVDG8bHv24rmRSauI DiOG+hDxV9v0tJa/YJWR9M+gfBLslt3STWcA0ihJ/5JB5uZlXf8RzMaDzjKbj5tou4AO frpnjuJffuzug//RN6rM6qPCnD43PnezuUOThlisP2KZbi27ZJzFhDdBbVrWpxr5Yyvq 5i4aoTAgyz8c7m5eIbsx5kokRO3n+BC8DN40nKMp4vLG83J/JLlTjk+U909Rb6AfQ1ko kffw== 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=lYrCXAnsOH5ti259ZxbWJxLR6syqU5rDe0tyxmeWWuA=; fh=h0MJ5j3WihNNW6X4RNzDYMB4z6dutAQcQnJtFLy5kKg=; b=pQsJMGWlldabvCoYl46zbP8aHBcEWe+b6ZojTxC+lAqzI0nB7ZoSBcTMMhwd63j0Zy tbfWNUA9izccb/muE5HVI5NCZPpsExn4JLyjv1W/8uo3NWZnKaVvgPtqLBqxOFGA5NAP fKxT07OTqf8eo7RgerpXhq+1VEj+NxkHvPqgT/k/RJ9Qz6rpoUT0X20L3+Vl/3hq/Krb O0pK8/o7BsZGs+sUa2I9j6bij9wsTwuZp5mAHxZtUuplAHbmNR1TFGkFlFtLo7qTNccj ezUqf7h6soccaEIWJF9L08h043L65DgXiVPbQB+wpxKwILjSkLwhmgMw9GAm94uwld8+ 5HAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ps9cD3Dx; spf=pass (google.com: domain of linux-kernel+bounces-15876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15876-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. [147.75.80.249]) by mx.google.com with ESMTPS id 17-20020a508e11000000b0055400e1f047si12336523edw.311.2024.01.03.10.39.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 10:39:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ps9cD3Dx; spf=pass (google.com: domain of linux-kernel+bounces-15876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15876-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 422761F233CA for ; Wed, 3 Jan 2024 18:39:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62A811CA8D; Wed, 3 Jan 2024 18:38:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ps9cD3Dx" 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 124631CAA0 for ; Wed, 3 Jan 2024 18:38:47 +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-a28bf46ea11so38981366b.1 for ; Wed, 03 Jan 2024 10:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704307126; x=1704911926; 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=lYrCXAnsOH5ti259ZxbWJxLR6syqU5rDe0tyxmeWWuA=; b=Ps9cD3DxxvLm/nA8x2j//4AbGTxK+X6pG3Df7eOOVLqwjQdWlsjSaojsKFd1m6XVBr exUPW0Ctd30yPSvhvxXlwz/RJzloEBoY6U/ZG0Pqf3Fw3AfeLoNd2C4xtHjavl46pOC8 jWwl6wNoYJzsu7J5H4gtoHnkZ5lX4XMYznnGWEdGOVSjxC/YSfHshtgOMUnmGLrpuVgy YgCCQ45iglhQxTNIVtd4ccexqPtDB7vWq/AZxELO4G5W3h1i3bqQT/haTXJlfoyN7mNr OFjnY6rXva0Vz97v4QVs8GMMwfG2En/soBv5RCqwaDzooEOOf50CJIut9MJJkMTRW/Vh ++4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704307126; x=1704911926; 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=lYrCXAnsOH5ti259ZxbWJxLR6syqU5rDe0tyxmeWWuA=; b=wICGSxmq8s0ZNzsiKzw9Um7qy5F0wbBzRC7gSBNXcqda1T9hy5bNvIv5TntwyfDXRs egSlFURI+NjWM7yI3P58FVnMDc2VBhglU1+Q9DBSmNZ11hRqVGl2osLDgI5Pn7P01gCX ngo1ofUJnzE3NUdf+VkXyrbZgWnkB4TOO5jpSPqNIfSulJZa9zcoaG85eyOf7AvrLh5L egl403wo9Pv6mqww8OwqInpZCBtAyHCh87wibOzDXXHAIVpL//8TXqObJwa8RaU6aB8A 2uz11cNXGerJ7IpRJGmxdp3YIFfkiXN2TM/TsU4ytNDNOV1gHfaw+J8ida14BlY2hQCR ow+A== X-Gm-Message-State: AOJu0YxImhlh5+5M2PlDyevK9h+lMmqOWsdglr5LaHMoJs+uPJCe/B7X D1b7JBiHmnXgxSbIVP82poEBZCmspGk4iShAUWOYK56kc5FRWbUV5YoetOPE6bVcHrc= X-Received: by 2002:a17:907:9010:b0:a23:62ed:105b with SMTP id ay16-20020a170907901000b00a2362ed105bmr1147383ejc.69.1704307126074; Wed, 03 Jan 2024 10:38:46 -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: From: Mina Almasry Date: Wed, 3 Jan 2024 10:38:31 -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 Wed, Jan 3, 2024 at 1:47=E2=80=AFAM Yunsheng Lin wrote: > > On 2024/1/3 0:14, Mina Almasry wrote: > > > > 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. > > There are many existing drivers which are not expecting NULL returning fo= r > skb_frag_page() as those drivers are not supporting devmem, adding additi= onl > checking overhead in skb_frag_page() for those drivers does not make much > sense, IMHO, it may make more sense to introduce a new helper for the dri= ver > supporting devmem or networking core that needing dealing with both norma= l > page and devmem. > > And we are also able to keep the old non-NULL returning semantic for > skb_frag_page(). I think I'm seeing agreement that the direction we're heading into here is that most net stack & drivers should use the abstract netmem type, and only specific code that needs a page or devmem (like tcp_receive_zerocopy or tcp_recvmsg_dmabuf) will be the ones that unpack the netmem and get the underlying page or devmem, using skb_frag_page() or something like skb_frag_dmabuf(), etc. As Jason says repeatedly, I'm not allowed to blindly cast a netmem to a page and assume netmem=3D=3Dpage. Netmem can only be cast to a page after checking the low bits and verifying the netmem is actually a page. I think any suggestions that blindly cast a netmem to page without the checks will get nacked by Jason & Christian, so the checking in the specific cases where the code needs to know the underlying memory type seems necessary. IMO I'm not sure the checking is expensive. With likely/unlikely & static branches the checks should be very minimal or a straight no-op. For example in RFC v2 where we were doing a lot of checks for devmem (we don't do that anymore for RFCv5), I had run the page_pool perf tests and proved there is little to no perf regression: https://lore.kernel.org/netdev/CAHS8izM4w2UETAwfnV7w+ZzTMxLkz+FKO+xTgRdtYKz= V8RzqXw@mail.gmail.com/ --=20 Thanks, Mina