From patchwork Tue Jun 25 19:55:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13711945 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CE9717D88C for ; Tue, 25 Jun 2024 19:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719345335; cv=none; b=hfrDWm+i///aw7hBxp4nEYjfmpNNh0/gyq+kIVXAfQP+QZ4SdcfPsQDJEBOLt4XvDhe0+C/MjLdstBtgOc4hyonmEu/5y99/H4cENh01XaQux2h1rfnodZhrhHzR7uHrLvajgVu9o/n6Mw0lxI4c0mmOswTKiZpgFlTTBp/UYsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719345335; c=relaxed/simple; bh=yQuDYyahyWrhpTwH6AYOLVPvgn4oGOMD/+riHf/SobE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sSk2X1n+wuYR5JRdyZZJM3nwrO8Nd8NYaznuoS6e3BQSiwkX+beo8yu6ON9+La8aCc8SEB2vSY2Kv1qkE68NmY1tzCx3vec8y1v/cumHisAtb9eEOI8YER17Eu/Q7ejqQbmbdry0ycfIxUkrGC8J5ckXnafcVtKRVB2yfnz5yp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk; spf=none smtp.mailfrom=davidwei.uk; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b=ij/BuTPs; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="ij/BuTPs" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1f480624d0fso46813375ad.1 for ; Tue, 25 Jun 2024 12:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1719345333; x=1719950133; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T+rHMLF33wUGoT93vAdJCy4YIKyj4oGjqYA3VqFPsY0=; b=ij/BuTPsYTck6Cxsm4yhusPShM6e0laEoBzXd0FouQQGrdT4oEpB8ukWwx005vVC4r Fl8cLp4RfEn1eB2S79/Vs064o/lG5+CThaWx0HUQLAddrU0Hzc/MnO5EZRJ8l7qcdpEk b3MjY2W0o3iZMy3BQ/V00wHllxtpaxgw/r8LfHl4EGDT0QC8rIT66YxA3ZcWPxitFASk LhcvYDBfJNlQF6rzshvtTA4fl8qeJPldwthdg7zxelC5KMh3EEVooV3kSvpds8TgGICc 21hKNfuuf197ZHnrCBOBT/LtJUpANV/UaJ4Y0hB6m0AaMrBDYtGvQicIZeGlt6FRDXlv 4s/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719345333; x=1719950133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T+rHMLF33wUGoT93vAdJCy4YIKyj4oGjqYA3VqFPsY0=; b=SQ/aAn0MQ7xm4bgmRK6MJ5eooEcIKGLEhqpXIqiSfbl5bnvyivQAynfO+fKr4UVE59 ooM8tlNT6KVJ9QWtanC2LgQu9q5R32NMe+wJLYFOsMlsVklspYiRFlEfjJgI95G0niJP bk5zTJ9j58qJb9tirDOgIaLDt/hqe/FXnMYaIQjeIzt1jnX8RmQ8TTj0M8GPpaSXfjbH 36+Cdnm47wV1P036cqSYn7YQ8JezEHDTn0SAkbqE5zUmIQBQl2U2xNyqX5a0bTf7ApAK qrUuDD99Zln1L3K3qrhTNbdac13dPmNmPhbtutsi3OUFP0tIuLnTBZU+wP+a7jgTBkXz Kx0Q== X-Forwarded-Encrypted: i=1; AJvYcCXKB/1f16xy1x/ibRIEVoAhbglM5N5Eu0y6NOSBKDRQl67cF91X3vbcqBgL7Y8/734oKa3MkfI7fnxltDob0Jx6a3Pkqu9W X-Gm-Message-State: AOJu0YyPvkPZ5Xwgc5tE8wBYKtPf53JaTrC5/c7t6dUMRF7Pb5T9Mz8f klBp5mxNBqrqU0RKGrHVbS3vDQhCcEWfJU171g6Z2IrK9RRgbZRL7iXY2x2TDZ4= X-Google-Smtp-Source: AGHT+IGosKYvm44LZDXoi8nS+gdZOULLTYynFShPVttc8Av5lY71SvE8tV4MEGet2G9PjWhfyDKngg== X-Received: by 2002:a17:902:da8f:b0:1f9:dc8d:236c with SMTP id d9443c01a7336-1fa240e7601mr79953595ad.50.1719345333414; Tue, 25 Jun 2024 12:55:33 -0700 (PDT) Received: from localhost (fwdproxy-prn-013.fbsv.net. [2a03:2880:ff:d::face:b00c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9eb321d4esm85613795ad.67.2024.06.25.12.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 12:55:33 -0700 (PDT) From: David Wei To: Michael Chan , Andy Gospodarek , Jesper Dangaard Brouer , Ilias Apalodimas , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next v1 1/2] page_pool: reintroduce page_pool_unlink_napi() Date: Tue, 25 Jun 2024 12:55:21 -0700 Message-ID: <20240625195522.2974466-2-dw@davidwei.uk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625195522.2974466-1-dw@davidwei.uk> References: <20240625195522.2974466-1-dw@davidwei.uk> 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 56ef27e3 unexported page_pool_unlink_napi() and renamed it to page_pool_disable_direct_recycling(). This is because there was no in-tree user of page_pool_unlink_napi(). Since then Rx queue API and an implementation in bnxt got merged. In the bnxt implementation, it broadly follows the following steps: allocate new queue memory + page pool, stop old rx queue, swap, then destroy old queue memory + page pool. The existing NAPI instance is re-used. The page pool to be destroyed is still linked to the re-used NAPI instance. Freeing it as-is will trigger warnings in page_pool_disable_direct_recycling(). In my initial patches I unlinked very directly by setting pp.napi to NULL. Instead, bring back page_pool_unlink_napi() and use that instead of having a driver touch a core struct directly. Suggested-by: Jakub Kicinski Signed-off-by: David Wei --- include/net/page_pool/types.h | 5 +++++ net/core/page_pool.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index 7e8477057f3d..aa3e615f1ae6 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -229,12 +229,17 @@ struct page_pool *page_pool_create_percpu(const struct page_pool_params *params, struct xdp_mem_info; #ifdef CONFIG_PAGE_POOL +void page_pool_unlink_napi(struct page_pool *pool); void page_pool_destroy(struct page_pool *pool); void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *), const struct xdp_mem_info *mem); void page_pool_put_page_bulk(struct page_pool *pool, void **data, int count); #else +static inline void page_pool_unlink_napi(struct page_pool *pool) +{ +} + static inline void page_pool_destroy(struct page_pool *pool) { } diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 3927a0a7fa9a..ec274dde0e32 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -1021,6 +1021,11 @@ static void page_pool_disable_direct_recycling(struct page_pool *pool) */ WRITE_ONCE(pool->cpuid, -1); + page_pool_unlink_napi(pool); +} + +void page_pool_unlink_napi(struct page_pool *pool) +{ if (!pool->p.napi) return; @@ -1032,6 +1037,7 @@ static void page_pool_disable_direct_recycling(struct page_pool *pool) WRITE_ONCE(pool->p.napi, NULL); } +EXPORT_SYMBOL(page_pool_unlink_napi); void page_pool_destroy(struct page_pool *pool) { From patchwork Tue Jun 25 19:55:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wei X-Patchwork-Id: 13711946 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3379A17D8B7 for ; Tue, 25 Jun 2024 19:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719345336; cv=none; b=INQPv1Dq9XrseLTELFKbUdH2i0gdyAX9I/riEkSoKXwH8RWdW8r+evNzlZNdCdgb4eQ2vvKyocXyBl+27eLvZMsUT6VhSgR5zKL/puyChXUC1cTajegc9DJ/eyewLPsV643pas2afbNV2MoSDMXEDtSA92xu/dObAeACf3JZL/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719345336; c=relaxed/simple; bh=+jQIvwSRoD2qY2EtGn1rH9DqSSCqa6kNGRg+qbb9NNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cjBs0y2oIJeT9JxLowrIjSaiu87L6b/QeCRA5GXeNqamaqoN7bJNzgHZ6NKb6KrEYfZG16ErpDnzL5vFNtYXM29SSh8QeTr51+Z7iSqLKeqM8G/PbLiyamE6Zdn9rDyxT22Q5ijdOs0CRdYrSvso5DoqWlxc+9EoUxv8LPLrMSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk; spf=none smtp.mailfrom=davidwei.uk; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b=qGbC8jwP; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=davidwei.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=davidwei-uk.20230601.gappssmtp.com header.i=@davidwei-uk.20230601.gappssmtp.com header.b="qGbC8jwP" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fa55dbf2e7so17590945ad.2 for ; Tue, 25 Jun 2024 12:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=davidwei-uk.20230601.gappssmtp.com; s=20230601; t=1719345334; x=1719950134; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fjBM8oO+wqXY9IZv7wSH+DBIVvI3nq0lFFqufk9e3T4=; b=qGbC8jwPHI3OS1i0FK4f8+Wy+wEJMVUcV+uCamJCUmRzrTibjKs5LWTLicYkOnjrN9 IvWoTr9Gi4XpL59O2NgeF+9WI6UU9P6QstUl4B8AUC9yRaZCcBIJEddMHIKNPMVUt132 urOVQucFLq5XThBTT4Brb7Yyr9ogXbaCv3POMimfBYU4hVJ3p+pgpI3vqsISY9xxf+GC cIyaCR01gj0xuCu0fjYvW6Ao5dV/pj3r1RTkx+XrXdJzgsGyimNegbW0HDDwZ/2s4V6x Dz0zOSudgN73hPJfUqTZyqamuDEWf5sATEdHAE1Qe8dz4LV48mu1y5x4Up8UTjGJ0skL oe5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719345334; x=1719950134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fjBM8oO+wqXY9IZv7wSH+DBIVvI3nq0lFFqufk9e3T4=; b=NyfyTKGm87J1+gC1mJW1Nr/uJbfC8LGzqwt2LvPhD3PbTxoVr7ZFROAeFIU0ZBbsXs 4qVexUb83jgjKOCV5/E0aq5bwt4PBCIR0unAbYtChF3oUWS0qKo4YRKa4BOSF5lgqKsJ wyWLp0NaFsqVcXnRtMWbYX6le0nqv1n8lU3Sa1Qvn4ZHJaPfPlVbpVqiwR1AwyHo2z9C Dpwjn4SB3gLXyuc5TVbJkaWNAYHIX/Yjak2i2yGscsXBaFbKYWlI1nNsDBCwEqD7Hj1u pIVcNbIvHFU/bKdI7yxZpU8iTCUIxdd7Kq/qDeRf+oj74Mbyk3vQw5FeJOf3zRpsfE+U JLCQ== X-Forwarded-Encrypted: i=1; AJvYcCWAQfhnIcjo6UmhrJnvJ6bs+TGRzsIOuJZDSUTnANPKppl4w1WFAuZmMQDeXZRBl2OHNQgwhzng+cxiVAK9OwplU+YmLbqM X-Gm-Message-State: AOJu0Ywr8AxXac0UDW3Bhs/TUBCVKv+bgtUoU+o0UqkXzoclFQVRujDv 23jw6HxZYAMKptK2av2YK4TWvu+xmUVai0oe+7mVaa9yjPIb5M4gt8gYBFP8QxI= X-Google-Smtp-Source: AGHT+IEcJlL5Sp1GtvcZ1zjWQMCjEtqpSh/sk2hyiDkiigbG9qAdeHvVoLfa2RT37d23WvmwWJYouQ== X-Received: by 2002:a17:902:e5cf:b0:1f8:68b8:373e with SMTP id d9443c01a7336-1fa158de8f9mr98387385ad.20.1719345334409; Tue, 25 Jun 2024 12:55:34 -0700 (PDT) Received: from localhost (fwdproxy-prn-027.fbsv.net. [2a03:2880:ff:1b::face:b00c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f9eb329a33sm85180955ad.116.2024.06.25.12.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 12:55:34 -0700 (PDT) From: David Wei To: Michael Chan , Andy Gospodarek , Jesper Dangaard Brouer , Ilias Apalodimas , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next v1 2/2] bnxt_en: unlink page pool when stopping Rx queue Date: Tue, 25 Jun 2024 12:55:22 -0700 Message-ID: <20240625195522.2974466-3-dw@davidwei.uk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625195522.2974466-1-dw@davidwei.uk> References: <20240625195522.2974466-1-dw@davidwei.uk> 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 Have bnxt call the restored page_pool_unlink_napi() to unlink the old page pool when resetting a queue, instead of setting a core struct to NULL directly. Signed-off-by: David Wei --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1bd0c5973252..2884ab006ea2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -15049,11 +15049,6 @@ static void bnxt_queue_mem_free(struct net_device *dev, void *qmem) bnxt_free_one_rx_ring(bp, rxr); bnxt_free_one_rx_agg_ring(bp, rxr); - /* At this point, this NAPI instance has another page pool associated - * with it. Disconnect here before freeing the old page pool to avoid - * warnings. - */ - rxr->page_pool->p.napi = NULL; page_pool_destroy(rxr->page_pool); rxr->page_pool = NULL; @@ -15173,6 +15168,7 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx) bnxt_hwrm_rx_ring_free(bp, rxr, false); bnxt_hwrm_rx_agg_ring_free(bp, rxr, false); rxr->rx_next_cons = 0; + page_pool_unlink_napi(rxr->page_pool); memcpy(qmem, rxr, sizeof(*rxr)); bnxt_init_rx_ring_struct(bp, qmem);