]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/core: Add FRMR pools statistics
authorMichael Guralnik <michaelgur@nvidia.com>
Thu, 26 Feb 2026 13:52:09 +0000 (15:52 +0200)
committerLeon Romanovsky <leon@kernel.org>
Mon, 2 Mar 2026 18:45:10 +0000 (13:45 -0500)
Count for each pool the number of FRMR handles popped and held by user
MRs.
Also keep track of the max value of this counter.

Next patches will expose the statistics through netlink.

Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Link: https://patch.msgid.link/20260226-frmr_pools-v4-4-95360b54f15e@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/frmr_pools.c
drivers/infiniband/core/frmr_pools.h

index 1be7253d7afd2c7f897dfbec6077daafe4f4fab3..5a9c60f19e4e1b6d39a86cf7560170633a9eb99c 100644 (file)
@@ -310,19 +310,24 @@ static int get_frmr_from_pool(struct ib_device *device,
                if (pool->inactive_queue.ci > 0) {
                        handle = pop_handle_from_queue_locked(
                                &pool->inactive_queue);
-                       spin_unlock(&pool->lock);
                } else {
                        spin_unlock(&pool->lock);
                        err = pools->pool_ops->create_frmrs(device, &pool->key,
                                                            &handle, 1);
                        if (err)
                                return err;
+                       spin_lock(&pool->lock);
                }
        } else {
                handle = pop_handle_from_queue_locked(&pool->queue);
-               spin_unlock(&pool->lock);
        }
 
+       pool->in_use++;
+       if (pool->in_use > pool->max_in_use)
+               pool->max_in_use = pool->in_use;
+
+       spin_unlock(&pool->lock);
+
        mr->frmr.pool = pool;
        mr->frmr.handle = handle;
 
@@ -374,6 +379,9 @@ int ib_frmr_pool_push(struct ib_device *device, struct ib_mr *mr)
        if (pool->queue.ci == 0)
                schedule_aging = true;
        ret = push_handle_to_queue_locked(&pool->queue, mr->frmr.handle);
+       if (ret == 0)
+               pool->in_use--;
+
        spin_unlock(&pool->lock);
 
        if (ret == 0 && schedule_aging)
index a80789c876383e731d3bf13673a973775777a4b8..a30f7ce45d387410e2642223a67a4cfd44afc72a 100644 (file)
@@ -42,6 +42,9 @@ struct ib_frmr_pool {
 
        struct delayed_work aging_work;
        struct ib_device *device;
+
+       u32 max_in_use;
+       u32 in_use;
 };
 
 struct ib_frmr_pools {