]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA: Replace msecs_to_jiffies with secs_to_jiffies for timeout
authorPeng Jiang <jiang.peng9@zte.com.cn>
Wed, 26 Mar 2025 14:19:55 +0000 (22:19 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 7 Apr 2025 18:03:25 +0000 (15:03 -0300)
In drivers/infiniband/hw/mlx4/mcg.c and drivers/infiniband/hw/mlx5/mr.c,
`msecs_to_jiffies` is used to convert milliseconds to jiffies.
For constant milliseconds, using `msecs_to_jiffies` introduces additional
computational overhead. For example, it is unnecessary to check
if m > jiffies_to_msecs(MAX_JIFFY_OFFSET) or (int)m < 0 for constants,
while using `secs_to_jiffies` can avoid these extra calculations.

Link: https://patch.msgid.link/r/20250326221955611qu6Ix3Pt5WgKvhL6sTySX@zte.com.cn
Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>
Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx4/mcg.c

index 33f525b744f286c8db8b58407bf8efe4e5f3ed16..e279e69b9a51254b3cd03d7769b8ff4c584dd0c8 100644 (file)
@@ -43,7 +43,7 @@
 
 #define MAX_VFS                80
 #define MAX_PEND_REQS_PER_FUNC 4
-#define MAD_TIMEOUT_MS 2000
+#define MAD_TIMEOUT_SEC        2
 
 #define mcg_warn(fmt, arg...)  pr_warn("MCG WARNING: " fmt, ##arg)
 #define mcg_error(fmt, arg...) pr_err(fmt, ##arg)
@@ -270,7 +270,7 @@ static int send_join_to_wire(struct mcast_group *group, struct ib_sa_mad *sa_mad
        if (!ret) {
                /* calls mlx4_ib_mcg_timeout_handler */
                queue_delayed_work(group->demux->mcg_wq, &group->timeout_work,
-                               msecs_to_jiffies(MAD_TIMEOUT_MS));
+                                  secs_to_jiffies(MAD_TIMEOUT_SEC));
        }
 
        return ret;
@@ -309,7 +309,7 @@ static int send_leave_to_wire(struct mcast_group *group, u8 join_state)
        if (!ret) {
                /* calls mlx4_ib_mcg_timeout_handler */
                queue_delayed_work(group->demux->mcg_wq, &group->timeout_work,
-                               msecs_to_jiffies(MAD_TIMEOUT_MS));
+                                  secs_to_jiffies(MAD_TIMEOUT_SEC));
        }
 
        return ret;
@@ -1091,7 +1091,7 @@ static void _mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy
        for (i = 0; i < MAX_VFS; ++i)
                clean_vf_mcast(ctx, i);
 
-       end = jiffies + msecs_to_jiffies(MAD_TIMEOUT_MS + 3000);
+       end = jiffies + secs_to_jiffies(MAD_TIMEOUT_SEC + 3);
        do {
                count = 0;
                mutex_lock(&ctx->mcg_table_lock);