[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/49] scripts/kvm/kvm_stat: Cleanup of platform dete
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 21/49] scripts/kvm/kvm_stat: Cleanup of platform detection |
Date: |
Tue, 26 Jan 2016 14:46:53 +0100 |
From: Janosch Frank <address@hidden>
s390 machines can also be detected via uname -m, i.e. python's
os.uname, no need for more complicated checks.
Calling uname once and saving its value for multiple checks is
perfectly sufficient. We don't expect the machine's architecture to
change when the script is running anyway.
On multi-cpu systems x86_init currently will get called multiple
times, returning makes sure we don't waste cicles on that.
Signed-off-by: Janosch Frank <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
scripts/kvm/kvm_stat | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 93b5ea7..5b6742a 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -254,24 +254,21 @@ def aarch64_init():
EXIT_REASONS = AARCH64_EXIT_REASONS
def detect_platform():
- if os.uname()[4].startswith('ppc'):
+ machine = os.uname()[4]
+
+ if machine.startswith('ppc'):
ppc_init()
- return
- elif os.uname()[4].startswith('aarch64'):
+ elif machine.startswith('aarch64'):
aarch64_init()
- return
-
- for line in file('/proc/cpuinfo').readlines():
- if line.startswith('flags'):
- for flag in line.split():
- if flag in X86_EXIT_REASONS:
- x86_init(flag)
- return
- elif line.startswith('vendor_id'):
- for flag in line.split():
- if flag == 'IBM/S390':
- s390_init()
- return
+ elif machine.startswith('s390'):
+ s390_init()
+ else:
+ for line in file('/proc/cpuinfo').readlines():
+ if line.startswith('flags'):
+ for flag in line.split():
+ if flag in X86_EXIT_REASONS:
+ x86_init(flag)
+ return
def walkdir(path):
--
1.8.3.1
- [Qemu-devel] [PULL 12/49] scripts/kvm/kvm_stat: Invert dictionaries, (continued)
- [Qemu-devel] [PULL 12/49] scripts/kvm/kvm_stat: Invert dictionaries, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 15/49] scripts/kvm/kvm_stat: Introduce main function, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 17/49] scripts/kvm/kvm_stat: Rename variables that redefine globals, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 18/49] scripts/kvm/kvm_stat: Moved DebugfsProvider, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 14/49] scripts/kvm/kvm_stat: Improve debugfs access checking, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 16/49] scripts/kvm/kvm_stat: Fix spaces around keyword assignments, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 20/49] scripts/kvm/kvm_stat: Set sensible no. files rlimit, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 19/49] scripts/kvm/kvm_stat: Fixup syscall error reporting, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 23/49] scripts/kvm/kvm_stat: Rename _perf_event_open, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 22/49] scripts/kvm/kvm_stat: Make cpu detection a function, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 21/49] scripts/kvm/kvm_stat: Cleanup of platform detection,
Paolo Bonzini <=
- [Qemu-devel] [PULL 26/49] scripts/kvm/kvm_stat: Cleanup cpu list retrieval, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 27/49] scripts/kvm/kvm_stat: Encapsulate filters variable, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 25/49] scripts/kvm/kvm_stat: Cleanup of TracepointProvider, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 24/49] scripts/kvm/kvm_stat: Introduce properties for providers, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 30/49] scripts/kvm/kvm_stat: Cleanup of Event class, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 29/49] scripts/kvm/kvm_stat: Cleanup of Groups class, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 28/49] scripts/kvm/kvm_stat: Cleanup of Stats class, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 36/49] scripts/kvm/kvm_stat: Read event values as u64, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 31/49] scripts/kvm/kvm_stat: Group arch specific data, Paolo Bonzini, 2016/01/26
- [Qemu-devel] [PULL 34/49] scripts/kvm/kvm_stat: Fix output formatting, Paolo Bonzini, 2016/01/26