#include "mds_client.h"
#include "metric.h"
+static int histogram_show(struct seq_file *s, void *p)
+{
+ struct ceph_san_tls_logger *tls;
+ size_t cpu;
+ u64 total_histogram[16] = {0};
+ int i;
+
+ seq_printf(s, "Ceph TLS Histogram Summary:\n");
+ seq_printf(s, "%-10s %-16s\n", "Bucket", "Count");
+ seq_printf(s, "-------------------------\n");
+
+ /* Sum up histograms from all CPUs */
+ for_each_possible_cpu(cpu) {
+ tls = &per_cpu(ceph_san_tls, cpu);
+
+ /* Add each CPU's histogram data to the total */
+ for (i = 0; i < 16; i++) {
+ total_histogram[i] += tls->histogram.counters[i];
+ }
+ }
+
+ /* Calculate total sum for normalization */
+ u64 sum = 0;
+ for (i = 0; i < 16; i++) {
+ sum += total_histogram[i];
+ }
+
+ /* Display normalized histogram with stars and percentages */
+ for (i = 0; i < 16; i++) {
+ int stars = sum ? (total_histogram[i] * 128) / sum : 0;
+ u64 percent = sum ? (total_histogram[i] * 100) / sum : 0;
+ seq_printf(s, "%-4d [%3.1f%%] ", i, percent);
+ while (stars-- > 0)
+ seq_printf(s, "*");
+ seq_printf(s, "\n");
+ }
+
+ return 0;
+}
+
static int ceph_san_show(struct seq_file *s, void *p)
{
struct ceph_san_tls_logger *tls;
DEFINE_SHOW_ATTRIBUTE(metrics_size);
DEFINE_SHOW_ATTRIBUTE(metrics_caps);
DEFINE_SHOW_ATTRIBUTE(ceph_san);
+DEFINE_SHOW_ATTRIBUTE(histogram);
/*
debugfs_remove(fsc->debugfs_status);
debugfs_remove(fsc->debugfs_mdsc);
debugfs_remove(fsc->debugfs_cephsan);
+ debugfs_remove(fsc->debugfs_histogram);
debugfs_remove_recursive(fsc->debugfs_metrics_dir);
doutc(fsc->client, "done\n");
}
fsc,
&ceph_san_fops);
+ fsc->debugfs_histogram = debugfs_create_file("histogram",
+ 0444,
+ fsc->client->debugfs_dir,
+ fsc,
+ &histogram_fops);
+
fsc->debugfs_metrics_dir = debugfs_create_dir("metrics",
fsc->client->debugfs_dir);
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
-
+#include <linux/slab.h>
DECLARE_PER_CPU(struct ceph_san_tls_logger, ceph_san_tls);
DECLARE_PER_CPU(struct cephsan_pagefrag, ceph_san_pagefrag);
pid_t pid;
u32 len;
};
-
+struct histogram {
+ u64 counters[16];
+};
struct ceph_san_tls_logger {
size_t head_idx;
struct page *pages;
struct ceph_san_log_entry *logs;
+ struct histogram histogram;
};
#else /* CONFIG_DEBUG_FS */
struct ceph_san_tls_logger *tls = this_cpu_ptr(&ceph_san_tls);
struct cephsan_pagefrag *pf = this_cpu_ptr(&ceph_san_pagefrag);
- int head_idx = tls->head_idx++ & (CEPH_SAN_MAX_LOGS - 1);
+ int head_idx = tls->head_idx + 1 & (CEPH_SAN_MAX_LOGS - 1);
int pre_len = tls->logs[head_idx].len;
buf[len-1] = '\0';
memcpy(tls->logs[head_idx].comm, current->comm, TASK_COMM_LEN);
cephsan_pagefrag_free(pf, pre_len);
+ tls->logs[head_idx].len = 0;
buf_idx = cephsan_pagefrag_alloc(pf, len);
if (buf_idx) {
+ tls->head_idx = head_idx;
+ tls->histogram.counters[len >> 3]++;
tls->logs[head_idx].len = len;
tls->logs[head_idx].buf = cephsan_pagefrag_get_ptr(pf, buf_idx);
memcpy(tls->logs[head_idx].buf, buf, len);
struct ceph_san_tls_logger *tls;
struct cephsan_pagefrag *pf;
- struct task_struct *task = current;
for_each_possible_cpu(cpu) {
tls = per_cpu_ptr(&ceph_san_tls, cpu);
tls->pages = alloc_pages(GFP_KERNEL, get_order(CEPH_SAN_MAX_LOGS * sizeof(struct ceph_san_log_entry)));