Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pytorch/cpuinfo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@gmail.com>2017-11-27 10:48:13 +0300
committerMarat Dukhan <maratek@gmail.com>2017-11-27 10:48:13 +0300
commite009ce826df331c0629e6ba42c1fab36356f65f5 (patch)
tree59b5b5193f95adffbaf950f2f01a5cb6895b570d /scripts
parent89d1e6cdb0a76a355138ec716521deaa6cc5f69f (diff)
Update Android device dump script
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/android-filesystem-dump.py126
1 files changed, 112 insertions, 14 deletions
diff --git a/scripts/android-filesystem-dump.py b/scripts/android-filesystem-dump.py
index 52d4fb9..c0c5d45 100755
--- a/scripts/android-filesystem-dump.py
+++ b/scripts/android-filesystem-dump.py
@@ -2,6 +2,7 @@
import os
import sys
+import string
import argparse
import subprocess
import tempfile
@@ -18,14 +19,65 @@ SYSTEM_FILES = [
"/sys/devices/system/cpu/kernel_max",
"/sys/devices/system/cpu/possible",
"/sys/devices/system/cpu/present",
+ "/sys/devices/system/cpu/online",
+ "/sys/devices/system/cpu/offline",
+ "/sys/devices/system/cpu/modalias",
+ "/sys/devices/system/cpu/cpufreq/all_time_in_state",
+ "/sys/devices/system/cpu/cpufreq/current_in_state",
+ "/sys/devices/system/cpu/cpuidle/current_driver",
+ "/sys/devices/system/cpu/cpuidle/current_governor_ro",
+ "/sys/devices/system/cpu/cputopo/cpus_per_cluster",
+ "/sys/devices/system/cpu/cputopo/big_cpumask",
+ "/sys/devices/system/cpu/cputopo/glbinfo",
+ "/sys/devices/system/cpu/cputopo/is_big_little",
+ "/sys/devices/system/cpu/cputopo/is_multi_cluster",
+ "/sys/devices/system/cpu/cputopo/little_cpumask",
+ "/sys/devices/system/cpu/cputopo/nr_clusters",
+ "/sys/devices/system/b.L/big_threads",
+ "/sys/devices/system/b.L/boot_cluster",
+ "/sys/devices/system/b.L/core_status",
+ "/sys/devices/system/b.L/little_threads",
+ "/sys/devices/system/b.L/down_migrations",
+ "/sys/devices/system/b.L/up_migrations",
+ "/sys/devices/system/cpu/clusterhotplug/cur_hstate",
+ "/sys/devices/system/cpu/clusterhotplug/down_freq",
+ "/sys/devices/system/cpu/clusterhotplug/down_tasks",
+ "/sys/devices/system/cpu/clusterhotplug/down_threshold",
+ "/sys/devices/system/cpu/clusterhotplug/sampling_rate",
+ "/sys/devices/system/cpu/clusterhotplug/time_in_state",
+ "/sys/devices/system/cpu/clusterhotplug/up_freq",
+ "/sys/devices/system/cpu/clusterhotplug/up_tasks",
+ "/sys/devices/system/cpu/clusterhotplug/up_threshold",
]
CPU_FILES = [
+ "current_driver",
+ "current_governor_ro",
+ "cpuidle/driver/name",
+ "cpufreq/affected_cpus",
"cpufreq/cpuinfo_max_freq",
"cpufreq/cpuinfo_min_freq",
- "topology/physical_package_id",
- "topology/core_siblings_list",
+ "cpufreq/cpuinfo_transition_latency",
+ "cpufreq/related_cpus",
+ "cpufreq/scaling_available_frequencies",
+ "cpufreq/scaling_available_governors",
+ "cpufreq/scaling_cur_freq",
+ "cpufreq/scaling_driver",
+ "cpufreq/scaling_governor",
+ "cpufreq/scaling_max_freq",
+ "cpufreq/scaling_min_freq",
+ "cpufreq/sched/down_throttle_nsec",
+ "cpufreq/sched/up_throttle_nsec",
+ "cpufreq/stats/time_in_state",
+ "cpufreq/stats/total_trans",
+ "cpufreq/stats/trans_table",
"topology/core_id",
+ "topology/core_siblings",
+ "topology/core_siblings_list",
+ "topology/cpu_capacity",
+ "topology/max_cpu_capacity",
+ "topology/physical_package_id",
+ "topology/thread_siblings",
"topology/thread_siblings_list",
]
@@ -35,6 +87,7 @@ CACHE_FILES = [
"level",
"number_of_sets",
"shared_cpu_list",
+ "shared_cpu_map",
"size",
"type",
"ways_of_associativity",
@@ -70,6 +123,24 @@ def adb_pull(device_path, local_path):
adb.communicate()
return adb.returncode == 0
+def adb_shell(commands):
+ env = os.environ.copy()
+ env["LC_ALL"] = "C"
+
+ adb = subprocess.Popen(["adb", "shell"] + commands, env=env, stdout=subprocess.PIPE)
+ stdout, _ = adb.communicate()
+ if adb.returncode == 0:
+ return stdout
+
+def adb_getprop():
+ properties = adb_shell(["getprop"])
+ properties_list = list()
+ for prop in properties.splitlines():
+ prop = prop.strip()
+ if prop:
+ key, value = tuple(map(string.strip, prop.split(":", 1)))
+ properties_list.append((key, value))
+ return properties_list
def dump_device_file(stream, path):
temp_fd, temp_path = tempfile.mkstemp()
@@ -89,34 +160,61 @@ def dump_device_file(stream, path):
else:
stream.write("\t\t.content = \"%s\",\n" % c_escape(content))
stream.write("\t},\n")
- return True
+ return content
finally:
- os.remove(temp_path)
+ if os.path.exists(temp_path):
+ os.remove(temp_path)
def main(args):
options = parser.parse_args(args)
- # with open(os.path.join("test", "dmesg", options.prefix + ".log"), "w") as dmesg_log:
- # dmesg_log.write(device.Shell("dmesg"))
- with open(os.path.join("test", options.prefix + ".h"), "w") as file_header:
+ dmesg_content = adb_shell(["dmesg"])
+ if dmesg_content is not None:
+ with open(os.path.join("test", "dmesg", options.prefix + ".log"), "w") as dmesg_dump:
+ dmesg_dump.write(dmesg_content)
+
+ build_prop_content = None
+ proc_cpuinfo_content = None
+ kernel_max = 0
+ with open(os.path.join("test", "mock", options.prefix + ".h"), "w") as file_header:
file_header.write("struct cpuinfo_mock_file filesystem[] = {\n")
for path in SYSTEM_FILES:
- dump_device_file(file_header, path)
- for cpu in range(16):
+ content = dump_device_file(file_header, path)
+ if content is not None:
+ if path == "/proc/cpuinfo":
+ proc_cpuinfo_content = content
+ elif path == "/system/build.prop":
+ build_prop_content = content
+ elif path == "/sys/devices/system/cpu/kernel_max":
+ kernel_max = int(content.strip())
+ for cpu in range(kernel_max + 1):
for filename in CPU_FILES:
path = "/sys/devices/system/cpu/cpu%d/%s" % (cpu, filename)
dump_device_file(file_header, path)
- for index in range(10):
+ for index in range(5):
for filename in CACHE_FILES:
path = "/sys/devices/system/cpu/cpu%d/cache/index%d/%s" % (cpu, index, filename)
dump_device_file(file_header, path)
file_header.write("\t{ NULL },\n")
file_header.write("};\n")
- adb_pull("/proc/cpuinfo",
- os.path.join("test", "cpuinfo", options.prefix + ".log"))
- adb_pull("/system/build.prop",
- os.path.join("test", "build.prop", options.prefix + ".log"))
+ file_header.write("#ifdef __ANDROID__\n")
+ file_header.write("struct cpuinfo_mock_property properties[] = {\n")
+ for key, value in adb_getprop():
+ file_header.write("\t{\n")
+ file_header.write("\t\t.key = \"%s\",\n" % c_escape(key))
+ file_header.write("\t\t.value = \"%s\",\n" % c_escape(value))
+ file_header.write("\t},\n")
+ file_header.write("\t{ NULL },\n")
+ file_header.write("};\n")
+ file_header.write("#endif /* __ANDROID__ */\n")
+
+ if proc_cpuinfo_content is not None:
+ with open(os.path.join("test", "cpuinfo", options.prefix + ".log"), "w") as proc_cpuinfo_dump:
+ proc_cpuinfo_dump.write(proc_cpuinfo_content)
+ if build_prop_content is not None:
+ with open(os.path.join("test", "build.prop", options.prefix + ".log"), "w") as build_prop_dump:
+ build_prop_dump.write(build_prop_content)
if __name__ == "__main__":
main(sys.argv[1:])