Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp457207rdb; Thu, 15 Feb 2024 05:37:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKTWbfrVtj6CGxKhVQt0bxmev0bdz3PdP3WXO888HvpK/YCt7gMM/L50qNxvxHMnGbXvxUy2oYrbvd2+LU7k8+SUO/7/0UqkkfA1Gp1w== X-Google-Smtp-Source: AGHT+IFpZCFcjILlg2AhHq84Vk+HdHlD/0PTiPshv1dr3ybbChuT9nFeFwmhBnIdzvCt9IXDv00s X-Received: by 2002:a1f:c346:0:b0:4c0:315d:cb6c with SMTP id t67-20020a1fc346000000b004c0315dcb6cmr1560528vkf.0.1708004244086; Thu, 15 Feb 2024 05:37:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708004244; cv=pass; d=google.com; s=arc-20160816; b=i29FNEf7INOGVL4VmZ7Ak4kw1NsHwm3XHcY2Ly8FNwdHPx4sKmXwd0e4ibAfIJaJmR JIO02Tooa++hLnk+FfdrYFs4BZlRU3tyca3dT51wG8rtoNh9/AneBMTTnMB+Sskk7mNl qqakWJmOSJUloBIBgj7iLE/ycWSSKnztxHYXVhSfz0G04CbdaXhWfaToHY0La3fBWIDM 5meWZ3uxyKjlAcWLyg1Ysg1TEN1mRkWnvD05CuvJB3GcgUyxusQpmC0O2L4Lgs8SXE1w y5huH66422hVMnvQaosH5Oun+cb9+N4AGT5WhkuVKLyaeyG5s5lJ1l4nJTX4E1YW3nUt e/0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=PFVxtk7+DZ0DWAk3Wc+rdZQ+V9hnlPmccXAlqx5M7eM=; fh=NH5y3Xj5KXledzsMPEC0Fv1Cslh4ViX581F+mILmPp4=; b=Y6M8ECtB8Z+k6uahhDogKxkYhYK3xvQg2HePwbWXDJUSyj6ZJEm/2amyznICXqH8w7 8AMeMWgF48Dr8Hc/FjIhECV3o6dGqZbYfVY90pk/eBPA6SzaXTzPKoJAmVZooHMEScK/ qSR2kFS/Co27kQ6lrNC8/QN4YoLhyGZ5TsX6iTITjwCMiMuc0u1EJOVNRUcLBDpJ5gBO m3unXCU4l+wH8OjVBlwGDtCqDzExk5EiO5zYIEM6Ba55JVPtF7wJaX3cmB75bt0INION wni0DUo6xXJw0gHJS/AFpzpxTucF13Wb1V4LBbrAOc62k9JnTlffzUdNi8xgn6jDhjH4 8e/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S1e/2dlz"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66995-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. [147.75.199.223]) by mx.google.com with ESMTPS id gu10-20020a056214260a00b0068d034d08b1si1458305qvb.305.2024.02.15.05.37.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:37:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S1e/2dlz"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-66995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66995-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 D09DD1C21BC4 for ; Thu, 15 Feb 2024 13:37:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8B98130E2D; Thu, 15 Feb 2024 13:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S1e/2dlz" 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 D012712FF7F; Thu, 15 Feb 2024 13:37:14 +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=1708004234; cv=none; b=tMVHMT/pXj+zQc65LYji7SkUCkS+Jcwmw4IKOYAkrENY58dxbtTtr3pWTtkgCvOeD+Crs0mrz+b/Ux82I8zYVV8btj4KhxtrOhJvjKLlbh7+Xl/q7vuegTzpM7lemq9dDhal2yOvH6Orf1Lxb0zb5lC0c2hlD8JvKo3GMKEx4dA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708004234; c=relaxed/simple; bh=PFVxtk7+DZ0DWAk3Wc+rdZQ+V9hnlPmccXAlqx5M7eM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jND8xivFnD5gg0Yy0KodKllxWqDb2Bmtruk42LgYrPPkKQGZVdab8gvMQ1Fct3Bl5nSz+17dDtstr2EnsYe3CySbckdViNd7FRk+Ze1hOr0jf3PKSgL1Zqe6qDVlmuLCURgdIGS+EIabPMfibxLvcwTSfBhd4TvFuT1jeS2rlfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S1e/2dlz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0BCDC433C7; Thu, 15 Feb 2024 13:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708004234; bh=PFVxtk7+DZ0DWAk3Wc+rdZQ+V9hnlPmccXAlqx5M7eM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S1e/2dlz+50J6jjmgBIN2URUTZmnc7ALcdTSep8FsCPgGRXiqVXjl56plOSsa/KNI cqiE0wvyF9OIFjSYsjxZmyalEAo5zkmZxWEAgKH0rtMCmwutb5YOz8Ky/ieebDD7GD lyp1UgYX/iJrdSFGDzzoo5Su0p0ucadd8TKNsp4Ybbxyc1ZuL6qNA6E6SzYzHyTtvf tnQqhvjWIJgUdDkXfDzN67YkP16WScFIk3xKlo3+SQEQ5ZqaOc059N4Mruat2t5EcC 4nRILszRrDisu93gYIg/K45KMDHqWopKEneSp8qnYsDDw5Sy4e+Kv7bRZ6Y7TM1XNh NQKGKhq+/dTNw== Date: Thu, 15 Feb 2024 14:37:10 +0100 From: Lorenzo Bianconi To: Alexander Lobakin Cc: Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] page_pool: disable direct recycling based on pool->cpuid on destroy Message-ID: References: <20240215113905.96817-1-aleksander.lobakin@intel.com> <87v86qc4qd.fsf@toke.dk> <8aa809c0-585f-4750-98d4-e19165c6ff73@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JwdDwmzJQxeHUrty" Content-Disposition: inline In-Reply-To: <8aa809c0-585f-4750-98d4-e19165c6ff73@intel.com> --JwdDwmzJQxeHUrty Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > From: Toke H=F8iland-J=F8rgensen > Date: Thu, 15 Feb 2024 13:05:30 +0100 >=20 > > Alexander Lobakin writes: > >=20 > >> Now that direct recycling is performed basing on pool->cpuid when set, > >> memory leaks are possible: > >> > >> 1. A pool is destroyed. > >> 2. Alloc cache is emptied (it's done only once). > >> 3. pool->cpuid is still set. > >> 4. napi_pp_put_page() does direct recycling basing on pool->cpuid. > >> 5. Now alloc cache is not empty, but it won't ever be freed. > >=20 > > Did you actually manage to trigger this? pool->cpuid is only set for the > > system page pool instance which is never destroyed; so this seems a very > > theoretical concern? >=20 > To both Lorenzo and Toke: >=20 > Yes, system page pools are never destroyed, but we might latter use > cpuid in non-persistent PPs. Then there will be memory leaks. > I was able to trigger this by creating bpf/test_run page_pools with the > cpuid set to test direct recycling of live frames. what about avoiding the page to be destroyed int this case? I do not like t= he idea of overwriting the cpuid field for it. Regards, Lorenzo >=20 > >=20 > > I guess we could still do this in case we find other uses for setting > > the cpuid; I don't think the addition of the READ_ONCE() will have any > > measurable overhead on the common arches? >=20 > READ_ONCE() is cheap, but I thought it's worth mentioning in the > commitmsg anyway :) >=20 > >=20 > > -Toke > >=20 >=20 > Thanks, > Olek --JwdDwmzJQxeHUrty Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZc4ThgAKCRA6cBh0uS2t rMKzAQCWGs8izokKKobJ1o5bjr0dNcsLSO9pBKgU1pZJzetrwQEA6Vm0zCDsUzog /Eh2aXqvy9gf0llzRVEpBYYSeLz0zgA= =r6Tb -----END PGP SIGNATURE----- --JwdDwmzJQxeHUrty--