Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309230
b: refs/heads/master
c: c4c76a0
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Mar 20, 2012
1 parent a478fe9 commit 50c6607
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 997a026c80c3cc05f82e589aced1f0011c17d376
refs/heads/master: c4c76a05382c7d05e0b911daa58a827399e9ba1a
100 changes: 51 additions & 49 deletions trunk/block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,15 +868,6 @@ static void blkio_get_key_name(enum stat_sub_type type, const char *dname,
}
}

static uint64_t blkio_fill_stat(char *str, int chars_left, uint64_t val,
struct cgroup_map_cb *cb, const char *dname)
{
blkio_get_key_name(0, dname, str, chars_left, true);
cb->fill(cb, str, val);
return val;
}


static uint64_t blkio_read_stat_cpu(struct blkio_group *blkg, int plid,
enum stat_type_cpu type, enum stat_sub_type sub_type)
{
Expand Down Expand Up @@ -916,8 +907,9 @@ static uint64_t blkio_get_stat_cpu(struct blkio_group *blkg, int plid,

if (type == BLKIO_STAT_CPU_SECTORS) {
val = blkio_read_stat_cpu(blkg, plid, type, 0);
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1, val, cb,
dname);
blkio_get_key_name(0, dname, key_str, MAX_KEY_LEN, true);
cb->fill(cb, key_str, val);
return val;
}

for (sub_type = BLKIO_STAT_READ; sub_type < BLKIO_STAT_TOTAL;
Expand All @@ -942,50 +934,60 @@ static uint64_t blkio_get_stat(struct blkio_group *blkg, int plid,
struct cgroup_map_cb *cb, const char *dname,
enum stat_type type)
{
struct blkg_policy_data *pd = blkg->pd[plid];
uint64_t disk_total;
struct blkio_group_stats *stats = &blkg->pd[plid]->stats;
uint64_t v = 0, disk_total = 0;
char key_str[MAX_KEY_LEN];
enum stat_sub_type sub_type;
int st;

if (type == BLKIO_STAT_TIME)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.time, cb, dname);
if (type >= BLKIO_STAT_ARR_NR) {
switch (type) {
case BLKIO_STAT_TIME:
v = stats->time;
break;
#ifdef CONFIG_DEBUG_BLK_CGROUP
if (type == BLKIO_STAT_UNACCOUNTED_TIME)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.unaccounted_time, cb, dname);
if (type == BLKIO_STAT_AVG_QUEUE_SIZE) {
uint64_t sum = pd->stats.avg_queue_size_sum;
uint64_t samples = pd->stats.avg_queue_size_samples;
if (samples)
do_div(sum, samples);
else
sum = 0;
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
sum, cb, dname);
}
if (type == BLKIO_STAT_GROUP_WAIT_TIME)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.group_wait_time, cb, dname);
if (type == BLKIO_STAT_IDLE_TIME)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.idle_time, cb, dname);
if (type == BLKIO_STAT_EMPTY_TIME)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.empty_time, cb, dname);
if (type == BLKIO_STAT_DEQUEUE)
return blkio_fill_stat(key_str, MAX_KEY_LEN - 1,
pd->stats.dequeue, cb, dname);
case BLKIO_STAT_UNACCOUNTED_TIME:
v = stats->unaccounted_time;
break;
case BLKIO_STAT_AVG_QUEUE_SIZE: {
uint64_t samples = stats->avg_queue_size_samples;

if (samples) {
v = stats->avg_queue_size_sum;
do_div(v, samples);
}
break;
}
case BLKIO_STAT_IDLE_TIME:
v = stats->idle_time;
break;
case BLKIO_STAT_EMPTY_TIME:
v = stats->empty_time;
break;
case BLKIO_STAT_DEQUEUE:
v = stats->dequeue;
break;
case BLKIO_STAT_GROUP_WAIT_TIME:
v = stats->group_wait_time;
break;
#endif
default:
WARN_ON_ONCE(1);
}

for (sub_type = BLKIO_STAT_READ; sub_type < BLKIO_STAT_TOTAL;
sub_type++) {
blkio_get_key_name(sub_type, dname, key_str, MAX_KEY_LEN,
false);
cb->fill(cb, key_str, pd->stats.stat_arr[type][sub_type]);
blkio_get_key_name(0, dname, key_str, MAX_KEY_LEN, true);
cb->fill(cb, key_str, v);
return v;
}
disk_total = pd->stats.stat_arr[type][BLKIO_STAT_READ] +
pd->stats.stat_arr[type][BLKIO_STAT_WRITE];

for (st = BLKIO_STAT_READ; st < BLKIO_STAT_TOTAL; st++) {
v = stats->stat_arr[type][st];

blkio_get_key_name(st, dname, key_str, MAX_KEY_LEN, false);
cb->fill(cb, key_str, v);
if (st == BLKIO_STAT_READ || st == BLKIO_STAT_WRITE)
disk_total += v;
}

blkio_get_key_name(BLKIO_STAT_TOTAL, dname, key_str, MAX_KEY_LEN,
false);
cb->fill(cb, key_str, disk_total);
Expand Down
6 changes: 5 additions & 1 deletion trunk/block/blk-cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum stat_type {
BLKIO_STAT_WAIT_TIME,
/* Number of IOs queued up */
BLKIO_STAT_QUEUED,

/* All the single valued stats go below this */
BLKIO_STAT_TIME,
#ifdef CONFIG_DEBUG_BLK_CGROUP
Expand All @@ -52,6 +53,9 @@ enum stat_type {
#endif
};

/* Types lower than this live in stat_arr and have subtypes */
#define BLKIO_STAT_ARR_NR (BLKIO_STAT_QUEUED + 1)

/* Per cpu stats */
enum stat_type_cpu {
BLKIO_STAT_CPU_SECTORS,
Expand Down Expand Up @@ -117,7 +121,7 @@ struct blkio_cgroup {
struct blkio_group_stats {
/* total disk time and nr sectors dispatched by this group */
uint64_t time;
uint64_t stat_arr[BLKIO_STAT_QUEUED + 1][BLKIO_STAT_TOTAL];
uint64_t stat_arr[BLKIO_STAT_ARR_NR][BLKIO_STAT_TOTAL];
#ifdef CONFIG_DEBUG_BLK_CGROUP
/* Time not charged to this cgroup */
uint64_t unaccounted_time;
Expand Down

0 comments on commit 50c6607

Please sign in to comment.