From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73B381F03E6 for ; Thu, 13 Mar 2025 10:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741862873; cv=none; b=IMAYg4VpX6zbO6eDUsHMWz3gFMgKYVALp1ESeUyXwAMA1NuZVpNx0hiHtAs4fPAymgKRIKS+8BDIipIFG5plhR61GhRUFrtDnBQWOvdg+Dx3nhTZdag4pFooTr0/JaIinT6VwGb0DVr52zOAjs7nWOgvVQ9ogDOikFa7DLjuNDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741862873; c=relaxed/simple; bh=flFI4F9iJbigAdLeH1msK0WPNSRRKGt+NPtx2Z0lY7g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PlIrFjfWnLkz+8s8wf759x+Lh7yjGQylNUDLbvwHYH6K8KksJt+HMJrArbgNfa+fOf/VpEDro/dq/chF2nbM/gead1eY/nJQuz396zpDXXhoAIG75udCvUBMFdOJu6vcBXzJCeyj2gsOR5kyLqpUtkp9XunFIRLr/fThavbfwUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=J82pn6a9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J82pn6a9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741862870; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mKlH8svYGZq8nS9wIHoOZaP2tIWMcEGLEEAOkrVCTz8=; b=J82pn6a9BqLAFjIB07wt6XutQpavmvmdhT1GYoD1EsY6/V2YBy054F2CC35+Fpp9sFQhAP YjcW7mJUeGbeCNUs2nqLInIJbfgq5U9+c/itscgRhfpsa7StOn5g+DEkT9zrbGLs/Y0OyV onGN+fMkBqI9gsHWi+9yBPM55yr+Ipw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-zjlVWBi0NfCNdMGUdKeEnQ-1; Thu, 13 Mar 2025 06:47:49 -0400 X-MC-Unique: zjlVWBi0NfCNdMGUdKeEnQ-1 X-Mimecast-MFC-AGG-ID: zjlVWBi0NfCNdMGUdKeEnQ_1741862868 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43d0a037f97so4036505e9.2 for ; Thu, 13 Mar 2025 03:47:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741862868; x=1742467668; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mKlH8svYGZq8nS9wIHoOZaP2tIWMcEGLEEAOkrVCTz8=; b=AaPV6lnQ2HYEgsPGVP0Jw2ymuCkBuDvF1FT6SnORGaAMky1JXOAVQGLwKgGNprzh14 /0qPLsX3v9SyLC/h+fT8RFyfzGo+VGxFI4toZl4MFkHB/Kw3PhjkB5knyTdou7eFqjzW h2B3CilUn1lhU0ZH7IV8S98uF3G/xf/7V+gUz8uun7G6s1m39ezpNrsWc02eCphP4XyX Skn7FJ0jHQ5Q3RI+Xetjeqyyc2xOYkCOCi8Vx1N3hfYAqnwe6R9JY1o2H/8taPWPUCTn EW9dR9VGs0t7k6KiqNjH0brwJlOYqMoPQBvtm97L0MNADsjMoZYhRHnskUKq1CpnFvju KTcA== X-Forwarded-Encrypted: i=1; AJvYcCUw+fKlHNnPMSyjf+SkrKB7NTnCmqKKVY4UA6yM9n/XQHZdXYvduooWuCUuBp60vJVXpkIhNz0=@vger.kernel.org X-Gm-Message-State: AOJu0YzdhdU1n2sd9yXMKCgGaztTUlABxAwAFKsc8omXdmqEVMjEtut6 QlcZChofrenI/pEsrEkFVStAPYJAnl+D1omTvPiJpxFM1u21bOvtah9hc9RY2Mro2u5EeSNhALs bK0Zcrl0p/3bogAfp3sIBhrUjbQin5/7YqGQHBH8u1dEedGLBQeyJkA== X-Gm-Gg: ASbGncvbg36267CiKgytjWHrVq+i8Zp4dw1TwYjrPVyH/MddIJeojV2nOY17XGgGMSh jXiqvN5dbB9DWqo9IZdnRlHme1urRsw9wGUzqVXwIyb+x0h7tBobPLGag63huaj4R3aE+6El3OE J/kclG9wUudgk8ZkSV4bA9l2EC4ZYJfKt7BSP/IrEpK+atqeorTAzx/Kk3XlzuCwOxIQ9UFtSya ezFGUZip6G3HYtkwTVj+koSG6USO04BkAkrS1/K4qfiO/EA05NTK5kDhx7i3D6raNjY6p6DN2M9 DQbqIZ1MSOLYZg/LdIu2G7hKOdXUMXVMPrI8LfiS X-Received: by 2002:a05:600c:524c:b0:43d:563:6fef with SMTP id 5b1f17b1804b1-43d05637140mr66351135e9.21.1741862868055; Thu, 13 Mar 2025 03:47:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuof90DCs7eJ3JwItRCIRpwATmH/3XNmF4IhoW7PyjbpLbTIbp4p7z1rZXGN+i2daYNGVW0g== X-Received: by 2002:a05:600c:524c:b0:43d:563:6fef with SMTP id 5b1f17b1804b1-43d05637140mr66350925e9.21.1741862867674; Thu, 13 Mar 2025 03:47:47 -0700 (PDT) Received: from [192.168.88.253] (146-241-6-87.dyn.eolo.it. [146.241.6.87]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d04004240sm38333535e9.3.2025.03.13.03.47.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Mar 2025 03:47:47 -0700 (PDT) Message-ID: <87e8bde7-b05e-4a1b-bcef-f6bb3a12315a@redhat.com> Date: Thu, 13 Mar 2025 11:47:44 +0100 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v7 2/9] net: add get_netmem/put_netmem support To: Mina Almasry , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev, linux-kselftest@vger.kernel.org Cc: Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Simon Horman , Jonathan Corbet , Andrew Lunn , Jeroen de Borst , Harshitha Ramamurthy , Kuniyuki Iwashima , Willem de Bruijn , David Ahern , Neal Cardwell , Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Shuah Khan , sdf@fomichev.me, asml.silence@gmail.com, dw@davidwei.uk, Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , Samiullah Khawaja References: <20250308214045.1160445-1-almasrymina@google.com> <20250308214045.1160445-3-almasrymina@google.com> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20250308214045.1160445-3-almasrymina@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/8/25 10:40 PM, Mina Almasry wrote: > Currently net_iovs support only pp ref counts, and do not support a > page ref equivalent. > > This is fine for the RX path as net_iovs are used exclusively with the > pp and only pp refcounting is needed there. The TX path however does not > use pp ref counts, thus, support for get_page/put_page equivalent is > needed for netmem. > > Support get_netmem/put_netmem. Check the type of the netmem before > passing it to page or net_iov specific code to obtain a page ref > equivalent. > > For dmabuf net_iovs, we obtain a ref on the underlying binding. This > ensures the entire binding doesn't disappear until all the net_iovs have > been put_netmem'ed. We do not need to track the refcount of individual > dmabuf net_iovs as we don't allocate/free them from a pool similar to > what the buddy allocator does for pages. > > This code is written to be extensible by other net_iov implementers. > get_netmem/put_netmem will check the type of the netmem and route it to > the correct helper: > > pages -> [get|put]_page() > dmabuf net_iovs -> net_devmem_[get|put]_net_iov() > new net_iovs -> new helpers > > Signed-off-by: Mina Almasry > Acked-by: Stanislav Fomichev > > --- > > v5: https://lore.kernel.org/netdev/20250227041209.2031104-2-almasrymina@google.com/ > > - Updated to check that the net_iov is devmem before calling > net_devmem_put_net_iov(). > > - Jakub requested that callers of __skb_frag_ref()/skb_page_unref be > inspected to make sure that they generate / anticipate skbs with the > correct pp_recycle and unreadable setting: > > skb_page_unref > ============== > > - callers that are unreachable for unreadable skbs: > > gro_pull_from_frag0, skb_copy_ubufs, __pskb_pull_tail Why `__pskb_pull_tail` is not reachable? it's called by __pskb_trim(), via skb_condense(). /P