blob: 99d7c82296b102326940f87d3a1124a81f1a2ce1 [file] [log] [blame]
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Run ureadahead in trace mode for ARC++"
author "chromium-os-dev@chromium.org"
# NOTE: this job is not automatically started on boot-up as it is
# expected to be started manually as needed e.g. when the
# android container is started without the pack file for the
# container. This job should not run while arc-ureadahead.conf
# is running. The existence of the pack and the user's opt-in
# status of ARC++ decide if the job runs or not.
stop on arc-booted or stop-arc-instance or stopping ui
# Give ureadahead extra time after SIGTERM to write out the pack file.
kill timeout 30
env LOGFILE=/var/log/arc-ureadahead-trace.log
env ROOT=/opt/google/containers/android/rootfs/root
script
{
echo "Start arc-ureadahead-trace"
set -x
# This is a temporary workaround to make ureadahead in tracing mode
# work with squashfs. The kernel always reports that loopN device is
# backed by a rotational device (HDD) which is not true, and that
# confuses ureadahead.
# TODO(yusukes): Revert this change once the kernel side fix is landed
# (https://chromium-review.googlesource.com/#/c/342531/) to all kernel
# versions we use. Once the patch is landed, queue/rotational will be
# 0 from the beginning.
LOOP_MINOR=$(stat --printf='%D' $ROOT | tail -c 1)
echo 0 > /sys/block/loop$LOOP_MINOR/queue/rotational
exec ureadahead --quiet --force-trace --path-prefix=$ROOT $ROOT
} 2>&1 | logger -t "${UPSTART_JOB}"
end script
post-stop exec logger -t "${UPSTART_JOB}" "Post-stop arc-ureadahead-trace"