1#!/bin/sh 2# SPDX-License-Identifier: CDDL-1.0 3 4# 5# This file and its contents are supplied under the terms of the 6# Common Development and Distribution License ("CDDL"), version 1.0. 7# You may only use this file in accordance with the terms of version 8# 1.0 of the CDDL. 9# 10# A full copy of the text of the CDDL should have accompanied this 11# source. A copy of the CDDL is also available via the Internet at 12# http://www.illumos.org/license/CDDL. 13# 14 15# 16# Copyright (c) 2016 by Intel, Corp. 17# 18 19# 20# Linux platform placeholder for collecting prefetch I/O stats 21# TBD if we can add additional kstats to achieve the desired results 22# 23 24getstat() { 25 awk -v c="$1" '$1 == c {print $3; exit}' /proc/spl/kstat/zfs/arcstats 26} 27 28get_prefetch_ios() { 29 echo $(( $(getstat prefetch_data_misses) + $(getstat prefetch_metadata_misses) )) 30} 31 32if [ $# -ne 2 ] 33then 34 echo "Usage: ${0##*/} poolname interval" >&2 35 exit 1 36fi 37 38interval=$2 39prefetch_ios=$(get_prefetch_ios) 40prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch) 41async_upgrade_sync=$(getstat async_upgrade_sync) 42 43while true 44do 45 new_prefetch_ios=$(get_prefetch_ios) 46 printf '%u\n%-24s\t%u\n' "$(date +%s)" "prefetch_ios" \ 47 $(( new_prefetch_ios - prefetch_ios )) 48 prefetch_ios=$new_prefetch_ios 49 50 new_prefetched_demand_reads=$(getstat demand_hit_predictive_prefetch) 51 printf '%-24s\t%u\n' "prefetched_demand_reads" \ 52 $(( new_prefetched_demand_reads - prefetched_demand_reads )) 53 prefetched_demand_reads=$new_prefetched_demand_reads 54 55 new_async_upgrade_sync=$(getstat async_upgrade_sync) 56 printf '%-24s\t%u\n' "async_upgrade_sync" \ 57 $(( new_async_upgrade_sync - async_upgrade_sync )) 58 async_upgrade_sync=$new_async_upgrade_sync 59 60 sleep "$interval" 61done 62