]> git.hungrycats.org Git - linux/commitdiff
IB/mlx5: Resolve soft lock on massive reg MRs
authorMoshe Lazer <moshel@mellanox.com>
Thu, 27 Oct 2016 13:36:42 +0000 (16:36 +0300)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:54:36 +0000 (03:54 +0000)
commit 6bc1a656ab9f57f0112823b4a36930c9a29d1f89 upstream.

When calling reg_mr of large MRs (e.g. 4GB) from multiple processes
and MR caches can't supply the required amount of MRs the slow-path
of MR allocation may be used. In this case we need to serialize the
slow-path between the processes to avoid soft lock.

Fixes: e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
Signed-off-by: Moshe Lazer <moshel@mellanox.com>
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/infiniband/hw/mlx5/mr.c

index f2ccf1a5a2910f92418751f2b2b4a6101da00105..61cf5f18c33a495120067988aaa5bb15b861aad4 100644 (file)
@@ -376,6 +376,8 @@ struct mlx5_ib_dev {
        struct mlx5_ib_resources        devr;
        struct mlx5_mr_cache            cache;
        struct timer_list               delay_timer;
+       /* Prevents soft lock on massive reg MRs */
+       struct mutex                    slow_path_mutex;
        int                             fill_delay;
 };
 
index afa873bd028ed5ad76f2348bbe9789b0b225b476..bf75b943bc318c8036c90844293f3727c7eb60ae 100644 (file)
@@ -554,6 +554,7 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
        int err;
        int i;
 
+       mutex_init(&dev->slow_path_mutex);
        cache->wq = create_singlethread_workqueue("mkey_cache");
        if (!cache->wq) {
                mlx5_ib_warn(dev, "failed to create work queue\n");
@@ -909,9 +910,12 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
                }
        }
 
-       if (!mr)
+       if (!mr) {
+               mutex_lock(&dev->slow_path_mutex);
                mr = reg_create(pd, virt_addr, length, umem, ncont, page_shift,
                                access_flags);
+               mutex_unlock(&dev->slow_path_mutex);
+       }
 
        if (IS_ERR(mr)) {
                err = PTR_ERR(mr);