Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Alexander Duyck
Fri, 13 Nov 2026 20:42
[net PATCH 6/6] fbnic: Allocate FW completions with kvzalloc
Author: Alexander Duyck
Date: Fri, 13 Nov 2026 20:42
Date: Fri, 13 Nov 2026 20:42
92 lines
14900 bytes
14900 bytes
From: Alexander Duyck <alexanderduyck@fb.com>
The fbnic_fw_reporter_dump function reads the firmware coredump into a
completion that carries the whole dump, allocated by the
__fbnic_fw_alloc_cmpl function with kzalloc. A dump of a few hundred
kilobytes makes that a high-order physically contiguous allocation.
The dump runs from the devlink health auto-dump when the FW reporter
fires, which happens on the service task with RTNL held, and a reporter
firing on a missed heartbeat is most likely when the host is already
short of memory. That is where such an allocation is least likely to
succeed and most likely to drive reclaim and compaction hard.
Allocate completions with kvzalloc and free them with kvfree. Small
completions are still served by the slab allocator, and the coredump
falls back to vmalloc instead of failing or stalling. Nothing hands the
buffer to the device: the mailbox Rx path copies each chunk in with
memcpy.
The dump size comes from the firmware, and until now kmalloc refusing
anything too large was the only bound on it. The firmware keeps its
core dump, header included, in a 256K region of its flash, so reject a
larger size as bogus instead of allocating and reading it with RTNL
held.
This was seen on production hosts during host memory stalls, where the
auto-dump that followed a missed heartbeat logged an order-6 page
allocation failure in this allocation.
Fixes: 005a54722e9d ("eth: fbnic: add FW health reporter")
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
---
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c | 5 +++++
drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 5 +++--
drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 5 +++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
index 0b653c4c20a7..f63cf3224510 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
@@ -414,6 +414,11 @@ static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter,
"Firmware core dump returned size 0");
return -EIO;
}
+ if (size > FBNIC_FW_COREDUMP_MAX_SIZE) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Firmware core dump size is too large");
+ return -EIO;
+ }
/* Read the dump, we can only transfer TLV_MAX_DATA at a time */
index_count = DIV_ROUND_UP(size, TLV_MAX_DATA);
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
index 3465f0139883..96cfe0b4cd8d 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.c
@@ -382,7 +382,7 @@ static void fbnic_fw_release_cmpl_data(struct kref *kref)
cmpl_data = container_of(kref, struct fbnic_fw_completion,
ref_count);
- kfree(cmpl_data);
+ kvfree(cmpl_data);
}
static struct fbnic_fw_completion *
@@ -2108,7 +2108,8 @@ struct fbnic_fw_completion *__fbnic_fw_alloc_cmpl(u32 msg_type,
{
struct fbnic_fw_completion *cmpl;
- cmpl = kzalloc(sizeof(*cmpl) + priv_size, GFP_KERNEL);
+ /* Can be large, and the device never accesses it, so allow vmalloc */
+ cmpl = kvzalloc(sizeof(*cmpl) + priv_size, GFP_KERNEL);
if (!cmpl)
return NULL;
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
index f47669129c9d..52f69274889e 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_fw.h
@@ -40,6 +40,11 @@ struct fbnic_fw_mbx {
#define FBNIC_FW_MAX_LOG_HISTORY 14
#define FBNIC_MBX_RX_TO_SEC 10
+/* The FW keeps its core dump, header included, in a 256K region of its
+ * QSPI flash, so no valid dump is larger than that.
+ */
+#define FBNIC_FW_COREDUMP_MAX_SIZE SZ_256K
+
struct fbnic_fw_ver {
u32 version;
char commit[FBNIC_FW_CAP_RESP_COMMIT_MAX_SIZE];
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads