Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp290380lqi; Wed, 6 Mar 2024 18:16:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVaBqA5rsMnQlpZrGbpySUjAaNClp3je7ggjWolpcPhH932XselWv3wAJqlH63gz5mLcOa5k6baI0bKilqU1vbS5V/Hep09ZLUhi8Bixw== X-Google-Smtp-Source: AGHT+IE+Um7lX1u5lxkKsvtd0168AC6ZE89gjfL2bkQDz+/NU7/VOxYsc+bc/9qm0eCzqzHiAyR9 X-Received: by 2002:a05:6e02:1a0e:b0:365:2448:5867 with SMTP id s14-20020a056e021a0e00b0036524485867mr19787639ild.18.1709777816735; Wed, 06 Mar 2024 18:16:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709777816; cv=pass; d=google.com; s=arc-20160816; b=GQKXeLxMPEqLPxk9yyrS/txgQoA79mtfW+t/8A+kq5mftHBUc0dpL43f7MAWfViijc dxc/nGEEvhrJVOcaGAMc8M3+i03aYFYhEu8LqhTCIJmR5ZbLUA+roPi95KJpUTt0bbFs cAgGdeYcs15A5aKXtSveXryRD6Phsla8r69SbNC+6zvkIFGVRppDH+j8Np9YAhT97Hz7 TWC0Om/UI9+nBtc0IKxoZ+j25HWC3rzYHvIkDwFfwweW1n1qBkqIaKQMvior9dEce45h uZ05nd0Kk9RF0ah6MiKwSnlKgxhe6V5xaAZrg2OBS7c0+5w9eqIhbZ5pL/YleneOfSbf +MyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=W14tpPjzPU6T94Ery9FN/R8WyHigR9IedLcrglpL9+U=; fh=n/MJyM7W1HrIcdQRyYfB3tJjiYrv/rKwYIRNbHLyAUU=; b=b9IP7sLSvIzAln9wpBtYXEdWUlxnUQoNfASjeqYE/CJIkg+cM/friWXElEH3JFNvTx q+SxFyNUjhMOpweK0W0B9Vtdo+guHmtYeTPwc8w3wO7fAmXVH3HDHrn9I1pzwFuiL0FJ hhs3gzDYaL6BYU6GzyLMqnTdwto6qfsJVg6kRXQIk9UHHZUqFWrvFuDvaBAuELRBhKO4 hUwVibjovL7fhyQ/zDX4jH48boqTg5Jvvdoxx/xsRilV0z2s/WBw/hcxPwpPlnl8kgcN RiVzMMZZK8h/Qil6AVUzN1xDBa5wCfrAuJBHXi2SYZ8vq2ywWcB0lNDJWx+fIH4J/Xbp PEqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e2haLrco; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-94858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b27-20020a631b5b000000b005e47d608cbesi12795267pgm.134.2024.03.06.18.16.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 18:16:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=e2haLrco; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-94858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 68541286D76 for ; Thu, 7 Mar 2024 02:16:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FCA11804E; Thu, 7 Mar 2024 02:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e2haLrco" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 47BB415EA6; Thu, 7 Mar 2024 02:16:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709777762; cv=none; b=nLsIkrYbZHkrdlbFfW9jaqZD2KNuEmkYRz94OPiQsSVPFxKKSOoi9ufOUfCzwyXey/radYFcfr86dcER1+JtXupXaEQKC5lWPyl+cp9uw0+bskbOhzADs3DolB5uQ2uwenl9xfPYwK46yAYpUP3E8PiMgdYPVx0rHThD2TGlCZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709777762; c=relaxed/simple; bh=Cw89We1aTAVBbcBRos65D+qMVJWNLUVeKILK2DWf540=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T9jx8jzZ3kv1NM891tfP4ujUR+0oxkAKbi0rB577DSa3HnPKRGjmfKmqTrfQI0qyg9cFYMfQqDwCOCza2eUgtEllnJb8Wb7aHwO2oAJVM/a5Xus03Uuexn7X1LkFZC0IvHZABmnYVKFOJJdEX5NLORd/cgBpcoviKhhWubLNzbw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e2haLrco; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59B1BC43390; Thu, 7 Mar 2024 02:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709777761; bh=Cw89We1aTAVBbcBRos65D+qMVJWNLUVeKILK2DWf540=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=e2haLrcoYyKOlH2ZZ7Rf2CK7O15Lo2E4Oo5/0FMZRY1/4m0vAJc7leeijC1NOZL/Q VFqcSJcgHOooJ/oa6qlbuQ4Ae6kYuqlId0zP2V4BKXfRz7qldYKowGfkO0SC0LHa9b rCUh6zs2WQYuNhvgy05KaFAW3UzmQfdupjgIo4nyNIT6iwWozWi6D0gmspUrvORIPF 4Ka4+bjiQR8ADhwLoCSpt3VlxbFfeRlynSh1LA1Ye/sA/O9fu1GmVl63FgJTgZ+6R6 gmAm5XzUS7RlaaZi7B16Yg8ARBnUcqZcbvfJC1sTgYhXR4TwttR4QEgZjm8R1Vh/VA O20Ji8xeC+9Kw== Date: Wed, 6 Mar 2024 18:16:00 -0800 From: Jakub Kicinski To: Mina Almasry Cc: Liang Chen , Yunsheng Lin , Dragos Tatulea , "davem@davemloft.net" , "herbert@gondor.apana.org.au" , Gal Pressman , "dsahern@kernel.org" , "steffen.klassert@secunet.com" , "linux-kernel@vger.kernel.org" , "pabeni@redhat.com" , Leon Romanovsky , "edumazet@google.com" , "ian.kumlien@gmail.com" , "Anatoli.Chechelnickiy@m.interpipe.biz" , "netdev@vger.kernel.org" Subject: Re: [RFC] net: esp: fix bad handling of pages from page_pool Message-ID: <20240306181600.5af8ef5f@kernel.org> In-Reply-To: References: <20240304094950.761233-1-dtatulea@nvidia.com> <20240305190427.757b92b8@kernel.org> <7fc334b847dc4d90af796f84a8663de9f43ede5d.camel@nvidia.com> <20240306072225.4a61e57c@kernel.org> <320ef2399e48ba0a8a11a3b258b7ad88384f42fb.camel@nvidia.com> <20240306080931.2e24101b@kernel.org> <9a78b37abdf40daafd9936299ea2c08f936ad3d5.camel@nvidia.com> <20240306094133.7075c39f@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 6 Mar 2024 10:46:45 -0800 Mina Almasry wrote: > Gah, nevermind, skb_pp_frag_ref() actually returns -EINVAL if > !skb->pp_recycle, and in the call site we do a skb_frag_ref() on this > error, so all in all we end up doing a get_page/put_page pair. Sorry > for the noise. > > So we're supposed to: > - !skb->pp_recycle && is_pp_page() > ref via get_page > unref via put_page > > Very subtle stuff (for me at least). I'll try to propose some cleanup > to make this a bit simpler using helpers that handle all these subtle > details internally so that the call sites don't have to do this > special handling. Sure, although complexity is complexity, we can only do so much to hide it. For pp_recycle - the problem is when we added page pool pages, hardly anything in the upper layers of the stack was made pp aware. So we can end up with someone doing get_page(page); skb_fill_page_desc(skb, page); on a PP page. You probably inspected a lot of those cases for the ZC work, and they can be fixed up to do a "pp-aware get()", but until then we need skb->pp_recycle. pp_recycle kinda denotes whether whoever constructed the skb was PP aware. So, yes, definitely a good long term goal, but not in a fix :)