Skip to contentSkip to conversation

Apps to read & process kvmppc instruction trace data

kvm-ppc-devel Christian Ehrhardt 1 participant 1 message Apr 14, 2008

lore
Share & tools
lore
#0 lore raw

Based on Hollis tlb tracing from http://penguinppc.org/~hollisb/kvm/ this mail contains a c file that can be used to read the instruction traces into a file (binary) and a python script that processes these binary files to a readable table. @Hollis we might think of merging these and possible following tools of that kind and/or strive to add is to kvm-userspace - what do you think ?

To use the instruction relay stuff, on the host:
# First build a kernel with "ppc440 instruction emulation tracing" enabled as host kernel # then run the guest workload while reading the relay file
% gcc -Wall -O2 44x_instr.c -o 44x_instr
% ./44x_instr > instrlog.bin & # can also be invoked later e.g only around some guest workload part % qemu-system-ppcemb ...
% kill the 44x_instr command

% python decode_instr.py instrlog.bin # can be run on any system

The python script decodes extra informations for some opcodes e.g. sprn for m[ft]spr An example line:

        time:      instr @         pc          rsval          raval          rbval mnemonic - context info
 0.892007422:   7c700aa6 @         1c          0              0              0        mfspr - sprn 0x030      PID
 0.892007422:   7c8000a6 @         20          0              0              0        mfmsr
 0.892007422:   7c72eba6 @         30          0              0              0        mtspr - sprn 0x3b2    MMUCR
 0.892007422:   7ee02f24 @         40          0              0             3c@r05    tlbsx
 0.892007422:   7c6407a4 @         54          0              1@r04          0        tlbwe - ws ->   PAGEID

- Time helps to find relations what the guest did in that moment
- instruction is the full opcode
- pc the program counter helping developers to analyze where that instr came from e.g. check guest image with objdump and look for these addresses
- r*val - the value in the used register, additionally the number of the used register is printed e.g. 1@r04 means r4 is used in that instruction and contains "1"
- mnemonic is the name of that instruction
- context info decodes special information for some instruction types (can be extended as needed)
- sprn for m[ft]spr
- spr name for m[ft]spr
- dcrn for m[ft]dcr
- tlbwe action type encoded in "ws"

Signature · 2 lines
Grüsse / regards, Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* Copyright IBM Corp. 2008
*
* Authors: Hollis Blanchard <[email protected]>
*/

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>

char *relay_file_name = "/sys/kernel/debug/kvm/44x_instr0";

struct instr_record {
        uint32_t time;
        uint32_t pc;
        uint32_t instr;
        uint32_t rsval;
        uint32_t raval;
        uint32_t rbval;
};

int main(int argc, char **argv)

{
	char buf[4096];
	int relay_file;
	int rc;

	relay_file = open(relay_file_name, O_RDONLY | O_NONBLOCK);
	if (relay_file < 0) {
		printf("Couldn't open relay file %s: errcode = %s\n",
		       relay_file_name, strerror(errno));
		return -1;
	}

	do {
		rc = read(relay_file, buf, sizeof(struct instr_record));
		if (rc < 0) {
			perror("read");
			continue;
		} else if (rc > 0) {
			write(fileno(stdout), buf, rc);
			continue;
		}
		fsync(fileno(stdout));
		usleep(1000);
	} while (1);

	close(relay_file);
}

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
kvm-ppc-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel