Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2503303rdb; Fri, 8 Dec 2023 09:56:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZK7HljNfc0PE9s5/tufTTW6C5/6n+2eb3j5PGpoJ5By3xuEBCs1nzCkf5dnSCN+nD08Ur X-Received: by 2002:a05:6a00:179e:b0:6ce:41ab:9a13 with SMTP id s30-20020a056a00179e00b006ce41ab9a13mr467711pfg.61.1702058180079; Fri, 08 Dec 2023 09:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702058180; cv=none; d=google.com; s=arc-20160816; b=qrGaXb/LzQmAeWMARrTTyLxp89vmCHMw+GTioI33jHjjKh71YJlWeEpbgP0SHNddQK 1k4rxgGrvZum6sUmDgfMwVhIGToKGVZcpM8BnQ6j7riYaXijBkB6RMRrMJ7Z8Wcoyocx 0YeNHFWbxsj3deWfBnL706OCfY7nmN6k92XTEKdjOQllxQzuUR9EmChEZRkezOB7739s mOpgNViF2y5LO5D6N0wtGCL/PzJJ2D/7l9Lr7ak0sk6Y76PmS3SBPOLhRSvQDdfExlsn bJBUCp+gOQib0wG+DCvH2TDz6hf2zJzWd1KI88LYwLeRebLLLBlHhdgbO579mIQoHSrs 4Ljw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1pibVEdRn/h3MlTco2YKZU/6mk3gQHd4/6Ydm2fpuZo=; fh=p8jzhi3KzDNvYqIjTsAbouWLEIcpxVNmda4fGrgl9Gg=; b=zgZEyAK82plmuOibbrkKuuvNuZX59c+MEx1Yvll618S24Al4BHkZdVBBp1mlSzlcjg YVW17RycFkV7kokbNeVBbKlkjVTu/b4dS+rMx/ojGHjNxXHOjFzLud1fqejXScbe3YOO 8Mp1asMHqPuoYcuXHJNTQJNLmtKQ+Sqw/O5vhB0vpMSR0PFxTULjfLq/T3KHRsS/ubOZ j9oviQbse44cVx6tdSEPqX3If1gQHn3vZVRZk5JpkcewdJG9bmEQKdwCNjtqKX7PUZiH R4kdtN4ggHIVYii08ELc3aT7zx+jV09bPWKYIq3oVao42jpp7cEsphj0+rpuafMMo31C hnoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ffQMD2au; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u26-20020a056a00099a00b006cb68d85220si1849817pfg.286.2023.12.08.09.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 09:56:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ffQMD2au; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 161E78087E11; Fri, 8 Dec 2023 09:55:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574543AbjLHRzQ (ORCPT + 99 others); Fri, 8 Dec 2023 12:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574499AbjLHRzO (ORCPT ); Fri, 8 Dec 2023 12:55:14 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7702FA for ; Fri, 8 Dec 2023 09:55:06 -0800 (PST) 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 Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jeroen de Borst , Praveen Kaligineedi , Jesper Dangaard Brouer , Ilias Apalodimas , Arnd Bergmann , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Yunsheng Lin , Harshitha Ramamurthy , Shakeel Butt , Willem de Bruijn , Kaiyuan Zhang 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 08 Dec 2023 09:55:35 -0800 (PST) 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?