Skip to content

Commit 8a68403

Browse files
Hans Westgaard Ryjfvogel
authored andcommitted
RDS-IB: Fix cachehit statistics
RDS IB cache make cache-hit-statistics available through sysfs. Statistics is collected per device and should be available via /sys/kernel/debug/rds_cache/<device-name>/hit_stats. The current codebase only generates the file for the first device. Orabug: 33426206 Signed-off-by: Hans Westgaard Ry <[email protected]> Reviewed-by: William Kucharski <[email protected]> Conflicts: net/rds/ib.c Orabug: 33590097 UEK6 => UEK7 (cherry picked from commit 2cb43f3) cherry-pick-repo=UEK/production/linux-uek.git Signed-off-by: Gerd Rausch <[email protected]> Reviewed-by: William Kucharski <[email protected]>
1 parent 4ea5c23 commit 8a68403

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

net/rds/ib.c

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include "ib.h"
4343
#include "rds_single_path.h"
4444

45+
static struct dentry *debugfs_basedir;
46+
4547
unsigned int rds_ib_fmr_1m_pool_size = RDS_FMR_1M_POOL_SIZE;
4648
unsigned int rds_ib_fmr_8k_pool_size = RDS_FMR_8K_POOL_SIZE;
4749
unsigned int rds_ib_retry_count = RDS_IB_DEFAULT_RETRY_COUNT;
@@ -103,32 +105,50 @@ static int ib_rds_cache_hit_show(struct seq_file *m, void *v)
103105
struct rds_ib_refill_cache *cache;
104106
struct rds_ib_cache_head *head;
105107
unsigned long long miss, hit;
108+
u32 cnt;
106109
int i;
107110
int cpu;
108111
u64 sum_get_stats[(RDS_FRAG_CACHE_ENTRIES + 1)];
109112
u64 sum_hit_stats[(RDS_FRAG_CACHE_ENTRIES + 1)];
113+
u32 sum_cnt_stats[(RDS_FRAG_CACHE_ENTRIES + 1)];
110114
char heading[(RDS_FRAG_CACHE_ENTRIES + 1)][40];
111115

112-
sprintf(heading[0], "---------- Inc ----------");
116+
sprintf(heading[0], "------------- Inc -------------");
113117
for (i = 1; i <= RDS_FRAG_CACHE_ENTRIES; i++)
114-
sprintf(heading[i], "---------- Frag-%d ----------", i - 1);
118+
sprintf(heading[i], "------------- Frag-%d -------------", i - 1);
115119

116120
seq_printf(m, "%11s", " ");
117121
for (i = 0; i <= RDS_FRAG_CACHE_ENTRIES; i++) {
118-
seq_printf(m, "%35s ", heading[i]);
122+
seq_printf(m, "%41s ", heading[i]);
119123

120124
sum_get_stats[i] = 0;
121125
sum_hit_stats[i] = 0;
126+
sum_cnt_stats[i] = 0;
122127
}
123128
seq_puts(m, "\n");
124129

125130
seq_printf(m, "%11s", "cpu");
126131
for (i = 0; i <= RDS_FRAG_CACHE_ENTRIES; i++)
127-
seq_printf(m, "%15s %15s %4s", "Get", "Hit", "%");
132+
seq_printf(m, "%15s %15s %4s %5s", "Get", "Hit", "%", "Count");
128133

129134
seq_puts(m, "\n");
130135

131136
for_each_possible_cpu(cpu) {
137+
u64 s = 0;
138+
139+
for (i = 0; i <= RDS_FRAG_CACHE_ENTRIES; i++) {
140+
if (i == 0)
141+
cache = &rds_ibdev->i_cache_incs;
142+
else
143+
cache = rds_ibdev->i_cache_frags + i - 1;
144+
head = per_cpu_ptr(cache->percpu, cpu);
145+
s += atomic64_read(&head->miss_count);
146+
s += atomic64_read(&head->hit_count);
147+
s += atomic_read(&head->count);
148+
}
149+
if (!s)
150+
continue;
151+
132152
seq_printf(m, "%3d ", cpu);
133153
for (i = 0; i <= RDS_FRAG_CACHE_ENTRIES; i++) {
134154
if (i == 0)
@@ -138,23 +158,25 @@ static int ib_rds_cache_hit_show(struct seq_file *m, void *v)
138158
head = per_cpu_ptr(cache->percpu, cpu);
139159
miss = atomic64_read(&head->miss_count);
140160
hit = atomic64_read(&head->hit_count);
141-
142-
seq_printf(m, "%15llu %15llu %4llu",
161+
cnt = atomic_read(&head->count);
162+
seq_printf(m, "%15llu %15llu %4llu %5u",
143163
(hit + miss),
144164
hit,
145-
(hit + miss) ? hit * 100 / (hit + miss) : 0);
165+
(hit + miss) ? hit * 100 / (hit + miss) : 0, cnt);
146166
sum_get_stats[i] += (hit + miss);
147167
sum_hit_stats[i] += hit;
168+
sum_cnt_stats[i] += cnt;
148169
}
149170
seq_puts(m, "\n");
150171
}
151172
seq_puts(m, "sum ");
152173

153174
for (i = 0; i <= RDS_FRAG_CACHE_ENTRIES; i++) {
154-
seq_printf(m, "%15llu %15llu %4llu",
175+
seq_printf(m, "%15llu %15llu %4llu %5u",
155176
sum_get_stats[i],
156177
sum_hit_stats[i],
157-
sum_get_stats[i] ? sum_hit_stats[i] * 100 / sum_get_stats[i] : 0);
178+
sum_get_stats[i] ? sum_hit_stats[i] * 100 / sum_get_stats[i] : 0,
179+
sum_cnt_stats[i]);
158180
}
159181
seq_puts(m, "\n");
160182

@@ -166,10 +188,10 @@ static int ib_rds_cache_hit_show(struct seq_file *m, void *v)
166188
cache = rds_ibdev->i_cache_frags + i - 1;
167189
miss = atomic64_read(&cache->miss_count);
168190
hit = atomic64_read(&cache->hit_count);
169-
seq_printf(m, "%15s %15llu %4llu",
191+
seq_printf(m, "%15s %15llu %4llu %5s",
170192
"",
171193
hit,
172-
(hit + miss) ? hit * 100 / (hit + miss) : 0);
194+
(hit + miss) ? hit * 100 / (hit + miss) : 0, " ");
173195
}
174196
seq_puts(m, "\n");
175197

@@ -181,8 +203,8 @@ static int ib_rds_cache_hit_show(struct seq_file *m, void *v)
181203
else
182204
cache = rds_ibdev->i_cache_frags + i - 1;
183205
miss = atomic64_read(&cache->miss_count);
184-
seq_printf(m, "%15llu %15s %4s",
185-
miss, " ", " ");
206+
seq_printf(m, "%15llu %15s %4s %5s",
207+
miss, " ", " ", " ");
186208
}
187209
seq_puts(m, "\n");
188210

@@ -203,18 +225,13 @@ static const struct file_operations ib_rds_cache_hit_fops = {
203225

204226
static int ib_rds_create_debugfs_cache_hit(struct rds_ib_device *rds_ibdev)
205227
{
206-
struct dentry *d_dev;
207228
struct dentry *ent;
208229

209-
rds_ibdev->debugfs_dir = debugfs_create_dir("rds_cache", NULL);
230+
rds_ibdev->debugfs_dir = debugfs_create_dir(rds_ibdev->dev->name, debugfs_basedir);
210231
if (!rds_ibdev->debugfs_dir)
211-
return -ENOMEM;
212-
213-
d_dev = debugfs_create_dir(rds_ibdev->dev->name, rds_ibdev->debugfs_dir);
214-
if (!d_dev)
215-
goto fail;
232+
goto out;
216233

217-
ent = debugfs_create_file("hit_stats", 0400, d_dev,
234+
ent = debugfs_create_file("hit_stats", 0400, rds_ibdev->debugfs_dir,
218235
rds_ibdev, &ib_rds_cache_hit_fops);
219236
if (!ent)
220237
goto fail;
@@ -223,6 +240,7 @@ static int ib_rds_create_debugfs_cache_hit(struct rds_ib_device *rds_ibdev)
223240
fail:
224241
debugfs_remove_recursive(rds_ibdev->debugfs_dir);
225242
rds_ibdev->debugfs_dir = NULL;
243+
out:
226244
return -ENOMEM;
227245
}
228246

@@ -1230,6 +1248,10 @@ int rds_ib_init(void)
12301248

12311249
INIT_LIST_HEAD(&rds_ib_devices);
12321250

1251+
debugfs_basedir = debugfs_create_dir("rds_cache", NULL);
1252+
if (!debugfs_basedir)
1253+
pr_err("RDS/IB: can't create debugfs_basedir\n");
1254+
12331255
/* Initialise the RDS IB fragment size */
12341256
rds_ib_init_frag(RDS_PROTOCOL_VERSION);
12351257

@@ -1352,6 +1374,7 @@ void rds_ib_exit(void)
13521374
destroy_workqueue(rds_evt_wq);
13531375
destroy_workqueue(rds_aux_wq);
13541376
rds_ib_fmr_exit();
1377+
debugfs_remove_recursive(debugfs_basedir);
13551378
}
13561379

13571380
struct rds_transport rds_ib_transport = {

0 commit comments

Comments
 (0)