From: D. Wythe Date: Wed, 29 Apr 2026 02:16:37 +0000 (+0800) Subject: net/smc: cap allocation order for SMC-R physically contiguous buffers X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4cc5130ee84adcc8904772df44d64e59727c72bd;p=thirdparty%2Fkernel%2Flinux.git 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. Signed-off-by: D. Wythe Reviewed-by: Dust Li Reviewed-by: Simon Horman Reviewed-by: Sidraya Jayagond Link: https://patch.msgid.link/20260429021637.21815-1-alibuda@linux.alibaba.com Signed-off-by: Jakub Kicinski --- diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index e2d083daeb7e8..cf6b620fef05f 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -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) {