Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4857345rdb; Tue, 12 Dec 2023 11:08:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IF35aSZ8QmQq0bhgJOSlGXr46PVpaiYiemzrEO7Kwi8Mf8cIUTUy7IDtU8zfc3LWuBpLpX+ X-Received: by 2002:a05:6a20:3ca0:b0:187:96e0:33c with SMTP id b32-20020a056a203ca000b0018796e0033cmr3990110pzj.45.1702408115338; Tue, 12 Dec 2023 11:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702408115; cv=none; d=google.com; s=arc-20160816; b=QlMsX86GVohA7MhlvzYMHU8/CZ1Sl4CBMowssbupO+5etFQYR7s5uSugAMPhe6j0AW VofYvSMrevdqbbMb2TtEAM2rWcGEMY4BRmpsxsiaQHDgZ+Fzgr/6P9RcyLXaUhr6qnYB Vbx8jf3DzC/YYg4I31nLwmi81FBWf7IUtC/phDXlmaiYhtda+FRGAc/nfKANPilOOFAG Vo9p5OKgERb/79Ml9Vi4RqLqvvLAAoZEpZ1kYA9owtHn37jf52oKhX9XHDH3F5uCbui+ pgYe9BLy8UHOnRSpVRly3tNhgfvfMVKHwnAp4lr4vw9XnauiN6ryRPTSjON4s4Vih+tJ 8qcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PE/0uUhJMPyFTyD3bW2Eu/oJ1pGeHMMJk06m8ZEqd9c=; fh=6B+dJEyUcRgVt31LPPsQ3kmKa61xywPYa/Z8onchcgg=; b=qW+XT36C7EGo4vOQ05slcnRqxbtIw/2PITcU4Yoql8HVMvhGAjl/n9CYQXp+Dq/EPp L2WsPzRJ+8sRzpUT2QaCZdGUuwvruYrN+h6UAYMw3UTI1BGp0L2kzCVVOuOxZrxH2Dns oJKiBZEC6UG68rxmLlTw38Q9FiYWbEs6Qkft2XmAriEz82YFuRZeHX0llezBudovaUoE EFjRdGB4to57u9m5ikPZE8OVTXNdHutCndadDt4u/Yw/LrPI4eyuvbxNUS5UTHX8QQK1 Uj6SgarM4KjiQz/FpIvA1ETU1HsQ8GghiINi0EvyUBpUxF0UQpfidiOg1aksjxYT2naa hJuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Au4hC/1g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id q28-20020a056a0002bc00b006ce7ff254c2si8123528pfs.368.2023.12.12.11.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:08:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Au4hC/1g"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id A7B09804C6ED; Tue, 12 Dec 2023 11:08:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233067AbjLLTIP (ORCPT + 99 others); Tue, 12 Dec 2023 14:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbjLLTIO (ORCPT ); Tue, 12 Dec 2023 14:08:14 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4457E9 for ; Tue, 12 Dec 2023 11:08:14 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D54B9C433C8; Tue, 12 Dec 2023 19:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702408094; bh=jhISTjjXnV6IhH0cY8Vge/0tePQdfehvyIi305w0McY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Au4hC/1gn8GAGqeNMIHMx+pf9H5e6cZx6if1YTAQ6myI1fcVcXp5E5HE2JZd7l5Ox z67YTPNEYCNjnSuydNuYjf11+fIKfzPgHgAvXDJMesthEcR7qviRft/QV/5zK2IHqc ruHQ42BTGcBdnaq77FMuM0r1fOHC9LqNVWjgGTPuAoXZTpwGA7dF5WXD028QLwM5fU 83R8uUGoHmwAgKnoHD0ERZyXGTjjQTXsSeJdhkJcoe/E2jvGdjrJ/mAO3N0OzKkaja 5wgu6LG6g2ra++dYX1DnvaNKyc0fxe1LJrSA1Kpyox0qvKLpHzYMqlHmzVyMur9vKu ehmZCE5A0RUew== Date: Tue, 12 Dec 2023 19:08:06 +0000 From: Simon Horman To: Mina Almasry 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 , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , Christian =?utf-8?B?S8O2bmln?= , Yunsheng Lin , Harshitha Ramamurthy , Shakeel Butt , Willem de Bruijn , Kaiyuan Zhang Subject: Re: [net-next v1 14/16] net: add SO_DEVMEM_DONTNEED setsockopt to release RX frags Message-ID: <20231212190806.GB5817@kernel.org> References: <20231208005250.2910004-1-almasrymina@google.com> <20231208005250.2910004-15-almasrymina@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231208005250.2910004-15-almasrymina@google.com> 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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 11:08:32 -0800 (PST) On Thu, Dec 07, 2023 at 04:52:45PM -0800, Mina Almasry wrote: > Add an interface for the user to notify the kernel that it is done > reading the devmem dmabuf frags returned as cmsg. The kernel will > drop the reference on the frags to make them available for re-use. > > Signed-off-by: Willem de Bruijn > Signed-off-by: Kaiyuan Zhang > Signed-off-by: Mina Almasry ... > diff --git a/net/core/sock.c b/net/core/sock.c > index fef349dd72fa..521bdc4ff260 100644 > --- a/net/core/sock.c > +++ b/net/core/sock.c > @@ -1051,6 +1051,41 @@ static int sock_reserve_memory(struct sock *sk, int bytes) > return 0; > } > > +static noinline_for_stack int > +sock_devmem_dontneed(struct sock *sk, sockptr_t optval, unsigned int optlen) > +{ > + struct dmabuf_token tokens[128]; Hi Mina, I am guessing it is mostly due to the line above, but on x86 32bit builds I see: warning: the frame size of 1048 bytes is larger than 1024 bytes [-Wframe-larger-than > + unsigned int num_tokens, i, j; > + int ret; > + > + if (sk->sk_type != SOCK_STREAM || sk->sk_protocol != IPPROTO_TCP) > + return -EBADF; > + > + if (optlen % sizeof(struct dmabuf_token) || optlen > sizeof(tokens)) > + return -EINVAL; > + > + num_tokens = optlen / sizeof(struct dmabuf_token); > + if (copy_from_sockptr(tokens, optval, optlen)) > + return -EFAULT; > + > + ret = 0; > + for (i = 0; i < num_tokens; i++) { > + for (j = 0; j < tokens[i].token_count; j++) { > + struct page *page = xa_erase(&sk->sk_user_pages, > + tokens[i].token_start + j); > + > + if (page) { > + if (WARN_ON_ONCE(!napi_pp_put_page(page, > + false))) > + page_pool_page_put_many(page, 1); > + ret++; > + } > + } > + } > + > + return ret; > +} > + > void sockopt_lock_sock(struct sock *sk) > { > /* When current->bpf_ctx is set, the setsockopt is called from ...