From nobody Sat Feb 7 08:27:54 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 DDF361DD0C9; Tue, 15 Oct 2024 14:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729004086; cv=none; b=I+xg9lMwoHpGnQ7DKshMlsRhezUWZ+ZKQ2jSKS15DTM5RQ6WmGp0ro4hAKd/w03lqd2iwb3AR2yahSbTL11LxgSWPyykWbxL+HwqY+tH08pskbrk5VB6dbpeQ6168eb14UKRv0sHJE0ui0TFk6r+VFGjO/txZVqfsI1JKF18cB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729004086; c=relaxed/simple; bh=qh0VLiP9AjlliJhi2Ofn75NLMTJvj8+z9+cv+j8uU3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KGtR2/VSzKRiWXcUuHinqaknkMz/Ew4Nt59tULVdYQAjXCWx4BrJzqAk+D7ik5WxIXS0qFtBLKXBXKb8nQcMPBwziO/kVtwkTISxUm+9qPp5cWiC1JmINTcJeoAw7SMh1FDrnFMjI6w69a0tpxDf0h3GuacvpVVd3hREjqo4hr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RsmSkBMa; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RsmSkBMa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729004085; x=1760540085; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qh0VLiP9AjlliJhi2Ofn75NLMTJvj8+z9+cv+j8uU3U=; b=RsmSkBMayPEqcITvFd1VeZ4TC+08RkeABNlxZszlyFDPWa++1KzfMCxx fFxprOcs1Jwj7rpXk/SahB3YKwyDHP2rAUy095ELUlMast6Z6vETZUeUD di0P2H9Hh4/JqIopkPpnrn1A++kMDnh1vTPzWUgyEZqjTkXWIhHWpoCRq c1ByN0LsWK8QOCAZZOJzdrtqlV5XWCVeYUyGjjk4u8dd0LCpsf8lW+POG bG1GXe2pVKcPTHbm4dAQ/3qGjbZq7YzR9is6+EvhS0SLHtkLZdOabKzGS 5ZZAOWOOrfDMGc7ey7LNHdiZC+PSZYMx4WtI8CuaKAMOB6fbYsNJF0LJw Q==; X-CSE-ConnectionGUID: ZkqrV75gSaO1lZ1RvlLObg== X-CSE-MsgGUID: DtOA3BC0Tq610/qSHLldXg== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="31277518" X-IronPort-AV: E=Sophos;i="6.11,205,1725346800"; d="scan'208";a="31277518" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 07:54:43 -0700 X-CSE-ConnectionGUID: jQxOQb3CQ0e0gIA/so2ibw== X-CSE-MsgGUID: MxFbcYn9T4+ulzgC9uvc0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="82723092" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orviesa003.jf.intel.com with ESMTP; 15 Oct 2024 07:54:39 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Stanislav Fomichev , Magnus Karlsson , nex.sw.ncis.osdt.itp.upstreaming@intel.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 07/18] net: Register system page pool as an XDP memory model Date: Tue, 15 Oct 2024 16:53:39 +0200 Message-ID: <20241015145350.4077765-8-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015145350.4077765-1-aleksander.lobakin@intel.com> References: <20241015145350.4077765-1-aleksander.lobakin@intel.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="utf-8" Content-Transfer-Encoding: quoted-printable From: Toke H=C3=B8iland-J=C3=B8rgensen To make the system page pool usable as a source for allocating XDP frames, we need to register it with xdp_reg_mem_model(), so that page return works correctly. This is done in preparation for using the system page pool for the XDP live frame mode in BPF_TEST_RUN; for the same reason, make the per-cpu variable non-static so we can access it from the test_run code as well. Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen Signed-off-by: Alexander Lobakin --- include/linux/netdevice.h | 1 + net/core/dev.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 72f53e7610ec..692f21c28ea5 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3308,6 +3308,7 @@ struct softnet_data { }; =20 DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); +DECLARE_PER_CPU(struct page_pool *, system_page_pool); =20 #ifndef CONFIG_PREEMPT_RT static inline int dev_recursion_level(void) diff --git a/net/core/dev.c b/net/core/dev.c index b857abb5c0e9..773388f26d4f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -460,7 +460,7 @@ EXPORT_PER_CPU_SYMBOL(softnet_data); * PP consumers must pay attention to run APIs in the appropriate context * (e.g. NAPI context). */ -static DEFINE_PER_CPU(struct page_pool *, system_page_pool); +DEFINE_PER_CPU(struct page_pool *, system_page_pool); =20 #ifdef CONFIG_LOCKDEP /* @@ -12103,11 +12103,18 @@ static int net_page_pool_create(int cpuid) .nid =3D cpu_to_mem(cpuid), }; struct page_pool *pp_ptr; + int err; =20 pp_ptr =3D page_pool_create_percpu(&page_pool_params, cpuid); if (IS_ERR(pp_ptr)) return -ENOMEM; =20 + err =3D xdp_reg_page_pool(pp_ptr); + if (err) { + page_pool_destroy(pp_ptr); + return err; + } + per_cpu(system_page_pool, cpuid) =3D pp_ptr; #endif return 0; @@ -12241,6 +12248,7 @@ static int __init net_dev_init(void) if (!pp_ptr) continue; =20 + xdp_unreg_page_pool(pp_ptr); page_pool_destroy(pp_ptr); per_cpu(system_page_pool, i) =3D NULL; } --=20 2.46.2