Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2552760rdb; Fri, 8 Dec 2023 11:23:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJGCSmhcPMHbw8hb7KatUGgGOvNkvrd5dWVwG0ELPW7uVgb/13nHHXeiufL6sQQYM/D0OF X-Received: by 2002:a17:90a:d705:b0:281:4fa7:7ab0 with SMTP id y5-20020a17090ad70500b002814fa77ab0mr619432pju.24.1702063410854; Fri, 08 Dec 2023 11:23:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702063410; cv=none; d=google.com; s=arc-20160816; b=hI6buuDlp+Fpq2z2Wn68WP77zajXHZRHS/hT0eQ+1EKgJhCNfrm36j19+Wsn9+YhdY xgf55v+lUuQdRBNctoaZRDrCkrIS3CiINFgRIVt0FktCDh3NDaqYSsMcXqma+gPHhBmo MpLZP2EHMgdhLDV0MGFGancncmOb1OFyHccRYfCocQsIcE8EFeFp93eYz2AY8YtyAHN7 b3Fq+I5DAspq97NMvSym8I3iPC6QooTaAQe06vLIGIZUgL461N9rI/yEwm7/PzjgzMq9 QBSXvHGS9Es6Ab/gcdfH99sW+OG2VtsYD+TzdMIgUZ+nwZ8fchaThPvqewYSmToGezra 3fFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eNuhxRDBfdQenk+uC5+I+2o2Yad/2wCHUso1pH85sfo=; fh=3vdDtv+sUddP2wEEeB9sfn0I6QTRYGCWb3VYJk0Hkkw=; b=JHxHSXz/xc5Mt/SMIQwwe+ANh62cAIs8yfioyLodOxDD6VBPLAMVqnj3d6pNFpUwRZ +wRxelsZDyn7yo3rO+M8SBrPsX49WrwLQoETjIYP2r/8eQXeul0EnfnHDum+MasnWtL9 burRa8EYZ/1UbZkeLlVGCg/hJI6LIK4wndBv9Q2y+eyhub+lNhdub25kpcCR0JG7xKUR 0X4GDKCbweKxTiDkCwsNtxELiFDfRb2gk1jnrZVKzaHYPhTUqpVQm/8JVE6ebxQP7mPQ /MZ0dx7z16iRCUWNDT3/IPVQ9ivyOrQ4FoHzB1/3PfDXoG22TH17t0/4YoWZzqYW7hdQ 4Dzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=puGdxYqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d6-20020a170902cec600b001d00a92b9d4si2091860plg.575.2023.12.08.11.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 11:23:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=puGdxYqA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4FA4D8025173; Fri, 8 Dec 2023 11:23:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574679AbjLHTXN (ORCPT + 99 others); Fri, 8 Dec 2023 14:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574687AbjLHTXL (ORCPT ); Fri, 8 Dec 2023 14:23:11 -0500 Received: from mail-ua1-x92e.google.com (mail-ua1-x92e.google.com [IPv6:2607:f8b0:4864:20::92e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA3E1998 for ; Fri, 8 Dec 2023 11:23:16 -0800 (PST) Received: by mail-ua1-x92e.google.com with SMTP id a1e0cc1a2514c-7cac4a9c5b5so142869241.1 for ; Fri, 08 Dec 2023 11:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702063396; x=1702668196; 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=eNuhxRDBfdQenk+uC5+I+2o2Yad/2wCHUso1pH85sfo=; b=puGdxYqAoQo3bHG294LrXUJmKf0r2uufNMehZOj/ib8lgIMoVsopaKC4B4b6fUFyya +B9rAwaP7t2N4ealA6hhXjhKtZfHcQqR6mND4Wm8Bn+OcwAWZPIz8cpOBRc9eMDbClhr m0HzrbjSOx0Odg45PVXWbTCRw/nXU3Cn7nmp3mL+o1poKncrgSXhF/YFLuLQHGoSStQf RrJGwyuzvUNDUEsmKjSD2uxYZ/BCYB8G86AaueFaliWGMcb/21OR7QeKm0LdzJc1VKhI 29fSLZU9MNVBk7gsWs++emPmOErx0U5NoIpQDDk2xKmI0xt174+doddUkTq2O/QdtbwO qpuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702063396; x=1702668196; 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=eNuhxRDBfdQenk+uC5+I+2o2Yad/2wCHUso1pH85sfo=; b=fTXQF+y2dOV1LYC/syRfXbtA1raEeYFFJvmoT4PLroPXcC9Mn8NIGOdsN5JOelZi7C tsg6pRq8XUQhoEOM70bCEozJh0YnrTU0jXiUlVtFT9Te7CRXj/0qeIbsUGngrYoXO/lR fxxFRRdB+0DHOF/meANYrN2zOXDYH+5hzlIN4/edtbCkToqgXJa9tdxnIZEIFu3ALGpA 8dZqtHltZJklJFzcJRuUdZoje5ezpLc67Acr12nE45LmtEbpu6OlzYmx2vDrnt3DdNSF VgX1iB165yyKl3eMPt7wrZuH8UslHhSjKuDs5/G3O2kANgvhORLdC6ajMkXzFif9FLJ/ i26g== X-Gm-Message-State: AOJu0Yz2sxJSAlt7J4f2HqRG/fA95rx9t6H/q/48u2uxr2O8olJGBCiN SpGhEI10mcP+zRYcMa2MYK4b/objJU8BZ4DnHAAiVA== X-Received: by 2002:a05:6102:38ce:b0:465:e3df:13a with SMTP id k14-20020a05610238ce00b00465e3df013amr837357vst.9.1702063395773; Fri, 08 Dec 2023 11:23:15 -0800 (PST) MIME-Version: 1.0 References: <20231208005250.2910004-1-almasrymina@google.com> <20231208005250.2910004-14-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Fri, 8 Dec 2023 11:23:04 -0800 Message-ID: Subject: Re: [net-next v1 13/16] tcp: RX path for devmem TCP To: David Ahern Cc: 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, "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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 08 Dec 2023 11:23:28 -0800 (PST) On Fri, Dec 8, 2023 at 9:55=E2=80=AFAM David Ahern wro= te: > > 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_DEVME= M > > 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? When an skb is dropped, skb_frag_unref() is called on the frags, which calls napi_pp_put_page(), drops the references, and the iov is recycled, yes. --=20 Thanks, Mina