From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 067641EB5C2; Wed, 29 Apr 2026 02:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777429030; cv=none; b=Hw3teNOm0WKNF3EoHFhPEO+O9Gj3TFu1L1BM1F1yN84kjDAMvEYDBwipidLKodp1/Dphc2annmg6ebgdQeswDwuqymn3zBB45QylXXaucx2WnJqQn1qAeWC+10wQsXzrxiY9Lc1wL8+ANh785zCoXOw8LFnHOk45G2yhZcOtm0g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777429030; c=relaxed/simple; bh=V2FQoXfu5HGEMJp0t7jIWmcfuJAWZrfh+b9gSNE/Gis=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Yw7lAmJmfIkXBo2sjOq7Z9bMmb5OY6DBdlIaAo8hHvM1Yo9sJuo/WBt5qeCh/FoOROyxKc+avQfLAQkfAS8NfzjyfVdv01nkVkMv3Xdtn5h2A4zV8qZZaX5txoemdN6wQPwVJSxpELTksW9gjpY/9ywjgJUszGIGfh3i9glSLRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=QoFJz4L1; arc=none smtp.client-ip=115.124.30.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="QoFJz4L1" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1777429023; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=N7vK4YGVGIaTJ0ADV12JN68NVGi80oWQzrH4TA+OltI=; b=QoFJz4L1C3HvpU09qJXVpJiyIVKbzL9fWjPCnS8gXt+OkiEDGwmi5EKiuKqANIOk76Q9Qv27BtXwOGRvq/G2w7d4qWQimb285yRhRzY5ClN2XqmdxDHKtnEvu/Vbbz1a7QngTsEN1UUYK0tzG9AW66cjUI/3p91U8zsEjmiLJek= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=alibuda@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0X1w.CqB_1777428997; Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0X1w.CqB_1777428997 cluster:ay36) by smtp.aliyun-inc.com; Wed, 29 Apr 2026 10:17:02 +0800 From: "D. Wythe" To: "David S. Miller" , Dust Li , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Wenjia Zhang Cc: Mahanta Jambigi , Simon Horman , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com, pasic@linux.ibm.com Subject: [PATCH net-next v3] net/smc: cap allocation order for SMC-R physically contiguous buffers Date: Wed, 29 Apr 2026 10:16:37 +0800 Message-ID: <20260429021637.21815-1-alibuda@linux.alibaba.com> X-Mailer: git-send-email 2.45.0 Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- Changes v2 -> v3: https://lore.kernel.org/netdev/20260407124337.88128-1-alibuda@linux.alibaba.com/ Remove unnecessary parentheses Changes v1 -> v2: https://lore.kernel.org/netdev/20260312082154.36971-1-alibuda@linux.alibaba.com/ --- net/smc/smc_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index e2d083daeb7e..cf6b620fef05 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) { -- 2.45.0