/* SPDX-License-Identifier: GPL-2.0 * * Legacy blkg rwstat helpers enabled by CONFIG_BLK_CGROUP_RWSTAT. * Do not use in new code.
*/ #ifndef _BLK_CGROUP_RWSTAT_H #define _BLK_CGROUP_RWSTAT_H
/* * blkg_[rw]stat->aux_cnt is excluded for local stats but included for * recursive. Used to carry stats of dead children.
*/ struct blkg_rwstat { struct percpu_counter cpu_cnt[BLKG_RWSTAT_NR];
atomic64_t aux_cnt[BLKG_RWSTAT_NR];
};
/** * blkg_rwstat_add - add a value to a blkg_rwstat * @rwstat: target blkg_rwstat * @opf: REQ_OP and flags * @val: value to add * * Add @val to @rwstat. The counters are chosen according to @rw. The * caller is responsible for synchronizing calls to this function.
*/ staticinlinevoid blkg_rwstat_add(struct blkg_rwstat *rwstat,
blk_opf_t opf, uint64_t val)
{ struct percpu_counter *cnt;
/** * blkg_rwstat_read - read the current values of a blkg_rwstat * @rwstat: blkg_rwstat to read * @result: where to put the current values * * Read the current snapshot of @rwstat and return it in the @result counts.
*/ staticinlinevoid blkg_rwstat_read(struct blkg_rwstat *rwstat, struct blkg_rwstat_sample *result)
{ int i;
for (i = 0; i < BLKG_RWSTAT_NR; i++)
result->cnt[i] =
percpu_counter_sum_positive(&rwstat->cpu_cnt[i]);
}
/** * blkg_rwstat_total - read the total count of a blkg_rwstat * @rwstat: blkg_rwstat to read * * Return the total count of @rwstat regardless of the IO direction. This * function can be called without synchronization and takes care of u64 * atomicity.
*/ staticinline uint64_t blkg_rwstat_total(struct blkg_rwstat *rwstat)
{ struct blkg_rwstat_sample tmp = { };
/** * blkg_rwstat_reset - reset a blkg_rwstat * @rwstat: blkg_rwstat to reset
*/ staticinlinevoid blkg_rwstat_reset(struct blkg_rwstat *rwstat)
{ int i;
for (i = 0; i < BLKG_RWSTAT_NR; i++) {
percpu_counter_set(&rwstat->cpu_cnt[i], 0);
atomic64_set(&rwstat->aux_cnt[i], 0);
}
}
/** * blkg_rwstat_add_aux - add a blkg_rwstat into another's aux count * @to: the destination blkg_rwstat * @from: the source * * Add @from's count including the aux one to @to's aux count.
*/ staticinlinevoid blkg_rwstat_add_aux(struct blkg_rwstat *to, struct blkg_rwstat *from)
{
u64 sum[BLKG_RWSTAT_NR]; int i;
for (i = 0; i < BLKG_RWSTAT_NR; i++)
sum[i] = percpu_counter_sum_positive(&from->cpu_cnt[i]);
for (i = 0; i < BLKG_RWSTAT_NR; i++)
atomic64_add(sum[i] + atomic64_read(&from->aux_cnt[i]),
&to->aux_cnt[i]);
} #endif/* _BLK_CGROUP_RWSTAT_H */
Messung V0.5
¤ Dauer der Verarbeitung: 0.20 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.