* Re: [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu @ 2026-10-20 16:47 netdev-bot+sashiko 0 siblings, 0 replies; 4+ messages in thread From: netdev-bot+sashiko @ 2026-10-20 16:47 UTC (permalink / raw) To: weh Cc: longli, kotaranov, kuba, davem, pabeni, edumazet, andrew+netdev, jgg, leon, haiyangz, wei.liu, decui, shradhagupta, horms, ernis, stephen, netdev, linux-rdma, linux-hyperv, linux-kernel, bpf, sdf, daniel, hawk, ast, john.fastabend, weh, edumazet Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] mana_change_mtu() adds a new use of the boolean channel_changing as an ad-hoc lock. -- net: mana: swap queue sets in mana_change_mtu With this patch, mana_change_mtu() builds a full replacement queue set sized for the new MTU and swaps it in. It no longer does a detach and attach. The MTU is carried in the queue set as configured_mtu, and ndev->mtu is published only after RSS configuration succeeds. > diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c > index c80a06ffbe508..c1ff4d9b8d45f 100644 > --- a/drivers/net/ethernet/microsoft/mana/mana_en.c > +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c > @@ -956,32 +956,52 @@ int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_qu > static int mana_change_mtu(struct net_device *ndev, int new_mtu) > { [ ... ] > + /* Fail-close may release the Ethernet vport reference. */ > + mutex_lock(&mpc->vport_mutex); > + if (mpc->channel_changing) { > + mutex_unlock(&mpc->vport_mutex); > + return -EBUSY; > + } > + mpc->channel_changing = true; > + mutex_unlock(&mpc->vport_mutex); > + > + scratch = mana_qset_scratch_alloc(mpc); > + if (!scratch) { > + err = -ENOMEM; > + goto clear_flag; > } > > - WRITE_ONCE(ndev->mtu, new_mtu); > + err = mana_alloc_qset(mpc, scratch, mpc->num_queues, > + mpc->rx_queue_size, mpc->tx_queue_size, > + mpc->priv_flags, new_mtu, &newq); > + if (err) > + goto free_scratch; > > - err = mana_attach(ndev); > + err = mana_publish_qset(mpc, &newq, &oldq); > if (err) { > - netdev_err(ndev, "mana_attach failed: %d\n", err); > - WRITE_ONCE(ndev->mtu, old_mtu); > + mana_free_qset(scratch, &newq); > + goto free_scratch; > } > > -out: > - mana_pre_dealloc_rxbufs(mpc); > + mana_free_qset(scratch, &oldq); > + > +free_scratch: > + mana_publish_close_if_needed(mpc); > + mana_qset_scratch_free(scratch); > +clear_flag: > + mutex_lock(&mpc->vport_mutex); > + mpc->channel_changing = false; > + mutex_unlock(&mpc->vport_mutex); > return err; > } [Severity: Medium] Here, channel_changing seems to act as a lock around a code section rather than as a record of object state. Is that the intent? The flag is set under vport_mutex, and then the mutex is dropped. The whole sleeping replacement runs after that: mana_qset_scratch_alloc(), mana_alloc_qset(), mana_publish_qset(), mana_free_qset(), mana_publish_close_if_needed() and mana_qset_scratch_free(). The flag is cleared again at clear_flag. The only reader is on the RDMA side, and it fails instead of waiting: mana_cfg_vport() { ... mutex_lock(&apc->vport_mutex); if (apc->vport_use_count > 0 || (check_channel_changing && apc->channel_changing)) { mutex_unlock(&apc->vport_mutex); return -EBUSY; } ... } As a result, RAW-QP creation gets a transient -EBUSY during any MTU change on a running port. Lockdep also cannot see this exclusion. vport_mutex probably can't just be held across the region, because the fail-close path takes it itself: mana_publish_close_if_needed() -> mana_dealloc_queues() -> mana_destroy_vport() -> mana_uncfg_vport() -> mutex_lock(&apc->vport_mutex) Can the -EBUSY check at the top of mana_change_mtu() ever trigger? Every writer of channel_changing holds RTNL for its whole region, and RDMA only reads the flag. The writers are mana_change_mtu(), the queue reset work, the set_channels, set_ringparam and set_priv_flags handlers, and the XDP setup path. The same pattern already exists in the queue reset work, mana_set_channels() and mana_set_priv_flags(). This patch extends it to the MTU path, and it is still there at the end of the series. Could a real lock, or some way for RDMA admission to wait, be used here? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1791710735.git.weh%40linux.microsoft.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v7 00/13] net: mana: reconfigure by replacing the queue set
@ 2026-10-16 15:38 Wei Hu
2026-10-16 15:38 ` [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu
0 siblings, 1 reply; 4+ messages in thread
From: Wei Hu @ 2026-10-16 15:38 UTC (permalink / raw)
To: longli, kotaranov, kuba, davem, pabeni, edumazet, andrew+netdev,
jgg, leon, haiyangz, wei.liu, decui, shradhagupta, horms, ernis,
stephen
Cc: netdev, linux-rdma, linux-hyperv, linux-kernel, bpf, sdf, daniel,
hawk, ast, john.fastabend, weh, edumazet
I am carrying Long Li's queue-set reconfiguration series forward for this
revision. Long remains the author of twelve patches, and Dipayaan Roy
remains the author of the detach change. Their authorship and signoffs
are retained; I have added my signoff for this revision.
Replace detach/attach reconfiguration with pre-allocation and queue-set
replacement. Allocation failure leaves the running configuration intact.
Publication failure attempts rollback; a failed rollback closes the port
and holds carrier down until a successful reopen.
EQs and statistics belong to the port. Valid user-configured RSS tables
survive queue rebuilds. Channel-count changes reuse surviving queues:
reductions retire the tail and increases allocate only the added queues.
Ring, MTU, private-flag and XDP layout changes still perform full rebuilds.
This series remains independent of the HWC concurrency/dynamic-depth
series; it is not stacked on its feature commits. Their CQ-publication
hunks overlap, so the later-applied series needs reconciliation preserving
both table-publication and individual-CQ lifetime guarantees.
https://lore.kernel.org/all/cover.1790665894.git.weh@linux.microsoft.com/
Changes since v6:
- Rebase onto net-next d8674294aefef02266c4d47ad10131f1bffbe534
after Simon Horman reported that v6 did not apply and CI did not run.
Preserve upstream's GDMA core/PCI/CDX split, its separate PCI capability
group and the RX-headroom-aware full-page shortcut.
- Fix the DMA-region unwind required by repeated EQ-pool growth in
patch 2. Destroy a registration still owned by software if EQ creation
fails. A successful hardware creation invalidates that handle, so a
later EQ-test failure does not destroy transferred ownership twice.
- Make mana_detach() return void in patch 9 and remove unreachable
caller error branches. Preserve deallocation logging and ndo_stop's
required integer return.
- Keep the thirteen-patch layout, original authors and existing signoffs.
Review notes:
- The reported /proc/net/dev stats UAF assumes unregister_netdevice()
defers its grace period. Its NULL-head path synchronously unlists and
synchronizes network readers, removes sysfs state, then synchronizes
again before returning, in both the old and new base.
- The two stats-folding deadlock reports require unsupported 32-bit
MANA. PCI and CDX both restrict support to 64-bit, where u64_stats_sync
has no sequence counter or reader retry loop.
- The xdp_xmit lost-increment race is real but already present on the
unmodified base. Moving the counter to port-owned storage does not
introduce it; keep that independent statistics fix separate.
Rebase request:
https://lore.kernel.org/all/20261010162855.GU83879@horms.kernel.org/
EQ unwind / detach reviews:
https://lore.kernel.org/all/sashiko-outbox-166658@kernel.org/
https://lore.kernel.org/all/sashiko-outbox-166664@kernel.org/
v6 review inventory:
https://sashiko.dev/#/patchset/cover.1790795005.git.weh@linux.microsoft.com
Changes since v5 (retained from v6):
- Rebase the independent queue-set series onto net-next base
47a1446725732cd3996edf607e8739334bbf4d78.
- Drain ALL old TX queues after closing the TX/XDP gate and waiting for
readers, but before publishing pointers, counts or RSS. A shared
120-second drain deadline rejects a replacement by resuming the old
configuration without reprogramming RSS or resetting the function.
Retirement does not use FLR. Ordinary mana_dealloc_queues() remains
byte-identical to this base: existing reset policy and independent
failed-FLR hardening are deliberately not changed.
- Complete the shared EQ/CQ lifetime prerequisite in patch 2. Initialize
EQ state before IRQ publication. After stopping a retiring CQ's NAPI
and work and tearing down its WQ object, flush its actual parent EQ
while the CQ callback is still published. Clear its table entry and
wait for RCU IRQ readers before freeing the CQ and callback owner.
Pair IRQ lookups with release publication at all CQ publishers;
Ethernet publication follows NAPI/DIM initialization. Matching HWC
and RDMA publication stores do not change their recovery policies.
- Move port-lifetime statistics preparation ahead of the first live
swap, now patch 3. Introduce RX retirement, writer handoff and folding
atomically with the first swap in patch 4, rather than relying on a
later patch to make intermediate statistics readers safe.
- Keep publication barriers consistent with open/attach. Latch forced
carrier shutdown regardless of the previous carrier state and clear
it only after successful reopen. Retain the rollback reader grace
period after restoring old pointers, before callers discard scratch
state.
- Join TX queue selection to the publication gate in patch 4. Acquire
port_is_up before count/RSS reads and snapshot real_num_tx_queues.
Retiring tail RQs can outlive a TX-count reduction; when a recorded
RX index no longer fits the live TX count, use the current RSS mapping
instead of returning that stale index.
- Clear DRV_XOFF on inactive allocated TX queues in patch 4's cold-path
restart helper, using netif_tx_start_queue() while preserving the
availability checks and wake behavior for active queues. Publication
stops all allocated queues, and the netdev watchdog scans allocated
num_tx_queues, not just real_num_tx_queues. Leaving the inactive tail
stopped after a channel shrink caused a watchdog timeout and recovery
on the previous release candidate.
- Keep old RX statistics retired until rollback steering restoration
succeeds. Restart DIM only for RXQs actually returning from retirement,
with NAPI disabled, work cancelled and DIM reinitialized; carried RXQs
and their counters are not reset.
- Reserve live MTU/XDP replacement with channel_changing under the
existing vport_mutex through queue, fail-close and scratch cleanup.
This excludes concurrent RDMA RAW-QP vport admission without changing
early validation, no-op or down-port paths.
- Correct the full-page RX shortcut description to include all existing
early-return conditions.
Resource and control-path costs:
Full rebuilds temporarily retain both sets of SQ/RQ/CQ objects, RX buffers
and page pools. The port-owned EQ pool is shared, not doubled. Device
resource limits can reject this temporary peak; no fixed hardware queue
threshold is assumed. Allocation failure preserves the live configuration.
The pre-publication TX drain can also reject a replacement without changing
the live pointer/count/RSS configuration.
CQ retirement adds parent-EQ marker operations and RCU reader waits on the
control path; these are not free and no latency improvement is claimed.
The IRQ lookup uses an acquire load, not a new per-packet lock. This series
does not introduce a general recovery policy for failed hardware commands.
Patch layout:
1: Queue-set helpers, preserving ordinary deallocation policy.
2: Shared EQ pool and EQ/CQ publication/retirement prerequisite.
3: Port-lifetime statistics preparation.
4: First live swap, nonreset drain, RX handoff and safe TX restart.
5-8: Ring, private-flag, MTU and XDP reconfiguration.
9: Remove the unreachable detach early return.
10-11: Release unused EQs and preserve user RSS tables.
12-13: Reuse queues across channel-count reductions and increases.
Overlap with separately submitted net fixes:
The XDP pre-allocation pointer fix is subsumed by patch 8's queue-set path,
which leaves the live program unchanged during allocation:
https://lore.kernel.org/all/20260904202640.3900685-1-longli@microsoft.com/
The user-RSS-table fix overlaps patch 11. Keep the three-argument
mana_rss_table_keep() and its queue-set callers in the overlapping blocks;
the RTNL RSS requirement is shared with the standalone net submission:
https://lore.kernel.org/all/20260905004401.3937066-1-longli@microsoft.com/
Neither submission is resent as a standalone patch here. These merge
notes do not prescribe changes to unrelated net-tree code.
History:
v5: https://lore.kernel.org/all/20260909222416.884246-1-longli@microsoft.com/
v4: https://lore.kernel.org/all/20260908032843.397667-1-longli@microsoft.com/
v3: https://lore.kernel.org/all/20260901014442.2945689-1-longli@microsoft.com/
v2 repost:
https://lore.kernel.org/all/20260813050418.2906468-1-longli@microsoft.com/
v2 earlier posting:
https://lore.kernel.org/all/20260811063506.2428213-1-longli@microsoft.com/
Full-page RX predecessor (v12, not a queue-set v1):
https://lore.kernel.org/all/20260711041415.3008868-1-dipayanroy@linux.microsoft.com/
The link labelled "v1" in the old queue-set covers actually points to the
four-patch full-page RX v12 predecessor, not an earlier 13-patch queue-set
posting.
Testing:
Source/static qualification completed:
- Baseline plus all thirteen commits: 28 fresh GCC/Clang W=1 target
builds and thirteen strict checkpatch/diff checks.
- Exact-source EQ-unwind regression: both compilers expose four v6
leaks; nine cases pass at fixed patch 2 and final v7.
- Full baseline/release kernels build with identical configurations.
Sparse retains a baseline warning; Smatch retains baseline frontend
failures/diagnostics and is not counted as a clean pass.
Fresh runtime results:
- Stable baseline/release TCP and 64-byte UDP comparisons completed,
forward/reverse with three samples per workload. Supported PD/MR
and native PD/CQ/MR resource controls passed.
- VM5 completed 39 named cases across documented exact-release boots
and three original mixed-profile cycles, not a single-boot matrix.
- VM6's earlier run completed 34 cases and failed repeated cleanup.
A later exact-release run passed the four remaining XDP cases and
all three original mixed-profile cycles. The earlier failure is
retained, not relabeled as a complete matrix pass.
- Three PCI remove/rescan cycles per VM passed with concurrent
/proc/net/dev and four sysfs-stat readers, per-function resource
identity/count checks and health dwells.
- Both VMs were restored to their safe kernels and original controls,
including RSS keys, tables and default/user policy. Owned fixtures
and helpers were removed and reservations released.
- All thirteen mails also applied cleanly to net-next d0bd617658dd.
A later unmodified net-next baseline also reproduced the TX-drain failure
class, with a pending send and a matching owned TX_OKAY completion.
DIM causality and a common root cause across runs remain unproven.
That baseline-present issue is recorded for separate investigation, not
silently treated as a passed test or a demonstrated v7 regression.
No speculative driver workaround has been added.
Prior v6 sanitizer/fault and CPU-accounting results are historical,
not fresh v7 qualification. No fresh 32-bit, CDX hardware, full-locking
or general firmware-failure recovery coverage is claimed.
v6:
https://lore.kernel.org/all/cover.1790795005.git.weh@linux.microsoft.com/
Signed-off-by: Wei Hu <weh@microsoft.com>
Dipayaan Roy (1):
net: mana: do not bail out of mana_detach on dealloc failure
Long Li (12):
net: mana: add queue-set allocation and teardown helpers
net: mana: share the EQ pool across a queue-set swap
net: mana: keep per-queue statistics in the port context
net: mana: swap queue sets in mana_set_channels
net: mana: swap queue sets in mana_set_ringparam
net: mana: swap queue sets in mana_set_priv_flags
net: mana: swap queue sets in mana_change_mtu
net: mana: swap queue sets in mana_xdp_set
net: mana: release EQs left idle by a channel-count reduction
net: mana: keep a user-configured RSS table across a queue rebuild
net: mana: keep the surviving queues when the channel count is reduced
net: mana: keep the existing queues when the channel count is raised
drivers/infiniband/hw/mana/cq.c | 3 +-
.../net/ethernet/microsoft/mana/gdma_main.c | 26 +-
.../net/ethernet/microsoft/mana/hw_channel.c | 3 +-
.../net/ethernet/microsoft/mana/mana_bpf.c | 108 +-
drivers/net/ethernet/microsoft/mana/mana_en.c | 1341 +++++++++++++++--
.../ethernet/microsoft/mana/mana_ethtool.c | 313 ++--
include/net/mana/gdma.h | 8 +-
include/net/mana/mana.h | 99 +-
8 files changed, 1615 insertions(+), 286 deletions(-)
base-commit: d8674294aefef02266c4d47ad10131f1bffbe534
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu 2026-10-16 15:38 [PATCH net-next v7 00/13] net: mana: reconfigure by replacing the queue set Wei Hu @ 2026-10-16 15:38 ` Wei Hu 2026-10-17 15:39 ` sashiko-bot 0 siblings, 1 reply; 4+ messages in thread From: Wei Hu @ 2026-10-16 15:38 UTC (permalink / raw) To: longli, kotaranov, kuba, davem, pabeni, edumazet, andrew+netdev, jgg, leon, haiyangz, wei.liu, decui, shradhagupta, horms, ernis, stephen Cc: netdev, linux-rdma, linux-hyperv, linux-kernel, bpf, sdf, daniel, hawk, ast, john.fastabend, weh, edumazet From: Long Li <longli@microsoft.com> Carry the MTU in the queue set and size replacement RX buffers from it. Publish ndev->mtu after RSS configuration succeeds; allocation failure leaves the live queues and advertised MTU unchanged. This full rebuild temporarily keeps both sets of SQ/RQ/CQ objects, RX buffers and page pools live. The port-owned EQ pool is shared, not doubled. Device resource limits may reject this temporary peak; allocation failure preserves the live queues and configuration. Reserve RAW-QP admission under vport_mutex for the entire live replacement, including unpublished queues, fail-close and scratch cleanup. Preserve validation, no-op and down-port behavior. Signed-off-by: Long Li <longli@microsoft.com> Signed-off-by: Wei Hu <weh@microsoft.com> --- drivers/net/ethernet/microsoft/mana/mana_en.c | 66 ++++++++++++++----- .../ethernet/microsoft/mana/mana_ethtool.c | 10 +-- include/net/mana/mana.h | 7 +- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index c80a06ffbe50..c1ff4d9b8d45 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -956,32 +956,52 @@ int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_qu static int mana_change_mtu(struct net_device *ndev, int new_mtu) { struct mana_port_context *mpc = netdev_priv(ndev); - unsigned int old_mtu = ndev->mtu; + struct mana_port_context *scratch; + struct mana_qset newq, oldq; int err; - /* Pre-allocate buffers to prevent failure in mana_attach later */ - err = mana_pre_alloc_rxbufs(mpc, new_mtu, mpc->num_queues); - if (err) { - netdev_err(ndev, "Insufficient memory for new MTU\n"); - return err; + if (!mpc->port_is_up) { + mpc->configured_mtu = new_mtu; + WRITE_ONCE(ndev->mtu, new_mtu); + return 0; } - err = mana_detach(ndev, false); - if (err) { - netdev_err(ndev, "mana_detach failed: %d\n", err); - goto out; + /* Fail-close may release the Ethernet vport reference. */ + mutex_lock(&mpc->vport_mutex); + if (mpc->channel_changing) { + mutex_unlock(&mpc->vport_mutex); + return -EBUSY; + } + mpc->channel_changing = true; + mutex_unlock(&mpc->vport_mutex); + + scratch = mana_qset_scratch_alloc(mpc); + if (!scratch) { + err = -ENOMEM; + goto clear_flag; } - WRITE_ONCE(ndev->mtu, new_mtu); + err = mana_alloc_qset(mpc, scratch, mpc->num_queues, + mpc->rx_queue_size, mpc->tx_queue_size, + mpc->priv_flags, new_mtu, &newq); + if (err) + goto free_scratch; - err = mana_attach(ndev); + err = mana_publish_qset(mpc, &newq, &oldq); if (err) { - netdev_err(ndev, "mana_attach failed: %d\n", err); - WRITE_ONCE(ndev->mtu, old_mtu); + mana_free_qset(scratch, &newq); + goto free_scratch; } -out: - mana_pre_dealloc_rxbufs(mpc); + mana_free_qset(scratch, &oldq); + +free_scratch: + mana_publish_close_if_needed(mpc); + mana_qset_scratch_free(scratch); +clear_flag: + mutex_lock(&mpc->vport_mutex); + mpc->channel_changing = false; + mutex_unlock(&mpc->vport_mutex); return err; } @@ -3335,7 +3355,8 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc, rxq->rxq_idx = rxq_idx; rxq->rxobj = INVALID_MANA_HANDLE; - mana_get_rxbuf_cfg(apc, ndev->mtu, &rxq->datasize, &rxq->alloc_size, + mana_get_rxbuf_cfg(apc, apc->configured_mtu, &rxq->datasize, + &rxq->alloc_size, &rxq->headroom, &rxq->frag_count); /* Create page pool for RX queue */ err = mana_create_page_pool(rxq, gc); @@ -4045,6 +4066,7 @@ static void mana_qset_snapshot(const struct mana_port_context *ctx, out->rx_queue_size = ctx->rx_queue_size; out->tx_queue_size = ctx->tx_queue_size; out->priv_flags = ctx->priv_flags; + out->mtu = ctx->configured_mtu; } /* Vport identity and port debugfs outlive queue sets. */ @@ -4061,6 +4083,7 @@ static void mana_qset_install(struct mana_port_context *ctx, ctx->rx_queue_size = qset->rx_queue_size; ctx->tx_queue_size = qset->tx_queue_size; ctx->priv_flags = qset->priv_flags; + ctx->configured_mtu = qset->mtu; } /* Scratch starts without SQs/RQs and borrows the port's EQ pool. Never call @@ -4101,7 +4124,7 @@ void mana_qset_scratch_free(struct mana_port_context *scratch) int mana_alloc_qset(struct mana_port_context *apc, struct mana_port_context *scratch, unsigned int num_queues, unsigned int rx_queue_size, unsigned int tx_queue_size, - u32 priv_flags, struct mana_qset *out) + u32 priv_flags, int mtu, struct mana_qset *out) { struct net_device *ndev = scratch->ndev; int err; @@ -4113,6 +4136,8 @@ int mana_alloc_qset(struct mana_port_context *apc, scratch->tx_queue_size = tx_queue_size; scratch->priv_flags = priv_flags; + scratch->configured_mtu = mtu; + err = mana_init_port_context(scratch); if (err) goto out_err; @@ -4365,6 +4390,8 @@ int mana_publish_qset(struct mana_port_context *apc, struct mana_qset *newq, if (err) goto rollback; + WRITE_ONCE(ndev->mtu, apc->configured_mtu); + /* Publish fields before opening the gate; pair with TX/XDP read * barriers. The post-gate full barrier cannot replace this. */ @@ -4420,6 +4447,8 @@ int mana_publish_qset(struct mana_port_context *apc, struct mana_qset *newq, synchronize_net(); mana_fold_qset_rx_stats(apc, out_old); + WRITE_ONCE(ndev->mtu, apc->configured_mtu); + /* Publish restored fields before reopening the gate, as on success. */ smp_wmb(); @@ -4572,6 +4601,7 @@ static int mana_probe_port(struct mana_context *ac, int port_idx, apc->port_handle = INVALID_MANA_HANDLE; apc->pf_filter_handle = INVALID_MANA_HANDLE; apc->port_idx = port_idx; + apc->configured_mtu = ndev->mtu; apc->link_cfg_error = 1; apc->cqe_coalescing_enable = 0; apc->cqe8_coalescing_enable = 0; diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c index 9c7c9879d0aa..43575aa3a168 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -738,7 +738,8 @@ static int mana_set_channels(struct net_device *ndev, } err = mana_alloc_qset(apc, scratch, new_count, apc->rx_queue_size, - apc->tx_queue_size, apc->priv_flags, &newq); + apc->tx_queue_size, apc->priv_flags, + apc->configured_mtu, &newq); if (err) goto free_scratch; @@ -827,7 +828,7 @@ static int mana_set_ringparam(struct net_device *ndev, } err = mana_alloc_qset(apc, scratch, apc->num_queues, new_rx, new_tx, - apc->priv_flags, &newq); + apc->priv_flags, apc->configured_mtu, &newq); if (err) { NL_SET_ERR_MSG_FMT(extack, "failed to change ring params: %d", err); @@ -916,8 +917,9 @@ static int mana_set_priv_flags(struct net_device *ndev, u32 priv_flags) goto clear_flag; } - err = mana_alloc_qset(apc, scratch, apc->num_queues, apc->rx_queue_size, - apc->tx_queue_size, priv_flags, &newq); + err = mana_alloc_qset(apc, scratch, apc->num_queues, + apc->rx_queue_size, apc->tx_queue_size, + priv_flags, apc->configured_mtu, &newq); if (err) goto free_scratch; diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index 14025024acfa..60c7df78316c 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -637,6 +637,10 @@ struct mana_port_context { unsigned int rx_queue_size; unsigned int tx_queue_size; + /* MTU used to size RX buffers, independent of ndev->mtu during a swap. + */ + int configured_mtu; + mana_handle_t port_handle; mana_handle_t pf_filter_handle; @@ -713,6 +717,7 @@ struct mana_qset { unsigned int tx_queue_size; u32 priv_flags; + int mtu; }; netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev); @@ -735,7 +740,7 @@ static inline struct mana_stats_rx *mana_rxq_stats(struct mana_rxq *rxq) int mana_alloc_qset(struct mana_port_context *apc, struct mana_port_context *scratch, unsigned int num_queues, unsigned int rx_queue_size, unsigned int tx_queue_size, - u32 priv_flags, struct mana_qset *out); + u32 priv_flags, int mtu, struct mana_qset *out); int mana_publish_qset(struct mana_port_context *apc, struct mana_qset *newq, struct mana_qset *out_old); void mana_publish_close_if_needed(struct mana_port_context *apc); -- 2.43.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu 2026-10-16 15:38 ` [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu @ 2026-10-17 15:39 ` sashiko-bot 2026-10-20 4:30 ` Wei Hu 0 siblings, 1 reply; 4+ messages in thread From: sashiko-bot @ 2026-10-17 15:39 UTC (permalink / raw) To: Wei Hu; +Cc: linux-rdma, linux-hyperv, bpf Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] mana: data race on TX stats syncp in mana_xdp_xmit -- commit 03c88ebc19bffbae5acfce1a1948eb4cb597ee75 Author: Long Li <longli@microsoft.com> net: mana: swap queue sets in mana_change_mtu Carry the MTU in the queue set and size replacement RX buffers from it. Publish ndev->mtu after RSS configuration succeeds; allocation failure leaves the live queues and advertised MTU unchanged. > diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c > index 484f061bc75e4..687b9ce7d9a3b 100644 > --- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c > +++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c > @@ -68,7 +73,7 @@ int mana_xdp_xmit(struct net_device *ndev, int n, struct xdp_frame **frames, > count++; > } > > - tx_stats = &apc->tx_qp[q_idx]->txq.stats; > + tx_stats = apc->tx_qp[q_idx]->txq.stats; > > u64_stats_update_begin(&tx_stats->syncp); > tx_stats->xdp_xmit += count; [Severity: Medium] Does this stats update in mana_xdp_xmit() lack mutual exclusion when racing with other CPUs? When multiple CPUs redirect traffic via ndo_xdp_xmit, they can map to the same q_idx (since q_idx = smp_processor_id() % real_num_tx_queues) and execute u64_stats_update_begin() concurrently. This could also race with mana_start_xmit(), which updates the same per-queue syncp: > diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c > index 489558176a5de..c1ff4d9b8d45f 100644 > --- a/drivers/net/ethernet/microsoft/mana/mana_en.c > +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c > @@ -551,7 +579,7 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) > /* Populated the packet and bytes counters based on post GSO packet > * calculations > */ > - tx_stats = &txq->stats; > + tx_stats = txq->stats; > u64_stats_update_begin(&tx_stats->syncp); > tx_stats->packets += num_gso_seg; While mana_start_xmit() holds __netif_tx_lock, that lock does not protect against lockless mana_xdp_xmit() calls. On architectures where u64_stats_update_begin() uses seqcounts, could this concurrent modification corrupt the seqcount and cause readers (like mana_get_stats64()) to infinite loop or read torn values? -- Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791710735.git.weh@linux.microsoft.com?part=7 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu 2026-10-17 15:39 ` sashiko-bot @ 2026-10-20 4:30 ` Wei Hu 0 siblings, 0 replies; 4+ messages in thread From: Wei Hu @ 2026-10-20 4:30 UTC (permalink / raw) To: sashiko-reviews; +Cc: linux-rdma, linux-hyperv, bpf, netdev, weh, kuba Hi, > Does this stats update in mana_xdp_xmit() lack mutual exclusion when > racing with other CPUs? I will leave this counter update unchanged in v8. This is the same baseline lost-update issue reported on patch 4: CPUs can share a queue, and the aggregate xdp_xmit update is outside the per-frame send lock. That exclusion gap predates this series in both upstream bases. The seqcount-corruption/infinite-loop consequence requires the 32-bit u64_stats_sync implementation. Supported PCI MANA configurations are X86_64 or ARM64, and CDX requires 64BIT; their implementation has no sequence counter or fetch retry loop. The lost increments are real, but the more severe claimed consequence does not follow on those builds. Also, the submitted patch 7 does not modify mana_bpf.c. The quoted counter-pointer conversion belongs to an earlier patch in the series. Neither that conversion nor this MTU change introduces the existing writer-exclusion gap. I am keeping the independent counter fix out of v8. Thanks, Wei ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-20 16:48 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-20 16:47 [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu netdev-bot+sashiko -- strict thread matches above, loose matches on Subject: below -- 2026-10-16 15:38 [PATCH net-next v7 00/13] net: mana: reconfigure by replacing the queue set Wei Hu 2026-10-16 15:38 ` [PATCH net-next v7 07/13] net: mana: swap queue sets in mana_change_mtu Wei Hu 2026-10-17 15:39 ` sashiko-bot 2026-10-20 4:30 ` Wei Hu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox