summaryrefslogtreecommitdiff
path: root/cras/src/server/audio_thread.c
diff options
context:
space:
mode:
authorYu-Hsuan Hsu <yuhsuan@chromium.org>2020-05-20 17:43:02 +0800
committerCommit Bot <commit-bot@chromium.org>2020-06-03 16:35:34 +0000
commitd4109e5c481ce9f106cc1e6d3739c0d9da8812da (patch)
tree45c0afffb9010ef74d4b3f3081707e22c72d7aec /cras/src/server/audio_thread.c
parentac71b07ecec4c9e31d747f0a9b33252cb402ad6e (diff)
downloadadhd-d4109e5c481ce9f106cc1e6d3739c0d9da8812da.tar.gz
CRAS: Log the length of busyloop
Log the length of busyloop in order to check the busyloop distribution. BUG=b:157116480 TEST=Trigger busyloop manually and check the chrome://histograms Change-Id: I7d69e940bc3b5e331c1fdf59df90020f3a4f4ecc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2209009 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org> Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Diffstat (limited to 'cras/src/server/audio_thread.c')
-rw-r--r--cras/src/server/audio_thread.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/cras/src/server/audio_thread.c b/cras/src/server/audio_thread.c
index 5482514b..73e61199 100644
--- a/cras/src/server/audio_thread.c
+++ b/cras/src/server/audio_thread.c
@@ -37,6 +37,13 @@
*/
#define MAX_CONTINUOUS_ZERO_SLEEP_COUNT 2
+/*
+ * If the number of continuous zero sleep is equal to this limit, the value
+ * will be recorded immediately. It can ensure all busyloop will be recorded
+ * even if the busyloop does not stop.
+ */
+#define MAX_CONTINUOUS_ZERO_SLEEP_METRIC_LIMIT 1000
+
/* Messages that can be sent from the main context to the audio thread. */
enum AUDIO_THREAD_COMMAND {
AUDIO_THREAD_ADD_OPEN_DEV,
@@ -783,7 +790,18 @@ static void check_busyloop(struct timespec *wait_ts)
busyloop_count++;
cras_audio_thread_event_busyloop();
}
+ if (continuous_zero_sleep_count ==
+ MAX_CONTINUOUS_ZERO_SLEEP_METRIC_LIMIT)
+ cras_server_metrics_busyloop_length(
+ continuous_zero_sleep_count);
+
} else {
+ if (continuous_zero_sleep_count >=
+ MAX_CONTINUOUS_ZERO_SLEEP_COUNT &&
+ continuous_zero_sleep_count <
+ MAX_CONTINUOUS_ZERO_SLEEP_METRIC_LIMIT)
+ cras_server_metrics_busyloop_length(
+ continuous_zero_sleep_count);
continuous_zero_sleep_count = 0;
}
}