]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
smc: Use flexible array for SMCD connections
authorRosen Penev <rosenp@gmail.com>
Tue, 19 May 2026 00:52:06 +0000 (17:52 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 May 2026 00:13:18 +0000 (17:13 -0700)
Store the per-DMB connection pointers in the SMCD device allocation
instead of allocating a separate connection array.

This keeps the connection table tied to the SMCD device lifetime and
simplifies the allocation and cleanup paths.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Link: https://patch.msgid.link/20260519005206.628071-1-rosenp@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/smc.h
net/smc/smc_ism.c

index bfdc4c41f0198b95a71b5d52ee4063c24a813dc5..a2bc3ab88075bf3d7012956e50f6f33a0ca05ec1 100644 (file)
@@ -40,7 +40,6 @@ struct smcd_dev {
        struct dibs_dev *dibs;
        struct list_head list;
        spinlock_t lock;
-       struct smc_connection **conn;
        struct list_head vlan;
        struct workqueue_struct *event_wq;
        u8 pnetid[SMC_MAX_PNETID_LEN];
@@ -50,6 +49,7 @@ struct smcd_dev {
        atomic_t lgr_cnt;
        wait_queue_head_t lgrs_deleted;
        u8 going_away : 1;
+       struct smc_connection *conn[];
 };
 
 #define SMC_HS_CTRL_NAME_MAX 16
index e0dba2c7b6e3139ebf8bf3250e71836215f99b2e..bde938c5eb3973ffd3e764d2a7f9a015c9af1d02 100644 (file)
@@ -467,17 +467,14 @@ static struct smcd_dev *smcd_alloc_dev(const char *name, int max_dmbs)
 {
        struct smcd_dev *smcd;
 
-       smcd = kzalloc_obj(*smcd);
+       smcd = kzalloc_flex(*smcd, conn, max_dmbs);
        if (!smcd)
                return NULL;
-       smcd->conn = kzalloc_objs(struct smc_connection *, max_dmbs);
-       if (!smcd->conn)
-               goto free_smcd;
 
        smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
                                                 WQ_MEM_RECLAIM, name);
        if (!smcd->event_wq)
-               goto free_conn;
+               goto free_smcd;
 
        spin_lock_init(&smcd->lock);
        spin_lock_init(&smcd->lgr_lock);
@@ -486,8 +483,6 @@ static struct smcd_dev *smcd_alloc_dev(const char *name, int max_dmbs)
        init_waitqueue_head(&smcd->lgrs_deleted);
        return smcd;
 
-free_conn:
-       kfree(smcd->conn);
 free_smcd:
        kfree(smcd);
        return NULL;
@@ -557,7 +552,6 @@ static void smcd_unregister_dev(struct dibs_dev *dibs)
        list_del_init(&smcd->list);
        mutex_unlock(&smcd_dev_list.mutex);
        destroy_workqueue(smcd->event_wq);
-       kfree(smcd->conn);
        kfree(smcd);
 }