Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp99134lqa; Fri, 26 Apr 2024 16:06:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6xOsKqdJRapcjNQB51NNpXYYfyZCX+13zInT1ryH8ckznzsL461N8HL18XYZlJe8lqf/Ozhbgdr6wCN6Bsn3mOThSbpYNuLTP9FxzyQ== X-Google-Smtp-Source: AGHT+IHD2zvLwcG8L8Wz8g8k104HjX+Vmm6zvq02QeDsjew3sBP9bg3rEAjSEuQEAw4mXUi/QvA7 X-Received: by 2002:a05:6808:6c9:b0:3c8:533d:3e9c with SMTP id m9-20020a05680806c900b003c8533d3e9cmr4053791oih.13.1714172767342; Fri, 26 Apr 2024 16:06:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714172767; cv=pass; d=google.com; s=arc-20160816; b=pba+O065zliD3fwq0BMDvLl474EttdAG5wT05AJpZMvYxz00/BW+quu5OhHbp+9ANc ieenmyRPyhO1oHxBDhAUjKUkT6d/m4BkdZEwHD00mQU2396FDUIStfZA1EPydnnpvoEQ gOc1/+LhqRJomDxuveTVj+pLmQEn7Xr0WGp6KRm13WjmKwWfPskAzVe7g0+dWARnpXP1 Z1KPsWYPKBUSMNlW0B/xiwyBi2hf3whw1WWeNQgJtEjTNpyjrVhbmH+/UcRLB/Hoo6/0 JgFzxlkiHwdKO79ENirUQu/Xw2RrXPos1sQZ059chqQS/XsAR9xMve0179s0eAokjHb0 Zukg== 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=iiPqwZQKtZJ9YVSRPExkcG4eX0iC0OeFk/H43TbqDZo=; fh=8dU1ExXBWmg/k5paL4vfYkpAYXdBFaemhQBDzA40kPM=; b=AkaTrfHyfSSnVZvfBHNdWln9/7YSTg8dBhCV6Qd2BR5JcPeOxxlf22mAAlqhmQrIeF 8DMykZSFGWyrGirXteVmBmUP9ZFqpPCT+2erAXxYq01VCShzvkPC4WKJFdX7+CRXfx4d +jMOsHX0A/zuvhH7gprYwmFqDeWLhJIW3BBIme6wTk1/W5d1Ycq/AFYnkp5MzWZkMmmA W+p49CaF3FpcDyfxTUi7MkZhJ8ewaub62eBzB57APXZ/jSUaIlGkpplAtQ8KRW5wysA1 1a7Mew6FRh/+GoQzS8jECbvE9o/tLdBkXb/4ZDzwXRyasttnwXZyRKx6GPQ9X/b8BA+R BjXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uorwIqEI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m11-20020a0562141bcb00b0069b7c08a2dfsi21619588qvc.548.2024.04.26.16.06.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 16:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uorwIqEI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-160762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160762-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 09AB21C21A3F for ; Fri, 26 Apr 2024 23:06:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 531F73BB38; Fri, 26 Apr 2024 23:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uorwIqEI" 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 7980C39FC5; Fri, 26 Apr 2024 23:05:59 +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=1714172759; cv=none; b=LxrsmZv6VKHauEISkGyMsvEpXNgUpONK9oHGMWUhaxEBLQV/WegKxkOAVj7HDlbFlskt0VVPnaO9BbcSo3iUnCX7xFxqH64pfYAj1X7gIfHU/auNUVO0JPDc8X1aDMWrGP8mzjZDgh/QQc/PSDu8ExPx3AUu1ojUf4EXYfRG6bg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714172759; c=relaxed/simple; bh=cz81g8dRd8WGS4FfF7yHOLy1Rtt7gsfw9coHC3cgGw4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B1GWyjRfTi5YQlrQFs7jiPgFuUeRtMniu0Ja78KpUhbo3a3J1b8XFrtqllODQK9rvOlxz+MvNzYjfiCNSy3q2/2k03SUOPxVQXS2MYHu7pRUUUsi5nZcUxF1gXNiMWjCkzsz7gqfT1bHuMIpeYgXmHuAh6ru1gMGji3iHhtSNIs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uorwIqEI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95794C113CD; Fri, 26 Apr 2024 23:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714172759; bh=cz81g8dRd8WGS4FfF7yHOLy1Rtt7gsfw9coHC3cgGw4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uorwIqEI92m1Q3QTYmc59i0meAi6h5Xwcn0yC4tWv48cgnTDHGurA6BMF/mJQk2Wu OYrq5jAWsEX5XlWtlbBIesUiuVtAU/XKNa0N5lRudKKCMtLGCub5hl9ZBOM9t8eFgZ 2oUt64s/xDej+8hf32ZrLtfDOKZXey+INgy/VBSVN/mVYd7s87pg47GvKGMp6V0FZ9 tIhdz3bjYtVAcCwU86vtD4dqfTD6GUEl/BcvY0YV5Ncin3srxySNWz52IGG+N0VmOS z1Mve9M4fbuzSDdVUpn3AswiA6k0zcwjAXrA91zTyWnQdEpa/w+UNTuWMuc4nqaTnt ovIzbbRIujwNQ== Date: Fri, 26 Apr 2024 16:05:57 -0700 From: Jakub Kicinski To: Dragos Tatulea Cc: "almasrymina@google.com" , "davem@davemloft.net" , "pabeni@redhat.com" , "ilias.apalodimas@linaro.org" , "linux-kernel@vger.kernel.org" , "jacob.e.keller@intel.com" , "netdev@vger.kernel.org" , Jianbo Liu , "edumazet@google.com" Subject: Re: [RFC PATCH] net: Fix one page_pool page leak from skb_frag_unref Message-ID: <20240426160557.51de91f9@kernel.org> In-Reply-To: <4c20b500c2ed615aba424c0f3c7a79f5f5a04171.camel@nvidia.com> References: <20240424165646.1625690-2-dtatulea@nvidia.com> <4ba023709249e11d97c78a98ac7db3b37f419960.camel@nvidia.com> <4c20b500c2ed615aba424c0f3c7a79f5f5a04171.camel@nvidia.com> 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 Thu, 25 Apr 2024 08:17:28 +0000 Dragos Tatulea wrote: > > The unref path always dropped a regular page > > ref, thanks to this commit as you point out: > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2cc3aeb5ecccec0d266813172fcd82b4b5fa5803 > > > > AFAICT the correct fix is to actually revert commit 2cc3aeb5eccc > > ("skbuff: Fix a potential race while recycling page_pool packets"). > > The reason is that now that skb_frag_ref() can grab page-pool refs, we > > don't need to make sure there is only 1 SKB that triggers the recycle > > path anymore. All the skb and its clones can obtain page-pool refs, > > and in the unref path we drop the page-pool refs. page_pool_put_page() > > detects correctly that the last page-pool ref is put and recycles the > > page only then. > > > I don't think this is a good way forward. For example, skb->pp_recycle is used > as a hint in skb_gro_receive to avoid coalescing skbs with different pp_recycle > flag states. This could interfere with that. That's a bit speculative, right? The simple invariant we are trying to hold is that if skb->pp_recycle && skb_frag_is_pp(skb, i) then the reference skb is holding on that frag is a pp reference, not page reference. skb_gro_receive() needs to maintain that invariant, if it doesn't we need to fix it..