From nobody Sat Feb 7 11:31:03 2026 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (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 BD53A34D91C; Fri, 23 Jan 2026 08:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.110 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156647; cv=none; b=u19h5ZMFBLZW/ma0SUWGjmjxeO3iYvpnM2MGdaTHLrDBUaWjrZiEzoFTEya1pob0IDle3ZdcDkIaJROdeb0EU0yvVZ6oS8S0yJZMJ3MnYhNNDhI2uY8+6Z3jcwkM36kZC+3VUFoNpuZV/KYb8dlbZf8gcl6C2BLYdXGs1kPRasw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156647; c=relaxed/simple; bh=wM3JU/EQZGQCUY9DL/ap27lW5FHLzpGbQXdM7W26KpU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NChZWOWQ1YoWpIyz2vY3MhWgaPwBgsEv9jIvecD76Qsm0C7MSEPwPMqtdXw0QH5ziLhDvEiWkkbwRNWByWsP5EgwNNtXeA/f7+jBH4Z0IndUj+iINB+Gd8MPNYy3o2hRLY/Ajgy1P49v8U63r5aRhuWOjwaqPPQnsYtvfSlih5g= 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=N8UOb1xg; arc=none smtp.client-ip=115.124.30.110 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="N8UOb1xg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1769156635; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=l4ux9tDlFdT94Vxn27fx7SeIZf5wjhCyTIcjZvfwWJQ=; b=N8UOb1xgztH32QrTnJLQ0HErMKTEVypillYb5NrAbLG8ndcOQhHNa5GUXp/tWaUXBbOfNbs+VD1vFb5i1Y0P+GybToMmiESnuDDiAbyqHpWzV/RypwVcPh2RbmnhuKjZRNxA0AGfDLYQtSrrLl6WwPx+fEgjmwlXaCH9gy6mxtI= Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0Wxf8ov-_1769156634 cluster:ay36) by smtp.aliyun-inc.com; Fri, 23 Jan 2026 16:23:54 +0800 From: "D. Wythe" To: "David S. Miller" , Andrew Morton , Dust Li , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Uladzislau Rezki , Wenjia Zhang Cc: Mahanta Jambigi , Simon Horman , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com Subject: [PATCH net-next 1/3] net/smc: cap allocation order for SMC-R physically contiguous buffers Date: Fri, 23 Jan 2026 16:23:47 +0800 Message-ID: <20260123082349.42663-2-alibuda@linux.alibaba.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20260123082349.42663-1-alibuda@linux.alibaba.com> References: <20260123082349.42663-1-alibuda@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The alloc_page() 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, the allocation order is now capped to MAX_PAGE_ORDER, ensures the attempts to allocate the largest possible physically contiguous chunk instead of failing with an invalid order, which also avoid redundant "try-fail-degrade" cycles in __smc_buf_create(). For SMCR_MIXED_BUFS, If it's order exceeds MAX_PAGE_ORDER, skips the doomed physical allocation attempt and fallback to virtual memory immediately. Signed-off-by: D. Wythe Reviewed-by: Dust Li Reviewed-by: Alexandra Winter --- net/smc/smc_core.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index e4eabc83719e..6219db498976 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -2324,26 +2324,30 @@ static struct smc_buf_desc *smcr_new_buf_create(str= uct smc_link_group *lgr, if (!buf_desc) return ERR_PTR(-ENOMEM); =20 + buf_desc->order =3D get_order(bufsize); + switch (lgr->buf_type) { case SMCR_PHYS_CONT_BUFS: + buf_desc->order =3D min(buf_desc->order, MAX_PAGE_ORDER); + fallthrough; case SMCR_MIXED_BUFS: - buf_desc->order =3D get_order(bufsize); - buf_desc->pages =3D alloc_pages(GFP_KERNEL | __GFP_NOWARN | - __GFP_NOMEMALLOC | __GFP_COMP | - __GFP_NORETRY | __GFP_ZERO, - buf_desc->order); - if (buf_desc->pages) { - buf_desc->cpu_addr =3D - (void *)page_address(buf_desc->pages); - buf_desc->len =3D bufsize; - buf_desc->is_vm =3D false; - break; + if (buf_desc->order <=3D MAX_PAGE_ORDER) { + buf_desc->pages =3D alloc_pages(GFP_KERNEL | __GFP_NOWARN | + __GFP_NOMEMALLOC | __GFP_COMP | + __GFP_NORETRY | __GFP_ZERO, + buf_desc->order); + if (buf_desc->pages) { + buf_desc->cpu_addr =3D + (void *)page_address(buf_desc->pages); + buf_desc->len =3D bufsize; + buf_desc->is_vm =3D false; + break; + } } if (lgr->buf_type =3D=3D SMCR_PHYS_CONT_BUFS) goto out; fallthrough; // try virtually contiguous buf case SMCR_VIRT_CONT_BUFS: - buf_desc->order =3D get_order(bufsize); buf_desc->cpu_addr =3D vzalloc(PAGE_SIZE << buf_desc->order); if (!buf_desc->cpu_addr) goto out; --=20 2.45.0 From nobody Sat Feb 7 11:31:03 2026 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (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 570A32EDD52; Fri, 23 Jan 2026 08:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156641; cv=none; b=BvqBxZW6wbDvz1C4YIz/W7j/0H3zZ9cKHJA6C5eJAXvBw7Uxg6+IZ+yA0bu0jfm5BKNVieYGMwoxwtke8XCRa53WaPFyFUnVlIeiPKadO9hKBvoXb9OG0ZuaN94l+QrACbTLk5B9u/66VuGocEU0+pESJ39hbORIcNI106E5jz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156641; c=relaxed/simple; bh=12BYwHefeCHvg6DzgrKy0FPgd9W5v3eEwpoFFWFX9Rk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jbiYhHaiOViPayADtMY+CWmGJrAwR+S6iRQHoO/Nu++HeInlnf9elKK/X/tZCCNhC3GahVLvkDNf8JpKpuQU6rczR7VjcUTFdZMVxBAF4+ssIvp1zxr6eg9F0KsmthfpQRdm7NEwI2qiFdrsym2jKQQrErsZaX3OgKJTlPqwGE0= 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=iThvwSmC; arc=none smtp.client-ip=115.124.30.99 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="iThvwSmC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1769156636; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=hBm0JDk7EhK8byASx/pot4VMZ/7c5vuPMnvsfOBUnCE=; b=iThvwSmCe9zTcBWIDB1rbrn1vrh94TL4bCYPVBTMxdUevCygeT6x8Ap5G17RYKMSlLRReGp2R8UqAnE7phsCgTiYhai58xbGeG+AmPziVjMEAehhoKQ657R1jkugzvEFLqyzGslvoDW0kLkkC43dLSCFwvE7a6wH59MhfBxNdaI= Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0Wxf8ovm_1769156634 cluster:ay36) by smtp.aliyun-inc.com; Fri, 23 Jan 2026 16:23:55 +0800 From: "D. Wythe" To: "David S. Miller" , Andrew Morton , Dust Li , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Uladzislau Rezki , Wenjia Zhang Cc: Mahanta Jambigi , Simon Horman , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com Subject: [PATCH net-next 2/3] mm: vmalloc: export find_vm_area() Date: Fri, 23 Jan 2026 16:23:48 +0800 Message-ID: <20260123082349.42663-3-alibuda@linux.alibaba.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20260123082349.42663-1-alibuda@linux.alibaba.com> References: <20260123082349.42663-1-alibuda@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" find_vm_area() provides a way to find the vm_struct associated with a virtual address. Export this symbol to modules so that modularized subsystems can perform lookups on vmalloc addresses. Signed-off-by: D. Wythe --- mm/vmalloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ecbac900c35f..3eb9fe761c34 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -3292,6 +3292,7 @@ struct vm_struct *find_vm_area(const void *addr) =20 return va->vm; } +EXPORT_SYMBOL_GPL(find_vm_area); =20 /** * remove_vm_area - find and remove a continuous kernel virtual area --=20 2.45.0 From nobody Sat Feb 7 11:31:03 2026 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 A15A63195FD; Fri, 23 Jan 2026 08:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156641; cv=none; b=lwhvBZRzFVTXzx52ttfzUF+O6RcgPY69xTTmkzq2Q2Y9R6bhr7k3QtY8yggeiqVlHJ9LGxfu2kibeGEpHzoVv6E9xBvf6+Kgcc+Qk6W6dz7UypK0K6zlUST324pPImFfBa92ZjVPuLz86CnEjW+kNRKQVhJ9FSlcfoNVOQWOc8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769156641; c=relaxed/simple; bh=59DKB/VaktxKecnGsajFsV8KKJSNeWl2YpkeV1l9kvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g3EOrZjsRbsS0vpNTcqYaswWCB1KKG6Rzl8gmPTwes9aftDh54U6tdI6W9ViLW+8cXuob3/z+orlI11bGkGugWG3IbnHA2AxmsiVT/SSg+W+lpqYI8v8XqI6fCB8bTp+mzA0bJz4E6CoQFKDZz2E4nksDnzyGnf45dyGp6lZmo0= 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=dDKh9u0C; arc=none smtp.client-ip=115.124.30.118 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="dDKh9u0C" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1769156636; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=S1bjNuHUrGPdJip9CidbGVSG4Xe7mlDtcxJDAR5+R0s=; b=dDKh9u0C2/6CwA61LrupXXv7Iy8pKePZelbPzySVA39rNQJRFjJE7V4BrYqqPubDuGQxVqyM0Wsirsj1KSDB8Y3DZRG0jWfjuJWAUZdOigZ8kKxiaITif+c6vOzEbcks7QykzA/M6Fcnh0ElS9r08rcO5c5HaswE+gOqtuhpHCY= Received: from j66a10360.sqa.eu95.tbsite.net(mailfrom:alibuda@linux.alibaba.com fp:SMTPD_---0Wxf8owG_1769156635 cluster:ay36) by smtp.aliyun-inc.com; Fri, 23 Jan 2026 16:23:55 +0800 From: "D. Wythe" To: "David S. Miller" , Andrew Morton , Dust Li , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Uladzislau Rezki , Wenjia Zhang Cc: Mahanta Jambigi , Simon Horman , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com Subject: [PATCH net-next 3/3] net/smc: optimize MTTE consumption for SMC-R buffers Date: Fri, 23 Jan 2026 16:23:49 +0800 Message-ID: <20260123082349.42663-4-alibuda@linux.alibaba.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20260123082349.42663-1-alibuda@linux.alibaba.com> References: <20260123082349.42663-1-alibuda@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" SMC-R buffers currently use 4KB page mapping for IB registration. Each page consumes one MTTE, which is inefficient and quickly depletes limited IB hardware resources for large buffers. For virtual contiguous buffer, switch to vmalloc_huge() to leverage huge page support. By using larger page sizes during IB MR registration, we can drastically reduce MTTE consumption. For physically contiguous buffer, the entire buffer now requires only one single MTTE. Signed-off-by: D. Wythe Reviewed-by: Dust Li --- net/smc/smc_core.c | 3 ++- net/smc/smc_ib.c | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 6219db498976..8aca5dc54be7 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -2348,7 +2348,8 @@ static struct smc_buf_desc *smcr_new_buf_create(struc= t smc_link_group *lgr, goto out; fallthrough; // try virtually contiguous buf case SMCR_VIRT_CONT_BUFS: - buf_desc->cpu_addr =3D vzalloc(PAGE_SIZE << buf_desc->order); + buf_desc->cpu_addr =3D vmalloc_huge(PAGE_SIZE << buf_desc->order, + GFP_KERNEL | __GFP_ZERO); if (!buf_desc->cpu_addr) goto out; buf_desc->pages =3D NULL; diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index 1154907c5c05..67211d44a1db 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include =20 @@ -697,6 +698,18 @@ void smc_ib_put_memory_region(struct ib_mr *mr) ib_dereg_mr(mr); } =20 +static inline int smc_buf_get_vm_page_order(struct smc_buf_desc *buf_slot) +{ +#ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC + struct vm_struct *vm; + + vm =3D find_vm_area(buf_slot->cpu_addr); + return vm ? vm->page_order : 0; +#else + return 0; +#endif +} + static int smc_ib_map_mr_sg(struct smc_buf_desc *buf_slot, u8 link_idx) { unsigned int offset =3D 0; @@ -706,8 +719,9 @@ static int smc_ib_map_mr_sg(struct smc_buf_desc *buf_sl= ot, u8 link_idx) sg_num =3D ib_map_mr_sg(buf_slot->mr[link_idx], buf_slot->sgt[link_idx].sgl, buf_slot->sgt[link_idx].orig_nents, - &offset, PAGE_SIZE); - + &offset, + buf_slot->is_vm ? PAGE_SIZE << smc_buf_get_vm_page_order(buf_slot= ) : + PAGE_SIZE << buf_slot->order); return sg_num; } =20 @@ -719,7 +733,10 @@ int smc_ib_get_memory_region(struct ib_pd *pd, int acc= ess_flags, return 0; /* already done */ =20 buf_slot->mr[link_idx] =3D - ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, 1 << buf_slot->order); + ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, + buf_slot->is_vm ? + 1 << (buf_slot->order - smc_buf_get_vm_page_order(buf_slot)) : 1); + if (IS_ERR(buf_slot->mr[link_idx])) { int rc; =20 --=20 2.45.0