mmc: core: capture performance numbers only when asked
Currently performance numbers are captured for each SDCC
transfers unconditionally which may add the overhead and
could reduce the SDCC read/write throughput numbers.
This change adds additional control for enabling/disabling the
capturing of performance numbers at runtime. We already have sysfs
entry named "perf" for msm sdcc devices. Currently setting this
entry to 0 clears the performance statistics. But now we are
changing the definition of this entry as mentioned below:
Disable performance capturing and clear the performance statistics:
"echo 0 > /sys/devices/platform/msm_sdcc.<n>/perf"
Enable performance capturing:
"echo 1 > /sys/devices/platform/msm_sdcc.<n>/perf"
CRs-fixed: 345170
Change-Id: I3ab9288fd87cc8a8ada6c0c3d066cac4f68d79b7
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index f3cdb7b..dd83b64 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -203,17 +203,21 @@
if (mrq->data) {
#ifdef CONFIG_MMC_PERF_PROFILING
- diff = ktime_sub(ktime_get(), host->perf.start);
- if (mrq->data->flags == MMC_DATA_READ) {
- host->perf.rbytes_drv +=
+ if (host->perf_enable) {
+ diff = ktime_sub(ktime_get(), host->perf.start);
+ if (mrq->data->flags == MMC_DATA_READ) {
+ host->perf.rbytes_drv +=
+ mrq->data->bytes_xfered;
+ host->perf.rtime_drv =
+ ktime_add(host->perf.rtime_drv,
+ diff);
+ } else {
+ host->perf.wbytes_drv +=
mrq->data->bytes_xfered;
- host->perf.rtime_drv =
- ktime_add(host->perf.rtime_drv, diff);
- } else {
- host->perf.wbytes_drv +=
- mrq->data->bytes_xfered;
- host->perf.wtime_drv =
- ktime_add(host->perf.wtime_drv, diff);
+ host->perf.wtime_drv =
+ ktime_add(host->perf.wtime_drv,
+ diff);
+ }
}
#endif
pr_debug("%s: %d bytes transferred: %d\n",
@@ -360,7 +364,8 @@
mrq->stop->mrq = mrq;
}
#ifdef CONFIG_MMC_PERF_PROFILING
- host->perf.start = ktime_get();
+ if (host->perf_enable)
+ host->perf.start = ktime_get();
#endif
}
mmc_host_clk_hold(host);