diff options
| author | Kieran Bingham <kieran.bingham@linaro.org> | 2016-05-23 19:25:02 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-23 20:04:14 -0400 |
| commit | b1503934a5e51e74b2f4c72ad77b33231e7b6953 (patch) | |
| tree | 2a7051cec78c1b468eb8d2feabd5c2bf6921abee /scripts/gdb | |
| parent | c1a153992ea86307d2b8c3c0be2e060102b02aff (diff) | |
scripts/gdb: add cpu iterators
The linux kernel provides macro's for iterating against values from the
cpu_list masks. By providing some commonly used masks, we can mirror
the kernels helper macros with easy to use generators.
Link: http://lkml.kernel.org/r/d045c6599771ada1999d49612ee30fd2f9acf17f.1462865983.git.jan.kiszka@siemens.com
Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb')
| -rw-r--r-- | scripts/gdb/linux/cpus.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 4297b83fedef..fc316fb3a3d4 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py | |||
| @@ -100,6 +100,44 @@ def cpu_list(mask_name): | |||
| 100 | yield cpu | 100 | yield cpu |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | def each_online_cpu(): | ||
| 104 | for cpu in cpu_list("__cpu_online_mask"): | ||
| 105 | yield cpu | ||
| 106 | |||
| 107 | |||
| 108 | def each_present_cpu(): | ||
| 109 | for cpu in cpu_list("__cpu_present_mask"): | ||
| 110 | yield cpu | ||
| 111 | |||
| 112 | |||
| 113 | def each_possible_cpu(): | ||
| 114 | for cpu in cpu_list("__cpu_possible_mask"): | ||
| 115 | yield cpu | ||
| 116 | |||
| 117 | |||
| 118 | def each_active_cpu(): | ||
| 119 | for cpu in cpu_list("__cpu_active_mask"): | ||
| 120 | yield cpu | ||
| 121 | |||
| 122 | |||
| 123 | class LxCpus(gdb.Command): | ||
| 124 | """List CPU status arrays | ||
| 125 | |||
| 126 | Displays the known state of each CPU based on the kernel masks | ||
| 127 | and can help identify the state of hotplugged CPUs""" | ||
| 128 | |||
| 129 | def __init__(self): | ||
| 130 | super(LxCpus, self).__init__("lx-cpus", gdb.COMMAND_DATA) | ||
| 131 | |||
| 132 | def invoke(self, arg, from_tty): | ||
| 133 | gdb.write("Possible CPUs : {}\n".format(list(each_possible_cpu()))) | ||
| 134 | gdb.write("Present CPUs : {}\n".format(list(each_present_cpu()))) | ||
| 135 | gdb.write("Online CPUs : {}\n".format(list(each_online_cpu()))) | ||
| 136 | gdb.write("Active CPUs : {}\n".format(list(each_active_cpu()))) | ||
| 137 | |||
| 138 | LxCpus() | ||
| 139 | |||
| 140 | |||
| 103 | class PerCpu(gdb.Function): | 141 | class PerCpu(gdb.Function): |
| 104 | """Return per-cpu variable. | 142 | """Return per-cpu variable. |
| 105 | 143 | ||
