* [PATCH 0/3] ceph: fix the buffered read size metric and make the subvolume metrics per CPU
@ 2026-10-13 23:20 Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 1/3] ceph: report the requested length in the netfs read metrics Xiubo Li via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-10-13 23:20 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Milind Changire,
Jeff Layton
Cc: ceph-devel, linux-kernel, Dan van der Ster, Xiubo Li
Two problems in the client I/O metrics, reported by Dan van der Ster
while looking at IO500 runs on 144-core Grace clients.
Patch 1: metrics/size has reported 0 bytes for every page cache read
since buffered reads moved to CEPH_OSD_DATA_TYPE_ITER, because
finish_netfs_read() still reads osd_data->length, which only the page
vector type sets.
Patches 2-3: every OSD read and write completion updates the subvolume
metrics through state shared by the whole mount. Even with subvolume
metrics disabled it bumped an atomic64 counter that nothing reads;
with them enabled it took a mount-wide spinlock and searched an rbtree.
Patch 2 drops the unused counters, patch 3 accumulates the counters in
a per-CPU slot and only folds them into the tree when the slot changes
subvolume or when the metrics are sent or dumped.
Tested on x86_64 against a main MDS with SUBVOLUME_METRICS: 16 jobs on
16 CPUs writing and reading two subvolumes and a plain directory. The
read sizes are now reported, and the per-subvolume op and byte totals
summed over every metrics send match the I/O issued.
---
Xiubo Li (3):
ceph: report the requested length in the netfs read metrics
ceph: drop the unused subvolume metrics debug counters
ceph: accumulate subvolume metrics per CPU
fs/ceph/addr.c | 2 +-
fs/ceph/mds_client.c | 6 +-
fs/ceph/subvolume_metrics.c | 172 +++++++++++++++++++++++++++++++-------------
fs/ceph/subvolume_metrics.h | 26 ++-----
4 files changed, 133 insertions(+), 73 deletions(-)
---
base-commit: ed0502cb11f84fff29f374238e526ae94d9bdfde
change-id: 20261014-ceph-metrics-percpu-1cb5047f7150
Best regards,
--
Xiubo Li <xiubo.li@clyso.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] ceph: report the requested length in the netfs read metrics
2026-10-13 23:20 [PATCH 0/3] ceph: fix the buffered read size metric and make the subvolume metrics per CPU Xiubo Li via B4 Relay
@ 2026-10-13 23:20 ` Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 2/3] ceph: drop the unused subvolume metrics debug counters Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 3/3] ceph: accumulate subvolume metrics per CPU Xiubo Li via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-10-13 23:20 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Milind Changire,
Jeff Layton
Cc: ceph-devel, linux-kernel, Dan van der Ster, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
finish_netfs_read() passes osd_data->length to
ceph_update_read_metrics(), but a buffered read of an unencrypted
file attaches its data as CEPH_OSD_DATA_TYPE_ITER, and
ceph_osd_iter_init() only sets the type and the iov_iter. length
shares a union with the iov_iter, so the read size metrics record
some unrelated iov_iter field, which is normally 0, for every page
cache read, and metrics/size is useless for buffered reads.
Report op->extent.length, the length the OSD read asked for, which is
set for every data type and equals osd_data->length for the page
vector that encrypted files still use.
Fixes: 4de77f25fd85 ("ceph: use osd_req_op_extent_osd_iter for netfs reads")
Reported-by: Dan van der Ster <dan.vanderster@clyso.com>
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
fs/ceph/addr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index dd2bd8ed2424..8500d72702d6 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -236,7 +236,7 @@ static void finish_netfs_read(struct ceph_osd_request *req)
ceph_blog_enter_gfp(fsc, &__ji, GFP_ATOMIC);
ceph_update_read_metrics(&fsc->mdsc->metric, req->r_start_latency,
- req->r_end_latency, osd_data->length, err);
+ req->r_end_latency, op->extent.length, err);
boutc(cl, "result %d subreq->len=%zu i_size=%lld\n", req->r_result,
subreq->len, i_size_read(req->r_inode));
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] ceph: drop the unused subvolume metrics debug counters
2026-10-13 23:20 [PATCH 0/3] ceph: fix the buffered read size metric and make the subvolume metrics per CPU Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 1/3] ceph: report the requested length in the netfs read metrics Xiubo Li via B4 Relay
@ 2026-10-13 23:20 ` Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 3/3] ceph: accumulate subvolume metrics per CPU Xiubo Li via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-10-13 23:20 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Milind Changire,
Jeff Layton
Cc: ceph-devel, linux-kernel, Dan van der Ster, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
ceph_subvolume_metrics_record_io() bumps tracker->record_calls on
every OSD read and write completion, plus record_disabled or
record_no_subvol when it bails out, and ceph_subvolume_metrics_record()
adds to the total_read/write_ops/bytes counters on top of its own
per-subvolume ones. All of them are atomic64_t shared by every CPU
of the mount, so even with subvolume metrics disabled each I/O
completion dirties a cache line that every other completion on the
client also writes.
Nothing ever reads these counters, nor the snapshot_* ones: debugfs
prints the per-subvolume entries and the totals kept under
subvol_metrics_last_mutex. Remove them.
Fixes: b1137e0b3d4b ("ceph: add subvolume metrics collection and reporting")
Reported-by: Dan van der Ster <dan.vanderster@clyso.com>
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
fs/ceph/subvolume_metrics.c | 34 ++++------------------------------
fs/ceph/subvolume_metrics.h | 21 ---------------------
2 files changed, 4 insertions(+), 51 deletions(-)
diff --git a/fs/ceph/subvolume_metrics.c b/fs/ceph/subvolume_metrics.c
index 03fda1f9257b..895878a49ea7 100644
--- a/fs/ceph/subvolume_metrics.c
+++ b/fs/ceph/subvolume_metrics.c
@@ -39,16 +39,6 @@ void ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker)
tracker->tree = RB_ROOT_CACHED;
tracker->nr_entries = 0;
tracker->enabled = false;
- atomic64_set(&tracker->snapshot_attempts, 0);
- atomic64_set(&tracker->snapshot_empty, 0);
- atomic64_set(&tracker->snapshot_failures, 0);
- atomic64_set(&tracker->record_calls, 0);
- atomic64_set(&tracker->record_disabled, 0);
- atomic64_set(&tracker->record_no_subvol, 0);
- atomic64_set(&tracker->total_read_ops, 0);
- atomic64_set(&tracker->total_read_bytes, 0);
- atomic64_set(&tracker->total_write_ops, 0);
- atomic64_set(&tracker->total_write_bytes, 0);
}
static struct ceph_subvol_metric_rb_entry *
@@ -196,14 +186,10 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracke
entry->write_ops++;
entry->write_bytes += size;
entry->write_latency_us += latency_us;
- atomic64_inc(&tracker->total_write_ops);
- atomic64_add(size, &tracker->total_write_bytes);
} else {
entry->read_ops++;
entry->read_bytes += size;
entry->read_latency_us += latency_us;
- atomic64_inc(&tracker->total_read_ops);
- atomic64_add(size, &tracker->total_read_bytes);
}
spin_unlock(&tracker->lock);
if (new_entry)
@@ -227,8 +213,6 @@ int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *track
if (!READ_ONCE(tracker->enabled))
return 0;
- atomic64_inc(&tracker->snapshot_attempts);
-
spin_lock(&tracker->lock);
for (node = rb_first_cached(&tracker->tree); node; node = rb_next(node)) {
struct ceph_subvol_metric_rb_entry *entry =
@@ -240,16 +224,12 @@ int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *track
}
spin_unlock(&tracker->lock);
- if (!count) {
- atomic64_inc(&tracker->snapshot_empty);
+ if (!count)
return 0;
- }
snap = kcalloc(count, sizeof(*snap), GFP_NOFS);
- if (!snap) {
- atomic64_inc(&tracker->snapshot_failures);
+ if (!snap)
return -ENOMEM;
- }
spin_lock(&tracker->lock);
node = rb_first_cached(&tracker->tree);
@@ -380,18 +360,12 @@ void ceph_subvolume_metrics_record_io(struct ceph_mds_client *mdsc,
return;
tracker = &mdsc->subvol_metrics;
- atomic64_inc(&tracker->record_calls);
-
- if (!ceph_subvolume_metrics_enabled(tracker)) {
- atomic64_inc(&tracker->record_disabled);
+ if (!ceph_subvolume_metrics_enabled(tracker))
return;
- }
subvol_id = READ_ONCE(ci->i_subvolume_id);
- if (subvol_id == CEPH_SUBVOLUME_ID_NONE) {
- atomic64_inc(&tracker->record_no_subvol);
+ if (subvol_id == CEPH_SUBVOLUME_ID_NONE)
return;
- }
delta_us = ktime_to_us(ktime_sub(end, start));
if (delta_us <= 0)
diff --git a/fs/ceph/subvolume_metrics.h b/fs/ceph/subvolume_metrics.h
index 6f53ff726c75..8b901ae05e00 100644
--- a/fs/ceph/subvolume_metrics.h
+++ b/fs/ceph/subvolume_metrics.h
@@ -6,7 +6,6 @@
#include <linux/rbtree.h>
#include <linux/spinlock.h>
#include <linux/ktime.h>
-#include <linux/atomic.h>
struct seq_file;
struct ceph_mds_client;
@@ -38,32 +37,12 @@ struct ceph_subvol_metric_snapshot {
* @tree: Red-black tree of per-subvolume entries, keyed by subvolume_id
* @nr_entries: Number of entries currently in @tree
* @enabled: Whether collection is enabled (requires MDS feature support)
- * @snapshot_attempts: Debug counter: total ceph_subvolume_metrics_snapshot() calls
- * @snapshot_empty: Debug counter: snapshots that found no data to report
- * @snapshot_failures: Debug counter: snapshots that failed to allocate memory
- * @record_calls: Debug counter: total ceph_subvolume_metrics_record() calls
- * @record_disabled: Debug counter: record calls skipped because disabled
- * @record_no_subvol: Debug counter: record calls skipped (no subvolume_id)
- * @total_read_ops: Cumulative read ops across all snapshots (never reset)
- * @total_read_bytes: Cumulative bytes read across all snapshots (never reset)
- * @total_write_ops: Cumulative write ops across all snapshots (never reset)
- * @total_write_bytes: Cumulative bytes written across all snapshots (never reset)
*/
struct ceph_subvolume_metrics_tracker {
spinlock_t lock;
struct rb_root_cached tree;
u32 nr_entries;
bool enabled;
- atomic64_t snapshot_attempts;
- atomic64_t snapshot_empty;
- atomic64_t snapshot_failures;
- atomic64_t record_calls;
- atomic64_t record_disabled;
- atomic64_t record_no_subvol;
- atomic64_t total_read_ops;
- atomic64_t total_read_bytes;
- atomic64_t total_write_ops;
- atomic64_t total_write_bytes;
};
void ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker);
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] ceph: accumulate subvolume metrics per CPU
2026-10-13 23:20 [PATCH 0/3] ceph: fix the buffered read size metric and make the subvolume metrics per CPU Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 1/3] ceph: report the requested length in the netfs read metrics Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 2/3] ceph: drop the unused subvolume metrics debug counters Xiubo Li via B4 Relay
@ 2026-10-13 23:20 ` Xiubo Li via B4 Relay
2 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li via B4 Relay @ 2026-10-13 23:20 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, Milind Changire,
Jeff Layton
Cc: ceph-devel, linux-kernel, Dan van der Ster, Xiubo Li
From: Xiubo Li <xiubo.li@clyso.com>
With subvolume metrics enabled, every OSD read and write completion
takes the mount-wide tracker->lock and walks the rbtree of subvolumes
to add one op to its entry. On a client with many cores doing a
large bandwidth, the completions of all its CPUs serialize on that
spinlock and bounce its cache line.
Give each CPU a slot holding the counters of one subvolume. A
completion only takes its own slot's lock and adds to it; it goes to
the tree only when the slot held another subvolume, whose counters it
then folds into the tree entry the old way. The metrics sender and
the debugfs dump fold every slot into the tree before they read it,
so what they report is unchanged. A client usually works in one
subvolume at a time, so the tree is touched once per CPU and snapshot
instead of once per I/O.
The slot is looked up with raw_cpu_ptr() and protected by its own
lock, so a task that migrates in between just updates another CPU's
slot. ceph_subvolume_metrics_init() now allocates the per-CPU slots
and can fail.
Reported-by: Dan van der Ster <dan.vanderster@clyso.com>
Signed-off-by: Xiubo Li <xiubo.li@clyso.com>
---
fs/ceph/mds_client.c | 6 +-
fs/ceph/subvolume_metrics.c | 140 +++++++++++++++++++++++++++++++++++++-------
fs/ceph/subvolume_metrics.h | 5 +-
3 files changed, 129 insertions(+), 22 deletions(-)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index d4ef8a355a48..649284a2e746 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -6501,7 +6501,9 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
err = ceph_metric_init(&mdsc->metric);
if (err)
goto err_mdsmap;
- ceph_subvolume_metrics_init(&mdsc->subvol_metrics);
+ err = ceph_subvolume_metrics_init(&mdsc->subvol_metrics);
+ if (err)
+ goto err_metric;
mutex_init(&mdsc->subvol_metrics_last_mutex);
mdsc->subvol_metrics_last = NULL;
mdsc->subvol_metrics_last_nr = 0;
@@ -6533,6 +6535,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
fsc->mdsc = mdsc;
return 0;
+err_metric:
+ ceph_metric_destroy(&mdsc->metric);
err_mdsmap:
kfree(mdsc->mdsmap);
err_mdsc:
diff --git a/fs/ceph/subvolume_metrics.c b/fs/ceph/subvolume_metrics.c
index 895878a49ea7..def26152e5fc 100644
--- a/fs/ceph/subvolume_metrics.c
+++ b/fs/ceph/subvolume_metrics.c
@@ -31,14 +31,36 @@ struct ceph_subvol_metric_rb_entry {
u64 write_latency_us;
};
+/**
+ * struct ceph_subvol_metric_pcpu - Per-CPU accumulator in front of the tree
+ * @lock: Protects @m; only contended when a task migrates mid-update
+ * @m: Counters of one subvolume (@m.subvolume_id) not yet folded into the tree
+ *
+ * I/O completions add to the slot of the CPU they run on and only take
+ * tracker->lock when the slot holds another subvolume, or when a snapshot
+ * or a dump folds every slot into the tree.
+ */
+struct ceph_subvol_metric_pcpu {
+ spinlock_t lock;
+ struct ceph_subvol_metric_snapshot m;
+};
+
static struct kmem_cache *ceph_subvol_metric_entry_cachep;
-void ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker)
+int ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker)
{
+ int cpu;
+
spin_lock_init(&tracker->lock);
tracker->tree = RB_ROOT_CACHED;
tracker->nr_entries = 0;
tracker->enabled = false;
+ tracker->pcpu = alloc_percpu(struct ceph_subvol_metric_pcpu);
+ if (!tracker->pcpu)
+ return -ENOMEM;
+ for_each_possible_cpu(cpu)
+ spin_lock_init(&per_cpu_ptr(tracker->pcpu, cpu)->lock);
+ return 0;
}
static struct ceph_subvol_metric_rb_entry *
@@ -109,12 +131,28 @@ static void ceph_subvolume_metrics_clear_locked(
tracker->tree = RB_ROOT_CACHED;
}
+static void ceph_subvolume_metrics_clear_pcpu(
+ struct ceph_subvolume_metrics_tracker *tracker)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ struct ceph_subvol_metric_pcpu *pc = per_cpu_ptr(tracker->pcpu, cpu);
+
+ spin_lock(&pc->lock);
+ memset(&pc->m, 0, sizeof(pc->m));
+ spin_unlock(&pc->lock);
+ }
+}
+
void ceph_subvolume_metrics_destroy(struct ceph_subvolume_metrics_tracker *tracker)
{
spin_lock(&tracker->lock);
ceph_subvolume_metrics_clear_locked(tracker);
tracker->enabled = false;
spin_unlock(&tracker->lock);
+ free_percpu(tracker->pcpu);
+ tracker->pcpu = NULL;
}
void ceph_subvolume_metrics_enable(struct ceph_subvolume_metrics_tracker *tracker,
@@ -128,20 +166,20 @@ void ceph_subvolume_metrics_enable(struct ceph_subvolume_metrics_tracker *tracke
ceph_subvolume_metrics_clear_locked(tracker);
}
spin_unlock(&tracker->lock);
+ if (!enable)
+ ceph_subvolume_metrics_clear_pcpu(tracker);
}
-void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracker,
- u64 subvol_id, bool is_write,
- size_t size, u64 latency_us)
+/*
+ * Add the counters of one subvolume taken out of a per-CPU slot to its
+ * entry in the tree.
+ */
+static void ceph_subvolume_metrics_fold(struct ceph_subvolume_metrics_tracker *tracker,
+ const struct ceph_subvol_metric_snapshot *d)
{
struct ceph_subvol_metric_rb_entry *entry, *new_entry = NULL;
bool retry = false;
- /* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset subvolume */
- if (!READ_ONCE(tracker->enabled) ||
- subvol_id == CEPH_SUBVOLUME_ID_NONE || !size || !latency_us)
- return;
-
/*
* Retry loop for lock-free allocation pattern:
* 1. First iteration: lookup under lock, if miss -> drop lock, alloc, retry
@@ -158,7 +196,7 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracke
return;
}
- entry = __lookup_entry(tracker, subvol_id);
+ entry = __lookup_entry(tracker, d->subvolume_id);
if (!entry) {
if (!new_entry) {
spin_unlock(&tracker->lock);
@@ -166,7 +204,7 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracke
GFP_NOFS);
if (!new_entry)
return;
- new_entry->subvolume_id = subvol_id;
+ new_entry->subvolume_id = d->subvolume_id;
retry = true;
continue;
}
@@ -182,15 +220,12 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracke
new_entry = NULL;
}
- if (is_write) {
- entry->write_ops++;
- entry->write_bytes += size;
- entry->write_latency_us += latency_us;
- } else {
- entry->read_ops++;
- entry->read_bytes += size;
- entry->read_latency_us += latency_us;
- }
+ entry->read_ops += d->read_ops;
+ entry->read_bytes += d->read_bytes;
+ entry->read_latency_us += d->read_latency_us;
+ entry->write_ops += d->write_ops;
+ entry->write_bytes += d->write_bytes;
+ entry->write_latency_us += d->write_latency_us;
spin_unlock(&tracker->lock);
if (new_entry)
kmem_cache_free(ceph_subvol_metric_entry_cachep, new_entry);
@@ -198,6 +233,66 @@ void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracke
} while (retry);
}
+/* Move what every per-CPU slot holds into the tree. */
+static void ceph_subvolume_metrics_fold_pcpu(
+ struct ceph_subvolume_metrics_tracker *tracker)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu) {
+ struct ceph_subvol_metric_pcpu *pc = per_cpu_ptr(tracker->pcpu, cpu);
+ struct ceph_subvol_metric_snapshot d;
+
+ spin_lock(&pc->lock);
+ d = pc->m;
+ memset(&pc->m, 0, sizeof(pc->m));
+ pc->m.subvolume_id = d.subvolume_id;
+ spin_unlock(&pc->lock);
+
+ if (d.read_ops || d.write_ops)
+ ceph_subvolume_metrics_fold(tracker, &d);
+ }
+}
+
+void ceph_subvolume_metrics_record(struct ceph_subvolume_metrics_tracker *tracker,
+ u64 subvol_id, bool is_write,
+ size_t size, u64 latency_us)
+{
+ struct ceph_subvol_metric_snapshot old = {};
+ struct ceph_subvol_metric_pcpu *pc;
+
+ /* CEPH_SUBVOLUME_ID_NONE (0) means unknown/unset subvolume */
+ if (!READ_ONCE(tracker->enabled) ||
+ subvol_id == CEPH_SUBVOLUME_ID_NONE || !size || !latency_us)
+ return;
+
+ /*
+ * The slot of the CPU we start on; if we migrate, the lock still
+ * keeps the update consistent and it just lands in another slot.
+ */
+ pc = raw_cpu_ptr(tracker->pcpu);
+ spin_lock(&pc->lock);
+ if (unlikely(pc->m.subvolume_id != subvol_id)) {
+ old = pc->m;
+ memset(&pc->m, 0, sizeof(pc->m));
+ pc->m.subvolume_id = subvol_id;
+ }
+ if (is_write) {
+ pc->m.write_ops++;
+ pc->m.write_bytes += size;
+ pc->m.write_latency_us += latency_us;
+ } else {
+ pc->m.read_ops++;
+ pc->m.read_bytes += size;
+ pc->m.read_latency_us += latency_us;
+ }
+ spin_unlock(&pc->lock);
+
+ /* the slot held another subvolume: hand its counters to the tree */
+ if (old.read_ops || old.write_ops)
+ ceph_subvolume_metrics_fold(tracker, &old);
+}
+
int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *tracker,
struct ceph_subvol_metric_snapshot **out,
u32 *nr, bool consume)
@@ -213,6 +308,8 @@ int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *track
if (!READ_ONCE(tracker->enabled))
return 0;
+ ceph_subvolume_metrics_fold_pcpu(tracker);
+
spin_lock(&tracker->lock);
for (node = rb_first_cached(&tracker->tree); node; node = rb_next(node)) {
struct ceph_subvol_metric_rb_entry *entry =
@@ -306,6 +403,9 @@ void ceph_subvolume_metrics_dump(struct ceph_subvolume_metrics_tracker *tracker,
struct rb_node *node;
bool found = false;
+ if (READ_ONCE(tracker->enabled))
+ ceph_subvolume_metrics_fold_pcpu(tracker);
+
spin_lock(&tracker->lock);
if (!tracker->enabled) {
spin_unlock(&tracker->lock);
diff --git a/fs/ceph/subvolume_metrics.h b/fs/ceph/subvolume_metrics.h
index 8b901ae05e00..b29d48e9a4f1 100644
--- a/fs/ceph/subvolume_metrics.h
+++ b/fs/ceph/subvolume_metrics.h
@@ -10,6 +10,7 @@
struct seq_file;
struct ceph_mds_client;
struct ceph_inode_info;
+struct ceph_subvol_metric_pcpu;
/**
* struct ceph_subvol_metric_snapshot - Point-in-time snapshot of subvolume metrics
@@ -37,15 +38,17 @@ struct ceph_subvol_metric_snapshot {
* @tree: Red-black tree of per-subvolume entries, keyed by subvolume_id
* @nr_entries: Number of entries currently in @tree
* @enabled: Whether collection is enabled (requires MDS feature support)
+ * @pcpu: Per-CPU accumulators that I/O completions update without @lock
*/
struct ceph_subvolume_metrics_tracker {
spinlock_t lock;
struct rb_root_cached tree;
u32 nr_entries;
bool enabled;
+ struct ceph_subvol_metric_pcpu __percpu *pcpu;
};
-void ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker);
+int ceph_subvolume_metrics_init(struct ceph_subvolume_metrics_tracker *tracker);
void ceph_subvolume_metrics_destroy(struct ceph_subvolume_metrics_tracker *tracker);
void ceph_subvolume_metrics_enable(struct ceph_subvolume_metrics_tracker *tracker,
bool enable);
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-13 23:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-13 23:20 [PATCH 0/3] ceph: fix the buffered read size metric and make the subvolume metrics per CPU Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 1/3] ceph: report the requested length in the netfs read metrics Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 2/3] ceph: drop the unused subvolume metrics debug counters Xiubo Li via B4 Relay
2026-10-13 23:20 ` [PATCH 3/3] ceph: accumulate subvolume metrics per CPU Xiubo Li via B4 Relay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®