lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 18 Jul 2014 16:28:40 +1000
From:	Michael Ellerman <mpe@...erman.id.au>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	jolsa@...hat.com, linux-kernel@...r.kernel.org,
	namhyung@...nel.org, acme@...radead.org,
	Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 07/11] perf, tools: Add perf download to download event
 files

On Fri, 2014-07-11 at 16:59 -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@...ux.intel.com>
> 
> Add a downloader to automatically download the right
> files from a download site.
...
> diff --git a/tools/perf/Documentation/perf-download.txt b/tools/perf/Documentation/perf-download.txt
> new file mode 100644
> index 0000000..9e5b28e
> --- /dev/null
> +++ b/tools/perf/Documentation/perf-download.txt
> @@ -0,0 +1,31 @@
> +perf-download(1)
> +===============
> +
> +NAME
> +----
> +perf-download - Download event files for current CPU.
> +
> +SYNOPSIS
> +--------
> +[verse]
> +'perf download' [vendor-family-model]

Can you make that arch agnostic? eg:

> +'perf download' [cpu-identifier]

> diff --git a/tools/perf/perf-download.sh b/tools/perf/perf-download.sh
> new file mode 100755
> index 0000000..269dc96
> --- /dev/null
> +++ b/tools/perf/perf-download.sh
> @@ -0,0 +1,57 @@
> +#!/bin/bash
> +# download event files for current cpu for perf
> +
> +CURLOPT=${CURLOPT:- --max-time 5 -#}
> +
> +set -e
> +
> +if ! type curl > /dev/null ; then
> +	echo "please install curl"
> +	exit 1
> +fi
> +
> +if [ "$1" == "" ] ; then
> +	S=$(awk '
> +/^vendor/     		{ V=$3 }
> +/^model/ && $2 == ":" 	{ M=$3 }
> +/^cpu family/ 		{ F = $4 }
> +END	      		{ printf("%s-%s-%X", V, F, M) }' /proc/cpuinfo)
> +else
> +	S="$1"
> +fi
> +V=$(echo $S  | ( IFS=- read v f m ; echo $v) )

This obviously needs a bit of work to support other arches. I'm thinking we use
uname -m to do a top level switch? eg:

  ARCH=$(uname -m | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/)
  
  if [ "$ARCH" == "x86_64" ] || [ "$ARCH" == "i386" ]; then
          S=$(awk '/^vendor/              { V=$3 }
                   /^model/ && $2 == ":"  { M=$3 }
                   /^cpu family/          { F = $4 }
                   END                    { printf("%s-%s-%X", V, F, M) }' /proc/cpuinfo)
  elif [ "$ARCH" == "powerpc" ]; then
          ...
  fi

> +case "$V" in
> +GenuineIntel)
> +	echo "Downloading models file"
> +	URLBASE=${URLBASE:-https://download.01.org/perfmon}
> +	MAPFILE=${MAPFILE:-mapfile.csv}
> +	echo "Downloading readme.txt"
> +	curl $CURLOPT $URLBASE/readme.txt -o readme.txt
> +	;;
> +
> +# Add more CPU vendors here
> +
> +*)
> +	echo "Unsupported CPU vendor $V"
> +	exit 1
> +	;;
> +esac
> +
> +curl $CURLOPT $URLBASE/$MAPFILE -o $MAPFILE
> +
> +echo "Downloading events file"
> +awk -v urlbase=$URLBASE -v cpu="$S" -F, \
> +	'$1 == cpu && $4 == "core" { print "url = \"" urlbase $3 "\""; exit 0 }' \
> +	$MAPFILE > url$$
> +if [ -s url$$ ] ; then
> +	curl $CURLOPT -K url$$ -o $S-core.json
> +else
> +	echo "CPU $S not found"
> +fi

I'm not 100% sure, but I think we will want to use our PVR register as the
lookup key. That's just a hex value, with major and minor versions.

To make that work I think we will want a loop in the map lookup to handle
chopping off the low bits.

So for example it would check the MAPFILE for:
  003e0301
  003e030
  003e03
  003e0

etc.

So we might need another arch specific chunk in there.

cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ