Skip to contentSkip to conversation

net/smc: cap allocation order for SMC-R physically contiguous buffers

PATCH Applied D. Wythe 2 participants 2 messages Apr 29 – May 1

Subsystems (5)
lore
Share & tools
lore

D. Wythe

author maintainer
#0 lore raw

PATCH v3 1/1 net/smc: cap allocation order for SMC-R physically contiguous buffers

The alloc_pages() cannot satisfy requests exceeding MAX_PAGE_ORDER, and attempting such allocations will lead to guaranteed failures and potential kernel warnings.

For SMCR_PHYS_CONT_BUFS, cap the allocation order to MAX_PAGE_ORDER. This ensures the attempts to allocate the largest possible physically contiguous chunk succeed, instead of failing with an invalid order. This also avoids redundant "try-fail-degrade" cycles in __smc_buf_create().

For SMCR_MIXED_BUFS, no cap is needed: if the order exceeds MAX_PAGE_ORDER, alloc_pages() will silently fail (__GFP_NOWARN) and automatically fall back to virtual memory.

---
Changes v2 -> v3:
https://lore.kernel.org/netdev/[email protected]/
Remove unnecessary parentheses
Changes v1 -> v2:
https://lore.kernel.org/netdev/[email protected]/

---
 net/smc/smc_core.c | 4 ++++
 1 file changed, 4 insertions(+)
net/smc/smc_core.c +4 -0
index e2d083daeb7e..cf6b620fef05 100644
@@ -2440,6 +2440,10 @@ static int __smc_buf_create(struct smc_sock *smc, bool is_smcd, bool is_rmb)
 		/* use socket send buffer size (w/o overhead) as start value */
 		bufsize = smc->sk.sk_sndbuf / 2;
 
+	/* limit bufsize for physically contiguous buffers */
+	if (!is_smcd && lgr->buf_type == SMCR_PHYS_CONT_BUFS)
+		bufsize = min_t(int, bufsize, PAGE_SIZE << MAX_PAGE_ORDER);
+
 	for (bufsize_comp = smc_compress_bufsize(bufsize, is_smcd, is_rmb);
 	     bufsize_comp >= 0; bufsize_comp--) {
 		if (is_rmb) {
Signature · 1 line
2.45.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 29 Apr 2026 10:16:37 +0800 you wrote:

The alloc_pages() cannot satisfy requests exceeding MAX_PAGE_ORDER, and attempting such allocations will lead to guaranteed failures and potential kernel warnings.

For SMCR_PHYS_CONT_BUFS, cap the allocation order to MAX_PAGE_ORDER. This ensures the attempts to allocate the largest possible physically contiguous chunk succeed, instead of failing with an invalid order. This also avoids redundant "try-fail-degrade" cycles in __smc_buf_create().

[...]

Here is the summary with links:
- [net-next,v3] net/smc: cap allocation order for SMC-R physically contiguous buffers

    https://git.kernel.org/netdev/net-next/c/4cc5130ee84a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html