netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/smc: Use kvzalloc for allocating smc_link_group
@ 2022-01-20 14:09 Tony Lu
  2022-01-20 14:50 ` Karsten Graul
  0 siblings, 1 reply; 6+ messages in thread
From: Tony Lu @ 2022-01-20 14:09 UTC (permalink / raw)
  To: kgraul; +Cc: kuba, davem, netdev, linux-s390

When analyzed memory usage of SMC, we found that the size of struct
smc_link_group is 16048 bytes, which is too big for a busy machine to
allocate contiguous memory. Using kvzalloc instead that falls back to
vmalloc if there has not enough contiguous memory.

Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
---
 net/smc/smc_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 8935ef4811b0..a5024b098540 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -828,7 +828,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
 		}
 	}
 
-	lgr = kzalloc(sizeof(*lgr), GFP_KERNEL);
+	lgr = kvzalloc(sizeof(*lgr), GFP_KERNEL);
 	if (!lgr) {
 		rc = SMC_CLC_DECL_MEM;
 		goto ism_put_vlan;
@@ -914,7 +914,7 @@ static int smc_lgr_create(struct smc_sock *smc, struct smc_init_info *ini)
 free_wq:
 	destroy_workqueue(lgr->tx_wq);
 free_lgr:
-	kfree(lgr);
+	kvfree(lgr);
 ism_put_vlan:
 	if (ini->is_smcd && ini->vlan_id)
 		smc_ism_put_vlan(ini->ism_dev[ini->ism_selected], ini->vlan_id);
@@ -1317,7 +1317,7 @@ static void smc_lgr_free(struct smc_link_group *lgr)
 		if (!atomic_dec_return(&lgr_cnt))
 			wake_up(&lgrs_deleted);
 	}
-	kfree(lgr);
+	kvfree(lgr);
 }
 
 static void smc_sk_wake_ups(struct smc_sock *smc)
-- 
2.32.0.3.g01195cf9f


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-27 15:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20 14:09 [PATCH net-next] net/smc: Use kvzalloc for allocating smc_link_group Tony Lu
2022-01-20 14:50 ` Karsten Graul
2022-01-21  3:24   ` Tony Lu
2022-01-21 11:06     ` Karsten Graul
2022-01-24  9:46       ` Tony Lu
2022-01-27 15:28         ` Karsten Graul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).