0cdfb3b207
ids_inflight is used to track the inflight IOs. But the use of atomic_t variable can cause performance drops and can also become a performance bottleneck. This commit replaces the use of atomic_t with a percpu_ref structure. The advantage it offers is, it doesn't check if the reference has fallen to 0, until the user explicitly signals it to; and that is done by the percpu_ref_kill() function call. After that, the percpu_ref structure behaves like an atomic_t and for every put call, checks whether the reference has fallen to 0 or not. rtrs_srv_stats_rdma_to_str shows the count of ids_inflight as 0 for user-mode tools not to be confused. Fixes: 9cb837480424e ("RDMA/rtrs: server: main functionality") Link: https://lore.kernel.org/r/20210528113018.52290-14-jinpu.wang@ionos.com Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com> Signed-off-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Gioh Kim <gi-oh.kim@ionos.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
37 lines
1023 B
C
37 lines
1023 B
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* RDMA Transport Layer
|
|
*
|
|
* Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
|
|
* Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
|
|
* Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
|
|
*/
|
|
#undef pr_fmt
|
|
#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
|
|
|
|
#include "rtrs-srv.h"
|
|
|
|
int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)
|
|
{
|
|
if (enable) {
|
|
struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
|
|
|
|
memset(r, 0, sizeof(*r));
|
|
return 0;
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
ssize_t rtrs_srv_stats_rdma_to_str(struct rtrs_srv_stats *stats,
|
|
char *page, size_t len)
|
|
{
|
|
struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
|
|
|
|
return scnprintf(page, len, "%lld %lld %lld %lldn %u\n",
|
|
(s64)atomic64_read(&r->dir[READ].cnt),
|
|
(s64)atomic64_read(&r->dir[READ].size_total),
|
|
(s64)atomic64_read(&r->dir[WRITE].cnt),
|
|
(s64)atomic64_read(&r->dir[WRITE].size_total), 0);
|
|
}
|