From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E793FC4167B for ; Fri, 8 Dec 2023 17:55:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 16F2D10EAE0; Fri, 8 Dec 2023 17:55:09 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 493F410EAEC for ; Fri, 8 Dec 2023 17:55:07 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 90D006253F; Fri, 8 Dec 2023 17:55:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C37C433C8; Fri, 8 Dec 2023 17:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702058106; bh=JgZX3IUxr5QjMN2L4CfeQWIXpX0PnQ2euhMWDoEDapU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ffQMD2auV5w+fsPXOpLjjMdU1ohOWFKct2g6oLxTffd+jY0euyAOdzi/eqD61jlc+ HQog2qKV7NuXXul2OZwYKSbvrILIZs0XzeLqtAvKUA4/XQKUYj0GCwO8BZEcxFJAZ4 GLm3pcSpziEsxyQImevNBJZiHEQ8JkkB+a9n6UqqffPLT5eqXSY4Nx6h0P0+mdoyhV 1yb+zJMYP0R8FKtdnus7PhqoTZwJkmDhleXYtnwpOHALRaHKPwGAKUXVLbVD89Ec0l fXneCel4rLSIqmz3W4sSAXZ8gZYi+HGbH/qhPlVwKwHjNEGwB5ADQloXnigiu+qOwX MSXnnWbvmdStw== Message-ID: Date: Fri, 8 Dec 2023 10:55:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [net-next v1 13/16] tcp: RX path for devmem TCP Content-Language: en-US To: Mina Almasry , Shailend Chand , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20231208005250.2910004-1-almasrymina@google.com> <20231208005250.2910004-14-almasrymina@google.com> From: David Ahern In-Reply-To: <20231208005250.2910004-14-almasrymina@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Willem de Bruijn , Kaiyuan Zhang , Jeroen de Borst , Jesper Dangaard Brouer , Arnd Bergmann , Jonathan Corbet , Ilias Apalodimas , Yunsheng Lin , Sumit Semwal , Eric Dumazet , Shakeel Butt , Willem de Bruijn , Harshitha Ramamurthy , Praveen Kaligineedi , Jakub Kicinski , =?UTF-8?Q?Christian_K=C3=B6nig?= , Paolo Abeni , Shuah Khan , "David S. Miller" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 12/7/23 5:52 PM, Mina Almasry wrote: > In tcp_recvmsg_locked(), detect if the skb being received by the user > is a devmem skb. In this case - if the user provided the MSG_SOCK_DEVMEM > flag - pass it to tcp_recvmsg_devmem() for custom handling. > > tcp_recvmsg_devmem() copies any data in the skb header to the linear > buffer, and returns a cmsg to the user indicating the number of bytes > returned in the linear buffer. > > tcp_recvmsg_devmem() then loops over the unaccessible devmem skb frags, > and returns to the user a cmsg_devmem indicating the location of the > data in the dmabuf device memory. cmsg_devmem contains this information: > > 1. the offset into the dmabuf where the payload starts. 'frag_offset'. > 2. the size of the frag. 'frag_size'. > 3. an opaque token 'frag_token' to return to the kernel when the buffer > is to be released. > > The pages awaiting freeing are stored in the newly added > sk->sk_user_pages, and each page passed to userspace is get_page()'d. > This reference is dropped once the userspace indicates that it is > done reading this page. All pages are released when the socket is > destroyed. > > Signed-off-by: Willem de Bruijn > Signed-off-by: Kaiyuan Zhang > Signed-off-by: Mina Almasry > > --- > > Changes in v1: > - Added dmabuf_id to dmabuf_cmsg (David/Stan). > - Devmem -> dmabuf (David). > - Change tcp_recvmsg_dmabuf() check to skb->dmabuf (Paolo). > - Use __skb_frag_ref() & napi_pp_put_page() for refcounting (Yunsheng). > > RFC v3: > - Fixed issue with put_cmsg() failing silently. > What happens if a retransmitted packet is received or an rx window is closed and a probe is received where the kernel drops the skb - is the iov reference(s) in the skb returned to the pool by the stack and ready for use again?