From nobody Sat Jul 25 22:03:05 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 58DAF369991; Mon, 13 Jul 2026 07:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927050; cv=none; b=fHlr67kFmGJgLnAcuBFNNqNE3y2IQ8AwS9lXMP36Hie+bnLVPoHsEbfVwa4S7TC+zPVD+hpdg3v4uFuRfSnIqs6Q4yDDBN2dynZdnPt1a2suePQiaWq9Id37rn6Lzch4wHrLqLZ2LshIsxFLpGyTgFGY2pC7vApU6KDgFii+BJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927050; c=relaxed/simple; bh=LzIP6fu0a/gDtXYl3FhLJ6KZZBXl115F0W3SEbdUqaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UZbJd/5G+BqovHPOpZgQV1ack0vZUSjPWolNYz9ZT7LMlRFBH+5xFDgpU+6yqyKycMHeidPsQEScPoIh15dyJTEOyqxzxL9oZ377eJZTKXVowk88hn8TMsqpzUqzUB+r3OsmnOXJviBJ3oW6+YbktNbOC2rqMj91EIPYpVD49B8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mK7Rs7Ep; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mK7Rs7Ep" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44AE91F00A3A; Mon, 13 Jul 2026 07:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783927048; bh=uWIVcjeEM70jyTaGHVgY1Rp3qpXgQEqVNmxGrIcRzKo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mK7Rs7Ep2oHn7rc1lfqFdey6hB435+rCXTeAcd4DVnnNK0XLMIaVlziT5O8hxIvLb UvjsqfP7CFqucFochDH4MO8liVKybOtB/MpvIkXF+UXRbIdgeK5cyqUJ23NnezYe4k 1CyVypk/ieWMmRUqBFK48kK+DdRpdDp14sqrdYo7aQhAIAwJExbfxbbxW9eBWrDNWI yQ/587Sxd9rWeCacocCogH4nCaJSoq3zF4NEinV+4c66JO63tYnA1exxwVPjupPzgJ re/RsnjkCnKo2BIVPEM1vSW/Y6wuKAs+uGaXcOHdG0ZdZELLsioRWTsSlTTuBeq5Sy lX2LdrbLdp/4w== From: "Mike Rapoport (Microsoft)" Date: Mon, 13 Jul 2026 10:17:22 +0300 Subject: [PATCH v2 1/5] RDMA/umem: ib_umem_get(): use kmalloc() to allocate page array Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-rdma-v2-1-65d2a1a5180c@kernel.org> References: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> In-Reply-To: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> To: Jason Gunthorpe , Leon Romanovsky Cc: Dennis Dalessandro , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org X-Mailer: b4 0.16-dev ib_umem_get() allocates an array of pointers to struct page for pin_user_pages_fast() calls during memory registration. This array can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- drivers/infiniband/core/umem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 73498723a5d5..81f44dadfa52 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -209,7 +209,8 @@ static struct ib_umem *__ib_umem_get_va(struct ib_devic= e *device, =20 mmgrab(mm); =20 - page_list =3D (struct page **) __get_free_page(GFP_KERNEL); + /* TODO: switch to "fast and as large as possible" allocation helper */ + page_list =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!page_list) { ret =3D -ENOMEM; goto umem_kfree; @@ -269,7 +270,7 @@ static struct ib_umem *__ib_umem_get_va(struct ib_devic= e *device, __ib_umem_release(device, umem, 0); atomic64_sub(ib_umem_num_pages(umem), &mm->pinned_vm); out: - free_page((unsigned long) page_list); + kfree(page_list); umem_kfree: if (ret) { mmdrop(umem->owning_mm); --=20 2.53.0 From nobody Sat Jul 25 22:03:05 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 7197236E467; Mon, 13 Jul 2026 07:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927052; cv=none; b=lDCFWksf5bl7eErELXj1fQYAPqkC2dfTKCam086YNuJJVQER6LElQnP3yS8aNzCVsPZuiceruby8KzHWTPTSRL1oN8JZWSFaH8/n3jgYIAFympcwytsYujzXPyBG+0ElmXqBnqoOuY2D/LB7Zbi5bLb63F1j9jXEqCOFDh1Q6zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927052; c=relaxed/simple; bh=SXrz9gchSpYbNkqOo4zo2EfPrNrBLWlpKsoescdSehw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lPVWyn4wI0oon2IFDdxpA/BsIgMmZD5rMeZv5o4YwUTkvzTZE3CM57BWB9CkV4QNh9ys8s4bNz9zXAkGZx57mFa4o6u0uPSQlI0cFiGOB8Wn+pNLfGzuAlpSabv2LXHnNVWYQ150SRlSAso9ISzLTPNtNBW209GE2G++smAIL6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ejTfvo5h; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ejTfvo5h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65B741F00A3D; Mon, 13 Jul 2026 07:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783927051; bh=B1vEwrB73ps6zpLh3UcDtCf1sAnjTUd+qckbQEIzKaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ejTfvo5hBO6cSEnRbHpIIW/r22KHDES61igHJDW9ZcPA2O0kGD7LJzCU75DARdwwL 2KKztVnHkqEkPpICH2r2dv+eK3rNrm0XuDve2vTjNlSgsJELEkgk/xYMTkSOhSpz3i nwmH/Wa5cahWTKWCT3+NHbM+diM2aQ4m7SeDyyvui0u4QVHGU6x83GxgNbMC1LsShl BZ43fDIe1DCtUQEKZQS/ryg1QvTEwQ9YXzh4WqiUgQUglFJ8WQeF6Zp9J4OxS2TWU9 K3S+ormK2fzUIr5b7aGnjP8909gAZjCenA7vvD2vHLiBYLNbFGCqcjK/Ua2u5QmNIt 6xwFaVqslyccw== From: "Mike Rapoport (Microsoft)" Date: Mon, 13 Jul 2026 10:17:23 +0300 Subject: [PATCH v2 2/5] RDMA/mlx5: replace __get_free_page() with kmalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-rdma-v2-2-65d2a1a5180c@kernel.org> References: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> In-Reply-To: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> To: Jason Gunthorpe , Leon Romanovsky Cc: Dennis Dalessandro , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org X-Mailer: b4 0.16-dev mlx5_ib_mr_wqe_pfault_handler() allocates a scratch buffer for parsing work queue entries during page fault handling. This buffer can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- drivers/infiniband/hw/mlx5/odp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/= odp.c index 1badec9bf527..b8618610737a 100644 --- a/drivers/infiniband/hw/mlx5/odp.c +++ b/drivers/infiniband/hw/mlx5/odp.c @@ -37,6 +37,7 @@ #include #include #include +#include =20 #include "mlx5_ib.h" #include "cmd.h" @@ -1414,7 +1415,8 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5= _ib_dev *dev, goto resolve_page_fault; } =20 - wqe_start =3D (void *)__get_free_page(GFP_KERNEL); + /* TODO: switch to "fast and as large as possible" allocation helper */ + wqe_start =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!wqe_start) { mlx5_ib_err(dev, "Error allocating memory for IO page fault handling.\n"= ); goto resolve_page_fault; @@ -1475,7 +1477,7 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5= _ib_dev *dev, pfault->wqe.wq_num, resume_with_error, pfault->type); mlx5_core_res_put(res); - free_page((unsigned long)wqe_start); + kfree(wqe_start); } =20 static void mlx5_ib_mr_rdma_pfault_handler(struct mlx5_ib_dev *dev, --=20 2.53.0 From nobody Sat Jul 25 22:03:05 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 59A89367B7B; Mon, 13 Jul 2026 07:17:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927054; cv=none; b=qN7ph7hQxpD4V9dPwjyD5dd7f1zQLS0QLUNzdtPszfnFgL6cweQfqUH02CPY3vkdcJdccPIWwm7XePoejDMQLqjj39NVE9eIoNS7+Ix8Qw6OQWIbWY8l9M38JbLCzFSdRh9dVRXkLO0pRJb0wP5kVJcbe4H4OB1z+U4T/LZSk4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927054; c=relaxed/simple; bh=dU8D4V8tvsrJySrwR2gVQPb9mt0ZOvQF8iVTdyhEZdQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jolRQPoryNAo3X4kOSD2LMgHsQA5YEUHSN6P28OUHAPGHRTFxdHqgYenARdqdiQxpUoSswf9Yg1HOWrWU4mDJJTWCJ275UXqA2rbbzFx1SAVqV/Ds1vfopIhQ/omLHUK3BISgnsEfPupj+AKTtNmd8OXPkxV8PQ3R7ogXaeJja0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mVklzPwn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mVklzPwn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 864261F00A3A; Mon, 13 Jul 2026 07:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783927053; bh=N1GD0Oj81wk33gSXNYFk26bc8DHHpPqcq8HMI+cgJUQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mVklzPwnjtBYd+N3Q1NTXm8l+G32kSV0uADFNMVZ8zoEX2vISW7RRd4d/NPd12JOh DzxIKDw/Yt++8V/vrQHUfVzIi6FQ5tiWtLY0oMeG9eE25+rSnBmB6k1lqEcHp3Ko+M SDTuufoH7QqmiMlseyEIUUScT72Gq+35ghE6HXuXL0Y8HPFf0//qsgaGGQ5PsrymfU RkhBMQlqCLUqscttXvtCJU/wbAbnoqr29BiiAi1Q53EE56nvDVnArYJIWay2NOIyLo Y5h+aMGGNZPCE5Q1kaPFlT+G2B17cd8C2zP+4/u0Q7m3D7ITJXHilhhJh96jwlzB/g qT0T1CnxHBwHg== From: "Mike Rapoport (Microsoft)" Date: Mon, 13 Jul 2026 10:17:24 +0300 Subject: [PATCH v2 3/5] IB/mthca: mthca_reg_user_mr(): use kmalloc() to allocate addresses array Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-rdma-v2-3-65d2a1a5180c@kernel.org> References: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> In-Reply-To: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> To: Jason Gunthorpe , Leon Romanovsky Cc: Dennis Dalessandro , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org X-Mailer: b4 0.16-dev mthca_reg_user_mr() allocates an array of DMA addresses during memory registration. This buffer can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kmalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- drivers/infiniband/hw/mthca/mthca_provider.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infinib= and/hw/mthca/mthca_provider.c index f90f67afc8fa..9940165781e1 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c @@ -895,7 +895,8 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd= , u64 start, u64 length, goto err_umem; } =20 - pages =3D (u64 *) __get_free_page(GFP_KERNEL); + /* TODO: switch to "fast and as large as possible" allocation helper */ + pages =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (!pages) { err =3D -ENOMEM; goto err_mtt; @@ -924,7 +925,7 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd= , u64 start, u64 length, if (i) err =3D mthca_write_mtt(dev, mr->mtt, n, pages, i); mtt_done: - free_page((unsigned long) pages); + kfree(pages); if (err) goto err_mtt; =20 --=20 2.53.0 From nobody Sat Jul 25 22:03:05 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9E707381AE2; Mon, 13 Jul 2026 07:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927056; cv=none; b=ifPkwdZ/3/cs3/rZy0g1GVQANxFoQ+3oVni+b4AMt22pNYY7zhnp/2adGptH54Uf1k3hTwyfCr432S/VsjeOm3KJ041cZZQoovT6jl2xUAh8DTE9KNoiCXf+7hY7F9yAUY7iAp/KeMPbl3xNEe6tOsQ9w2oiePzHwql5UT6zXUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927056; c=relaxed/simple; bh=ZnUyjYJQ9FcxnRevoO+HwNPLSapZWFHPNg2h7hIMPmE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WzGAd7KNZsTC3DMb1ZUd5PyLSOLfgk8Myv7SFswBHbMFvCHlS2GV/BjO7/AJXFTV/eKDCWl4QwlGb2+GPudMvIxlJtyUqPrzqj/G8jOib/02r2tpDxe0IzpNazdUbihaJ9aIZAM4MlxITh3fvcRLRTVInLCOJQ825/509KmRNBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IEu/n99Q; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IEu/n99Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A64671F00A3D; Mon, 13 Jul 2026 07:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783927055; bh=KFYeKargova8Ud8wjAeX+s1i+b6lKR01HyMHcvbV2VQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=IEu/n99QuYXkErMNPS34wGG3wPAoz82f+IKjx411LSqg1hg5PAvx1ZTiomc+LcMEa 0mLgjz4z8EU3xipYaZCuZ7XzAsbHNzfCpwM9Y9UA/WuFfE/uemo+5ng3eVB31CHKPE INQF5CBkEc0Sqq/F/wtcEU3xoJp5eCIypyNFGX0u+b2QPeBVQ1pttYlvIMwS5cz3DP 0A7IEOLI6EfULdREoJj4q33cmplEHixakuAkPYaRsrViOhQxf99BE+Y1NFufAZQAfI NjldmWm1CyhuI4njvRw1N1JSf9S8OcrwlTcqcoO+XkiksVyvUi7zuykHoajCIvxTBJ 8UXFi9SMQftrw== From: "Mike Rapoport (Microsoft)" Date: Mon, 13 Jul 2026 10:17:25 +0300 Subject: [PATCH v2 4/5] IB/mthca: allocate mthca_array memory with kzalloc() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-rdma-v2-4-65d2a1a5180c@kernel.org> References: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> In-Reply-To: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> To: Jason Gunthorpe , Leon Romanovsky Cc: Dennis Dalessandro , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org X-Mailer: b4 0.16-dev mthca_array is essentially a sparse array of pointers and there is no need to allocate its memory using page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of get_zeroed_page() with kzalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- drivers/infiniband/hw/mthca/mthca_allocator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infini= band/hw/mthca/mthca_allocator.c index dedc301235a0..117a070e784e 100644 --- a/drivers/infiniband/hw/mthca/mthca_allocator.c +++ b/drivers/infiniband/hw/mthca/mthca_allocator.c @@ -126,7 +126,7 @@ int mthca_array_set(struct mthca_array *array, int inde= x, void *value) =20 /* Allocate with GFP_ATOMIC because we'll be called with locks held. */ if (!array->page_list[p].page) - array->page_list[p].page =3D (void **) get_zeroed_page(GFP_ATOMIC); + array->page_list[p].page =3D kzalloc(PAGE_SIZE, GFP_ATOMIC); =20 if (!array->page_list[p].page) return -ENOMEM; @@ -142,7 +142,7 @@ void mthca_array_clear(struct mthca_array *array, int i= ndex) int p =3D (index * sizeof (void *)) >> PAGE_SHIFT; =20 if (--array->page_list[p].used =3D=3D 0) { - free_page((unsigned long) array->page_list[p].page); + kfree(array->page_list[p].page); array->page_list[p].page =3D NULL; } else array->page_list[p].page[index & MTHCA_ARRAY_MASK] =3D NULL; @@ -174,7 +174,7 @@ void mthca_array_cleanup(struct mthca_array *array, int= nent) int i; =20 for (i =3D 0; i < (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE; += +i) - free_page((unsigned long) array->page_list[i].page); + kfree(array->page_list[i].page); =20 kfree(array->page_list); } --=20 2.53.0 From nobody Sat Jul 25 22:03:05 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A32E2389DF0; Mon, 13 Jul 2026 07:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927058; cv=none; b=CwWJnZRGENSpTKpkQezoPF7otabZep1LQnH7xDiknyQurpUqPbNAK7nu4jG4dMQor872F1lqSE0uXNWZuoLJkQB+/KAYEF2SHChk1/kIYThCo9e7Jw5H28w17VLgXR2twYaRrsBB+Mx+xl2hs3wweuiLsc4vFkTZ4Rx/SPNoXlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927058; c=relaxed/simple; bh=d2PjGOPWCKsDBhAPZ5RLuCJg2M92mnw/3ry5e803xJk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ixGrtNyV6g0W+hedPCAKy2wIsDCstdF3GrXQdpeb/c+HQlN25X2XshQn+olj2lR0exXgUsj2r5Aqtpbqr7SZrws/vp5whKcXzeD+du5KBBc+sg2NgR7DcksroRQ30iNxh8N2sFu24r9DZj8vwQLflZOD8Qvd8rbjJIKVfhSkBYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c9FME1wu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c9FME1wu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C64831F000E9; Mon, 13 Jul 2026 07:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783927057; bh=Hwd078SfSbWqZ8yo3wjpm66Fjg9WDFy+fTRvcAm+UkM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=c9FME1wuvshe3JefH5fc97yCGfSFLGlyfQzbOqHbZMegRzb6k0zRSqdoNrDOGZ2zb 3X2+AdpAPwaU7vPT+62vsFrLJjiYMLudeaBWOkEBsbpYvs0rR1bSH9GzMkF1OAIG5P H6X29dIgl++yuwSSuhWdv+BllCwsbq0v+JtdUSdonTMSP7LmtSgLmBGNCIkKeCcX6i 65wvtmHS5YiG/T+pbng49tkH8CimMMrTJ8QK4prOID/vFKcuv0pMP1huakRgLsIDwK ybdD81PM9GOz/IsGRk2VbWGO6DhdFIX2++f+da0P+mi6dBYZHaPfM6/tZ8HT2VO0pm Gg/Zfvl3jAXQQ== From: "Mike Rapoport (Microsoft)" Date: Mon, 13 Jul 2026 10:17:26 +0300 Subject: [PATCH v2 5/5] IB/rdmavt: use kzalloc() to allocate QPN-map pages Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260713-b4-rdma-v2-5-65d2a1a5180c@kernel.org> References: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> In-Reply-To: <20260713-b4-rdma-v2-0-65d2a1a5180c@kernel.org> To: Jason Gunthorpe , Leon Romanovsky Cc: Dennis Dalessandro , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org X-Mailer: b4 0.16-dev get_map_page() allocates bitmap pages using get_zeroed_page(). The bitmaps can be allocated with kmalloc() as there's nothing special about them to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of get_zeroed_page() with kzalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) --- drivers/infiniband/sw/rdmavt/qp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdma= vt/qp.c index 70e7d08fdce6..c40cce69e945 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c @@ -263,7 +263,7 @@ static inline bool wss_exceeds_threshold(struct rvt_wss= *wss) static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map) { - unsigned long page =3D get_zeroed_page(GFP_KERNEL); + void *page =3D kzalloc(PAGE_SIZE, GFP_KERNEL); =20 /* * Free the page if someone raced with us installing it. @@ -271,9 +271,9 @@ static void get_map_page(struct rvt_qpn_table *qpt, =20 spin_lock(&qpt->lock); if (map->page) - free_page(page); + kfree(page); else - map->page =3D (void *)page; + map->page =3D page; spin_unlock(&qpt->lock); } =20 @@ -343,7 +343,7 @@ static void free_qpn_table(struct rvt_qpn_table *qpt) int i; =20 for (i =3D 0; i < ARRAY_SIZE(qpt->map); i++) - free_page((unsigned long)qpt->map[i].page); + kfree(qpt->map[i].page); } =20 /** --=20 2.53.0