def __enter__(self): if self.kvmTrace is True: from mparts.util import maybeMakedirs resultDir = self.traceFile[:self.traceFile.rfind("/"):] maybeMakedirs(resultDir) print >> sys.stderr, "kvm trace begins..." traceCmd = ["trace-cmd", "record", "-b", "200000", "-e", "kvm", "-o", self.traceFile] self.__traceProc = self.host.sudo.run(traceCmd, wait=False) time.sleep(2)
def __enter__(self): if self.kvmTrace is True: from mparts.util import maybeMakedirs resultDir = self.traceFile[:self.traceFile.rfind("/"):] maybeMakedirs(resultDir) print >> sys.stderr, "kvm trace begins..." traceCmd = [ "trace-cmd", "record", "-b", "200000", "-e", "kvm", "-o", self.traceFile ] self.__traceProc = self.host.sudo.run(traceCmd, wait=False) time.sleep(2)
def __enter__(self): if self.perfRecord is True: from mparts.util import maybeMakedirs resultDir = self.perfFile[:self.perfFile.rfind("/"):] maybeMakedirs(resultDir) print >> sys.stderr, "perf record begins..." if self.perfKVMRec is False and self.guestOnlyRec is False: self.__perfProc = self.host.sudo.run([ self.perfBin, "record", "-F", "100", "-a", "--call-graph", "dwarf", "-o", self.perfFile ], wait=False) elif self.perfKVMRec is True and self.guestOnlyRec is False: # need to scp both guest.modules and guest.kallsyms guestSyms = "guest.kallsyms" guestModules = "guest.modules" def getFileFromGuest(fileName, dst): self.host.r.run([ "ssh", "-p", str(SSHPORT), "root@localhost", "cat /proc/%s" % fileName, ">", dst ]) self.host.r.run([ "scp", "-P", str(SSHPORT), "root@localhost:~/%s" % dst, resultDir ]) getFileFromGuest("kallsyms", guestSyms) getFileFromGuest("modules", guestModules) self.__perfProc = self.host.sudo.run([ self.perfBin, "kvm", "--host", "--guest", "--guestkallsyms=%s" % (os.path.join(resultDir, guestSyms)), "--guestmodules=%s" % (os.path.join(resultDir, guestModules)), "record", "-ag", "-F", "100", "-o", self.perfFile ], wait=False) elif self.perfKVMRec is False and self.guestOnlyRec is True: print "yet to implement" else: print "you can't have both apple and orange"
def __enter__(self): if self.perfRecord is True: from mparts.util import maybeMakedirs resultDir = self.perfFile[:self.perfFile.rfind("/"):] maybeMakedirs(resultDir) print >> sys.stderr, "perf record begins..." if self.perfKVMRec is False and self.guestOnlyRec is False: self.__perfProc = self.host.sudo.run([self.perfBin, "record", "-F", "100", "-a", "--call-graph", "dwarf", "-o", self.perfFile], wait=False) elif self.perfKVMRec is True and self.guestOnlyRec is False: # need to scp both guest.modules and guest.kallsyms guestSyms = "guest.kallsyms" guestModules = "guest.modules" def getFileFromGuest(fileName, dst): self.host.r.run( ["ssh", "-p", str(SSHPORT), "root@localhost", "cat /proc/%s" % fileName, ">", dst]) self.host.r.run( ["scp", "-P", str(SSHPORT), "root@localhost:~/%s" % dst, resultDir]) getFileFromGuest("kallsyms", guestSyms) getFileFromGuest("modules", guestModules) self.__perfProc = self.host.sudo.run([self.perfBin, "kvm", "--host", "--guest", "--guestkallsyms=%s" % (os.path.join(resultDir, guestSyms)), "--guestmodules=%s" % (os.path.join(resultDir, guestModules)), "record", "-ag", "-F", "100", "-o", self.perfFile], wait=False) elif self.perfKVMRec is False and self.guestOnlyRec is True: print "yet to implement" else: print "you can't have both apple and orange"
def wait(self, m): logPath = self.host.getLogPath(self) perfproc = None guestperfproc = None with Progress("Starting vm"): import time # Boot vm # TODO: Fix the number generation for qmp and ssh port for VMs absBenchRoot = os.path.abspath(".") vmProc = QemuVMDeamon(self.host, absBenchRoot, "ubuntu-server.img", self.vmcores, self.threads, self.sockets, 4444, 5555, 1) vmProc.startVM() self.vmProcs.append(vmProc) # checking for oversubscribed cloud case if self.multiVM is True: vmProcNew = QemuVMDeamon(self.host, absBenchRoot, "ubuntu-server-copy.img", self.vmcores, self.threads, self.sockets, 4445, 5556, 2) vmProcNew.startVM() self.vmProcs.append(vmProcNew) print "wait for VM to come up, sleeping 46 seconds" # Lets sleep for sometime as the VM booting takes some time self.host.r.run(['sleep', '1']) time.sleep(1) if self.qpin is True: for proc in self.vmProcs: proc.pinVCPUs() time.sleep(45) with Progress("Preparing build"): # mount tmpfs-separate def prepare(sshPort="5555"): self.host.r.run([ "ssh", "-p", sshPort, "root@localhost", 'sudo ./mkmounts tmpfs-separate' ]) # prefetch the directories self.host.r.run([ "ssh", "-p", sshPort, "root@localhost", './prefetch -r -x "*/.git" bench/fs-bench/tmp/linux-3.18/' ]) # # Gen defconfig self.host.r.run(self.__cmd("defconfig", sshPort)) # Build init/main.o first. This gets most of the serial # early build stages out of th way. self.host.r.run(self.__cmd("init/main.o", sshPort), stdout=logPath) prepare() if self.multiVM is True: prepare("5556") # Build for real # # XXX If we want to eliminate the serial startup, monitor # starting with " CHK include/generated/compile.h" or maybe # with the first " CC" line. #self.host.sudo.run() self.host.sudo.run([ 'mount', '-o', 'remount,mode=0755', '-t', 'debugfs', 'nodev', '/sys/kernel/debug' ]) # get the kallsyms and kmodules of guest proc = mparts.vmstat.StartMonitor("KVMNumbers", "data.csv") if self.lockStats is not None: self.lockStats.allowCollectLockStatsHost(0) self.lockStats.cleanLockStats() self.lockStats.allowCollectLockStatsHost(1) if self.multiVM is True: mparts.vmstat.StartLKC("5556", self.cores, self.srcPath, self.objPath) perfFile = os.path.join(os.path.abspath("."), self.resultPath, "perf-gmakeqemu-%s.dat" % self.cores) traceFile = os.path.join(os.path.abspath("."), self.resultPath, "kvmtrace-gmake-%s.dat" % self.cores) with PerfRecording(self.host, perfFile, self.perfRecord, self.perfBin, self.perfKVMRec, self.perfGuestRec): with KVMTrace(self.host, traceFile, self.kvmTrace): self.host.r.run(self.sysmon.wrap(self.__cmd("vmlinux")), stdout=logPath) if self.lockStats is not None: self.lockStats.dumpLockStats( os.path.join(self.resultPath, "lock-stats-%s" % (self.cores))) self.lockStats.allowCollectLockStatsHost(0) mparts.vmstat.TerminateMonitor(proc) # Get result log = self.host.r.readFile(logPath) self.sysmonOut = self.sysmon.parseLog(log) self.setResults(1, "build", "builds", self.sysmonOut["time.real"]) maybeMakedirs(self.resultPath) os.rename("data.csv", os.path.join(self.resultPath, "data.csv")) with Progress("Stopping vm"): for proc in self.vmProcs: proc.stopVM()
def wait(self, m): logPath = self.host.getLogPath(self) perfproc = None guestperfproc = None with Progress("Starting vm"): import time # Boot vm # TODO: Fix the number generation for qmp and ssh port for VMs absBenchRoot = os.path.abspath(".") vmProc = QemuVMDeamon(self.host, absBenchRoot, "ubuntu-server.img", self.vmcores, self.threads, self.sockets, 4444, 5555, 1) vmProc.startVM() self.vmProcs.append(vmProc) # checking for oversubscribed cloud case if self.multiVM is True: vmProcNew = QemuVMDeamon(self.host, absBenchRoot, "ubuntu-server-copy.img", self.vmcores, self.threads, self.sockets, 4445, 5556, 2) vmProcNew.startVM() self.vmProcs.append(vmProcNew) print "wait for VM to come up, sleeping 46 seconds" # Lets sleep for sometime as the VM booting takes some time self.host.r.run(['sleep', '1']) time.sleep(1) if self.qpin is True: for proc in self.vmProcs: proc.pinVCPUs() time.sleep(45) with Progress("Preparing build"): # mount tmpfs-separate def prepare(sshPort="5555"): self.host.r.run(["ssh", "-p", sshPort, "root@localhost", 'sudo ./mkmounts tmpfs-separate']) # prefetch the directories self.host.r.run(["ssh", "-p", sshPort, "root@localhost", './prefetch -r -x "*/.git" bench/fs-bench/tmp/linux-3.18/']) # # Gen defconfig self.host.r.run(self.__cmd("defconfig", sshPort)) # Build init/main.o first. This gets most of the serial # early build stages out of th way. self.host.r.run(self.__cmd("init/main.o", sshPort), stdout = logPath) prepare(); if self.multiVM is True: prepare("5556") # Build for real # # XXX If we want to eliminate the serial startup, monitor # starting with " CHK include/generated/compile.h" or maybe # with the first " CC" line. #self.host.sudo.run() self.host.sudo.run(['mount', '-o', 'remount,mode=0755', '-t', 'debugfs', 'nodev', '/sys/kernel/debug']) # get the kallsyms and kmodules of guest proc = mparts.vmstat.StartMonitor("KVMNumbers", "data.csv") if self.lockStats is not None: self.lockStats.allowCollectLockStatsHost(0) self.lockStats.cleanLockStats() self.lockStats.allowCollectLockStatsHost(1) if self.multiVM is True: mparts.vmstat.StartLKC("5556", self.cores, self.srcPath, self.objPath) perfFile = os.path.join(os.path.abspath("."), self.resultPath, "perf-gmakeqemu-%s.dat" % self.cores) traceFile = os.path.join(os.path.abspath("."), self.resultPath, "kvmtrace-gmake-%s.dat" % self.cores) with PerfRecording(self.host, perfFile, self.perfRecord, self.perfBin, self.perfKVMRec, self.perfGuestRec): with KVMTrace(self.host, traceFile, self.kvmTrace): self.host.r.run(self.sysmon.wrap(self.__cmd("vmlinux")), stdout = logPath) if self.lockStats is not None: self.lockStats.dumpLockStats(os.path.join(self.resultPath, "lock-stats-%s" % (self.cores))) self.lockStats.allowCollectLockStatsHost(0) mparts.vmstat.TerminateMonitor(proc) # Get result log = self.host.r.readFile(logPath) self.sysmonOut = self.sysmon.parseLog(log) self.setResults(1, "build", "builds", self.sysmonOut["time.real"]) maybeMakedirs(self.resultPath) os.rename("data.csv", os.path.join(self.resultPath, "data.csv")) with Progress("Stopping vm"): for proc in self.vmProcs: proc.stopVM()