Re: [PATCH 5/9] perf, tools: Add perf download to download event files v2
From: Namhyung Kim
Date: Wed May 14 2014 - 01:18:04 EST
On Mon, 12 May 2014 15:51:10 -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> Add a downloader to automatically download the right
> files from a download site.
>
> This is implemented as a script calling wget, similar to
> perf archive. The perf driver automatically calls the right
> binary. The downloader is extensible, but currently only
> implements an Intel event download. It would be straightforward
> to add other sites too for other vendors.
>
> The downloaded event files are put into ~/.cache/pmu-events, where the
> builtin event parser in util/* can find them automatically.
>
> Cc: Use ~/.cache
???
[SNIP]
> @@ -0,0 +1,52 @@
> +#!/bin/bash
> +# download event files for current cpu for perf
> +
> +WGETOPT=${WGETOPT:---no-verbose --timeout 5}
Could you please extend this script to support curl also? It seems the
wget is not installed by default on my system.
> +
> +set -e
> +
> +if [ "$1" == "" ] ; then
> + S=$(awk '
> +/^vendor/ { V=$3 }
> +/^model/ && $2 == ":" { M=$3 }
> +/^cpu family/ { F = $4 }
Inconsistency in using whitespace..
Thanks,
Namhyung
> +END { printf("%s-%s-%X", V, F, M) }' /proc/cpuinfo)
> +else
> + S="$1"
> +fi
> +V=$(echo $S | ( IFS=- read v f m ; echo $v) )
> +
> +CACHEDIR=${XDG_CACHE_HOME:-~/.cache}
> +[ ! -d $CACHEDIR/pmu-events ] && mkdir -p $CACHEDIR/pmu-events
> +cd $CACHEDIR/pmu-events
> +
> +case "$V" in
> +GenuineIntel)
> + echo "Downloading models file"
> + URLBASE=${URLBASE:-https://download.01.org/perfmon}
> + MAPFILE=${MAPFILE:-mapfile.csv}
> + echo "Downloading readme.txt"
> + wget -N $WGETOPT $URLBASE/readme.txt
> + ;;
> +
> +# Add more CPU vendors here
> +
> +*)
> + echo "Unsupported CPU vendor $V"
> + exit 1
> + ;;
> +esac
> +
> +wget -N $WGETOPT $URLBASE/$MAPFILE
> +
> +echo "Downloading events file"
> +awk -v urlbase=$URLBASE -v cpu="$S" -F, \
> + '$1 == cpu && $4 == "core" { print urlbase $3; exit 0 }' \
> + $MAPFILE > url$$
> +if [ -s url$$ ] ; then
> + wget $WGETOPT -q -i url$$ -O $S-core.json
> +else
> + echo "CPU $S not found"
> +fi
> +rm -f url$$
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/