diff options
author | Mohan Srinivasan <srmohan@google.com> | 2017-02-15 12:39:35 -0800 |
---|---|---|
committer | Mohan Srinivasan <srmohan@google.com> | 2017-02-15 12:42:39 -0800 |
commit | 08357dfe620c32a72de0c598a078dde01991cdb8 (patch) | |
tree | a46fe24f8148aacd859bf947d249d8682b543bae /ioshark | |
parent | 3e24331d2915d0c582138651b2f4e57eff881bd9 (diff) | |
download | extras-08357dfe620c32a72de0c598a078dde01991cdb8.tar.gz |
Query for device and then set the blockdev name.
IOshark uses /proc/diskstats to get various stats. It needs a
block device name for doing this. The block device was hardcoded
as sda (Marlin/Sailfish). Query the device productname and use
this to set the block device name instead. Needed to make IOshark
work on non-M/S device.
Test: Testing the change on marlin as well as bullhead (which
covers Sailfish, Shamu and Angler as well).
Change-Id: Id9d7071019112cede1fd5e5c1f2c62f2fc4b6e65
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
Diffstat (limited to 'ioshark')
-rw-r--r-- | ioshark/ioshark_bench_subr.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ioshark/ioshark_bench_subr.c b/ioshark/ioshark_bench_subr.c index 4083e053..06a6d99d 100644 --- a/ioshark/ioshark_bench_subr.c +++ b/ioshark/ioshark_bench_subr.c @@ -357,6 +357,41 @@ get_cores(void) #endif static void +get_blockdev_name(char *bdev) +{ + char dev_name[BUFSIZE]; + FILE *cmd; + + cmd = popen("getprop ro.product.name", "r"); + if (cmd == NULL) { + fprintf(stderr, "%s: Cannot popen getprop\n", + progname); + exit(1); + } + if (fgets(dev_name, BUFSIZE, cmd) == NULL) { + fprintf(stderr, + "%s: Bad output from getprop ro.product.name\n", + progname); + exit(1); + } + pclose(cmd); + /* strncmp needed because of the trailing '\n' */ + if (strncmp(dev_name, "bullhead", strlen("bullhead")) == 0 || + strncmp(dev_name, "angler", strlen("angler")) == 0 || + strncmp(dev_name, "shamu", strlen("shamu")) == 0) { + strcpy(bdev, "mmcblk0"); + } else if (strncmp(dev_name, "marlin", strlen("marlin")) == 0 || + strncmp(dev_name, "sailfish", strlen("sailfish")) == 0) { + strcpy(bdev, "sda"); + } else { + fprintf(stderr, + "%s: Unknown device %s\n", + progname, dev_name); + exit(1); + } +} + +static void read_disk_util_state(struct cpu_disk_util_stats *state) { FILE *fp; @@ -369,6 +404,7 @@ read_disk_util_state(struct cpu_disk_util_stats *state) unsigned long rd_merges; unsigned long wr_merges; unsigned long up_sec, up_cent; + char blockdev_name[BUFSIZE]; /* Read and parse /proc/uptime */ fp = fopen("/proc/uptime", "r"); @@ -381,7 +417,9 @@ read_disk_util_state(struct cpu_disk_util_stats *state) sscanf(line, "%lu.%lu", &up_sec, &up_cent); state->uptime = (unsigned long long) up_sec * hz + (unsigned long long) up_cent * hz / 100; + /* Read and parse /proc/diskstats */ + get_blockdev_name(blockdev_name); fp = fopen("/proc/diskstats", "r"); while (fgets(line, sizeof(line), fp)) { sscanf(line, @@ -391,7 +429,7 @@ read_disk_util_state(struct cpu_disk_util_stats *state) &rd_ticks, &state->wr_ios, &wr_merges, &state->wr_sec, &wr_ticks, &ios_pgr, &state->tot_ticks, &rq_ticks); - if (strcmp(dev_name, "sda") == 0) { + if (strcmp(dev_name, blockdev_name) == 0) { /* * tot_ticks is "number of milliseconds spent * doing I/Os". Look at Documentation/iostats.txt. |