- struct lprocfs_stats *stats = p->private;
- struct lprocfs_counter *cntr = v;
- struct lprocfs_counter ret;
- int idx, rc = 0;
-
- if (cntr == &(stats->ls_percpu[0])->lp_cntr[0]) {
- struct timeval now;
- cfs_gettimeofday(&now);
- rc = seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
- "snapshot_time", now.tv_sec, now.tv_usec);
- if (rc < 0)
- return rc;
- }
- idx = cntr - &(stats->ls_percpu[0])->lp_cntr[0];
-
- lprocfs_stats_collect(stats, idx, &ret);
-
- if (ret.lc_count == 0)
- goto out;
-
- rc = seq_printf(p, "%-25s "LPD64" samples [%s]", cntr->lc_name,
- ret.lc_count, cntr->lc_units);
-
- if (rc < 0)
- goto out;
-
- if ((cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ret.lc_count > 0)) {
- rc = seq_printf(p, " "LPD64" "LPD64" "LPD64,
- ret.lc_min, ret.lc_max, ret.lc_sum);
- if (rc < 0)
- goto out;
- if (cntr->lc_config & LPROCFS_CNTR_STDDEV)
- rc = seq_printf(p, " "LPD64, ret.lc_sumsquare);
- if (rc < 0)
- goto out;
- }
- rc = seq_printf(p, "\n");
+ struct lprocfs_stats *stats = p->private;
+ struct lprocfs_counter *cntr = v;
+ struct lprocfs_counter ret;
+ struct lprocfs_counter_header *header;
+ int entry_size;
+ int idx;
+ int rc = 0;
+
+ if (cntr == &(stats->ls_percpu[0])->lp_cntr[0]) {
+ struct timeval now;
+ cfs_gettimeofday(&now);
+ rc = seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
+ "snapshot_time", now.tv_sec, now.tv_usec);
+ if (rc < 0)
+ return rc;
+ }
+ entry_size = sizeof(*cntr);
+ if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE)
+ entry_size += sizeof(__s64);
+ idx = ((void *)cntr - (void *)&(stats->ls_percpu[0])->lp_cntr[0]) /
+ entry_size;
+
+ header = &stats->ls_cnt_header[idx];
+ lprocfs_stats_collect(stats, idx, &ret);
+
+ if (ret.lc_count == 0)
+ goto out;
+
+ rc = seq_printf(p, "%-25s "LPD64" samples [%s]", header->lc_name,
+ ret.lc_count, header->lc_units);
+
+ if (rc < 0)
+ goto out;
+
+ if ((header->lc_config & LPROCFS_CNTR_AVGMINMAX) &&
+ (ret.lc_count > 0)) {
+ rc = seq_printf(p, " "LPD64" "LPD64" "LPD64,
+ ret.lc_min, ret.lc_max, ret.lc_sum);
+ if (rc < 0)
+ goto out;
+ if (header->lc_config & LPROCFS_CNTR_STDDEV)
+ rc = seq_printf(p, " "LPD64, ret.lc_sumsquare);
+ if (rc < 0)
+ goto out;
+ }
+ rc = seq_printf(p, "\n");