From patchwork Wed Nov 22 03:44:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13463911 X-Patchwork-Delegate: kuba@kernel.org 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 D689AC131 for ; Wed, 22 Nov 2023 03:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OQLBD9ep" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29C2BC433C8; Wed, 22 Nov 2023 03:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700624667; bh=pR08Q6FORwYayHs7uhiLfNHKIns5vmXKCyxM52jBe7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQLBD9epnNTlbAcuwySNihKASbRUEVUu8V+G43ZDsfDWsmi8TBfafeKTQT5sh0y7N KqufGpHbU1cZDEkNfVB79BBQX+qjR59kNzD4quNGEmwdgapa9SMknEI++TBWtIQ3Eg HF73KofW5pMFkePhLW/8zWCzUB9tQhKaa4wgwXVHbtySITq4glVkfqm0LbNXZAEGda u4q/tMi4UvEuof0z+QUsoqQFEEwzqvszqa4HhBNNPZUTBqEyb4hVmqN+IvrBBe+ntq 8gl15rG+e05W58qGQrufcmAdDO4n/bgVzrR+NuxKPGHKKBJcMWTQrNVYefwRtKbDr6 FCtCrO4lZf5BA== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, almasrymina@google.com, hawk@kernel.org, ilias.apalodimas@linaro.org, dsahern@gmail.com, dtatulea@nvidia.com, willemb@google.com, Jakub Kicinski Subject: [PATCH net-next v3 04/13] net: page_pool: stash the NAPI ID for easier access Date: Tue, 21 Nov 2023 19:44:11 -0800 Message-ID: <20231122034420.1158898-5-kuba@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231122034420.1158898-1-kuba@kernel.org> References: <20231122034420.1158898-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org To avoid any issues with race conditions on accessing napi and having to think about the lifetime of NAPI objects in netlink GET - stash the napi_id to which page pool was linked at creation time. Signed-off-by: Jakub Kicinski Reviewed-by: Eric Dumazet Acked-by: Jesper Dangaard Brouer --- include/net/page_pool/types.h | 1 + net/core/page_pool_user.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index b258a571201e..7e47d7bb2c1e 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -193,6 +193,7 @@ struct page_pool { /* User-facing fields, protected by page_pools_lock */ struct { struct hlist_node list; + u32 napi_id; u32 id; } user; }; diff --git a/net/core/page_pool_user.c b/net/core/page_pool_user.c index 1591dbd66d51..23074d4c75fc 100644 --- a/net/core/page_pool_user.c +++ b/net/core/page_pool_user.c @@ -37,9 +37,11 @@ int page_pool_list(struct page_pool *pool) if (err < 0) goto err_unlock; - if (pool->slow.netdev) + if (pool->slow.netdev) { hlist_add_head(&pool->user.list, &pool->slow.netdev->page_pools); + pool->user.napi_id = pool->p.napi ? pool->p.napi->napi_id : 0; + } mutex_unlock(&page_pools_lock); return 0;