LPROCFS_TYPE_CYCLE = 0x0800,
};
-struct lprocfs_atomic {
- cfs_atomic_t la_entry;
- cfs_atomic_t la_exit;
-};
-
#define LC_MIN_INIT ((~(__u64)0) >> 1)
struct lprocfs_counter {
- struct lprocfs_atomic lc_cntl; /* may need to move to per set */
unsigned int lc_config;
__s64 lc_count;
__s64 lc_sum;
return;
percpu_cntr = &(stats->ls_percpu[smp_id]->lp_cntr[idx]);
- if (!(stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU))
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_entry);
percpu_cntr->lc_count++;
-
if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) {
/*
* lprocfs_counter_add() can be called in interrupt context,
if (amount > percpu_cntr->lc_max)
percpu_cntr->lc_max = amount;
}
- if (!(stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU))
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_exit);
lprocfs_stats_unlock(stats, LPROCFS_GET_SMP_ID, &flags);
}
EXPORT_SYMBOL(lprocfs_counter_add);
return;
percpu_cntr = &(stats->ls_percpu[smp_id]->lp_cntr[idx]);
- if (!(stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU))
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_entry);
if (percpu_cntr->lc_config & LPROCFS_CNTR_AVGMINMAX) {
/*
* Sometimes we use RCU callbacks to free memory which calls
else
percpu_cntr->lc_sum -= amount;
}
- if (!(stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU))
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_exit);
lprocfs_stats_unlock(stats, LPROCFS_GET_SMP_ID, &flags);
}
EXPORT_SYMBOL(lprocfs_counter_sub);
__s64 lprocfs_read_helper(struct lprocfs_counter *lc,
enum lprocfs_fields_flags field)
{
- __s64 ret = 0;
- int centry;
-
- if (!lc)
- RETURN(0);
- do {
- centry = cfs_atomic_read(&lc->lc_cntl.la_entry);
-
- switch (field) {
- case LPROCFS_FIELDS_FLAGS_CONFIG:
- ret = lc->lc_config;
- break;
- case LPROCFS_FIELDS_FLAGS_SUM:
- ret = lc->lc_sum + lc->lc_sum_irq;
- break;
- case LPROCFS_FIELDS_FLAGS_MIN:
- ret = lc->lc_min;
- break;
- case LPROCFS_FIELDS_FLAGS_MAX:
- ret = lc->lc_max;
- break;
- case LPROCFS_FIELDS_FLAGS_AVG:
- ret = (lc->lc_max - lc->lc_min)/2;
- break;
- case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
- ret = lc->lc_sumsquare;
- break;
- case LPROCFS_FIELDS_FLAGS_COUNT:
- ret = lc->lc_count;
- break;
- default:
- break;
- };
- } while (centry != cfs_atomic_read(&lc->lc_cntl.la_entry) &&
- centry != cfs_atomic_read(&lc->lc_cntl.la_exit));
-
- RETURN(ret);
+ __s64 ret = 0;
+
+ if (lc == NULL)
+ RETURN(0);
+
+ switch (field) {
+ case LPROCFS_FIELDS_FLAGS_CONFIG:
+ ret = lc->lc_config;
+ break;
+ case LPROCFS_FIELDS_FLAGS_SUM:
+ ret = lc->lc_sum + lc->lc_sum_irq;
+ break;
+ case LPROCFS_FIELDS_FLAGS_MIN:
+ ret = lc->lc_min;
+ break;
+ case LPROCFS_FIELDS_FLAGS_MAX:
+ ret = lc->lc_max;
+ break;
+ case LPROCFS_FIELDS_FLAGS_AVG:
+ ret = (lc->lc_max - lc->lc_min) / 2;
+ break;
+ case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
+ ret = lc->lc_sumsquare;
+ break;
+ case LPROCFS_FIELDS_FLAGS_COUNT:
+ ret = lc->lc_count;
+ break;
+ default:
+ break;
+ };
+
+ RETURN(ret);
}
EXPORT_SYMBOL(lprocfs_read_helper);
#endif /* LPROCFS */
void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
struct lprocfs_counter *cnt)
{
+ struct lprocfs_counter *ptr;
unsigned int num_entry;
- struct lprocfs_counter t;
- struct lprocfs_counter *percpu_cntr;
- int centry;
int i;
unsigned long flags = 0;
- memset(cnt, 0, sizeof(*cnt));
+ memset(cnt, 0, sizeof(*cnt));
- if (stats == NULL) {
- /* set count to 1 to avoid divide-by-zero errs in callers */
- cnt->lc_count = 1;
- return;
- }
+ if (stats == NULL) {
+ /* set count to 1 to avoid divide-by-zero errs in callers */
+ cnt->lc_count = 1;
+ return;
+ }
- cnt->lc_min = LC_MIN_INIT;
+ cnt->lc_min = LC_MIN_INIT;
num_entry = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags);
for (i = 0; i < num_entry; i++) {
if (stats->ls_percpu[i] == NULL)
continue;
- percpu_cntr = &(stats->ls_percpu[i])->lp_cntr[idx];
-
- do {
- centry = cfs_atomic_read(&percpu_cntr-> \
- lc_cntl.la_entry);
- t.lc_count = percpu_cntr->lc_count;
- t.lc_sum = percpu_cntr->lc_sum;
- t.lc_min = percpu_cntr->lc_min;
- t.lc_max = percpu_cntr->lc_max;
- t.lc_sumsquare = percpu_cntr->lc_sumsquare;
- } while (centry != cfs_atomic_read(&percpu_cntr->lc_cntl. \
- la_entry) &&
- centry != cfs_atomic_read(&percpu_cntr->lc_cntl. \
- la_exit));
- cnt->lc_count += t.lc_count;
- cnt->lc_sum += t.lc_sum;
- if (t.lc_min < cnt->lc_min)
- cnt->lc_min = t.lc_min;
- if (t.lc_max > cnt->lc_max)
- cnt->lc_max = t.lc_max;
- cnt->lc_sumsquare += t.lc_sumsquare;
- }
+
+ ptr = &(stats->ls_percpu[i])->lp_cntr[idx];
+ cnt->lc_count += ptr->lc_count;
+ cnt->lc_sum += ptr->lc_sum;
+ if (ptr->lc_min < cnt->lc_min)
+ cnt->lc_min = ptr->lc_min;
+ if (ptr->lc_max > cnt->lc_max)
+ cnt->lc_max = ptr->lc_max;
+ cnt->lc_sumsquare += ptr->lc_sumsquare;
+ }
cnt->lc_units = stats->ls_percpu[0]->lp_cntr[idx].lc_units;
lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags);
continue;
for (j = 0; j < stats->ls_num; j++) {
percpu_cntr = &(stats->ls_percpu[i])->lp_cntr[j];
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_entry);
percpu_cntr->lc_count = 0;
percpu_cntr->lc_sum = 0;
percpu_cntr->lc_min = LC_MIN_INIT;
percpu_cntr->lc_max = 0;
percpu_cntr->lc_sumsquare = 0;
- cfs_atomic_inc(&percpu_cntr->lc_cntl.la_exit);
}
}