Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 1 | #include "builtin.h" |
| 2 | #include "perf.h" |
| 3 | |
| 4 | #include "util/util.h" |
| 5 | #include "util/cache.h" |
| 6 | #include "util/symbol.h" |
| 7 | #include "util/thread.h" |
| 8 | #include "util/header.h" |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 9 | #include "util/session.h" |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 10 | |
| 11 | #include "util/parse-options.h" |
| 12 | #include "util/trace-event.h" |
| 13 | |
| 14 | #include "util/debug.h" |
| 15 | #include "util/data_map.h" |
| 16 | |
| 17 | #include <linux/rbtree.h> |
| 18 | |
| 19 | struct alloc_stat; |
| 20 | typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *); |
| 21 | |
| 22 | static char const *input_name = "perf.data"; |
| 23 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 24 | static u64 sample_type; |
| 25 | |
| 26 | static int alloc_flag; |
| 27 | static int caller_flag; |
| 28 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 29 | static int alloc_lines = -1; |
| 30 | static int caller_lines = -1; |
| 31 | |
Li Zefan | 7707b6b | 2009-11-24 13:25:48 +0800 | [diff] [blame] | 32 | static bool raw_ip; |
| 33 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 34 | static char default_sort_order[] = "frag,hit,bytes"; |
| 35 | |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 36 | static int *cpunode_map; |
| 37 | static int max_cpu_num; |
| 38 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 39 | struct alloc_stat { |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 40 | u64 call_site; |
| 41 | u64 ptr; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 42 | u64 bytes_req; |
| 43 | u64 bytes_alloc; |
| 44 | u32 hit; |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 45 | u32 pingpong; |
| 46 | |
| 47 | short alloc_cpu; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 48 | |
| 49 | struct rb_node node; |
| 50 | }; |
| 51 | |
| 52 | static struct rb_root root_alloc_stat; |
| 53 | static struct rb_root root_alloc_sorted; |
| 54 | static struct rb_root root_caller_stat; |
| 55 | static struct rb_root root_caller_sorted; |
| 56 | |
| 57 | static unsigned long total_requested, total_allocated; |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 58 | static unsigned long nr_allocs, nr_cross_allocs; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 59 | |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 60 | #define PATH_SYS_NODE "/sys/devices/system/node" |
| 61 | |
| 62 | static void init_cpunode_map(void) |
| 63 | { |
| 64 | FILE *fp; |
| 65 | int i; |
| 66 | |
| 67 | fp = fopen("/sys/devices/system/cpu/kernel_max", "r"); |
| 68 | if (!fp) { |
| 69 | max_cpu_num = 4096; |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | if (fscanf(fp, "%d", &max_cpu_num) < 1) |
| 74 | die("Failed to read 'kernel_max' from sysfs"); |
| 75 | max_cpu_num++; |
| 76 | |
| 77 | cpunode_map = calloc(max_cpu_num, sizeof(int)); |
| 78 | if (!cpunode_map) |
| 79 | die("calloc"); |
| 80 | for (i = 0; i < max_cpu_num; i++) |
| 81 | cpunode_map[i] = -1; |
| 82 | fclose(fp); |
| 83 | } |
| 84 | |
| 85 | static void setup_cpunode_map(void) |
| 86 | { |
| 87 | struct dirent *dent1, *dent2; |
| 88 | DIR *dir1, *dir2; |
| 89 | unsigned int cpu, mem; |
| 90 | char buf[PATH_MAX]; |
| 91 | |
| 92 | init_cpunode_map(); |
| 93 | |
| 94 | dir1 = opendir(PATH_SYS_NODE); |
| 95 | if (!dir1) |
| 96 | return; |
| 97 | |
| 98 | while (true) { |
| 99 | dent1 = readdir(dir1); |
| 100 | if (!dent1) |
| 101 | break; |
| 102 | |
| 103 | if (sscanf(dent1->d_name, "node%u", &mem) < 1) |
| 104 | continue; |
| 105 | |
| 106 | snprintf(buf, PATH_MAX, "%s/%s", PATH_SYS_NODE, dent1->d_name); |
| 107 | dir2 = opendir(buf); |
| 108 | if (!dir2) |
| 109 | continue; |
| 110 | while (true) { |
| 111 | dent2 = readdir(dir2); |
| 112 | if (!dent2) |
| 113 | break; |
| 114 | if (sscanf(dent2->d_name, "cpu%u", &cpu) < 1) |
| 115 | continue; |
| 116 | cpunode_map[cpu] = mem; |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 121 | static void insert_alloc_stat(unsigned long call_site, unsigned long ptr, |
| 122 | int bytes_req, int bytes_alloc, int cpu) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 123 | { |
| 124 | struct rb_node **node = &root_alloc_stat.rb_node; |
| 125 | struct rb_node *parent = NULL; |
| 126 | struct alloc_stat *data = NULL; |
| 127 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 128 | while (*node) { |
| 129 | parent = *node; |
| 130 | data = rb_entry(*node, struct alloc_stat, node); |
| 131 | |
| 132 | if (ptr > data->ptr) |
| 133 | node = &(*node)->rb_right; |
| 134 | else if (ptr < data->ptr) |
| 135 | node = &(*node)->rb_left; |
| 136 | else |
| 137 | break; |
| 138 | } |
| 139 | |
| 140 | if (data && data->ptr == ptr) { |
| 141 | data->hit++; |
| 142 | data->bytes_req += bytes_req; |
| 143 | data->bytes_alloc += bytes_req; |
| 144 | } else { |
| 145 | data = malloc(sizeof(*data)); |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 146 | if (!data) |
| 147 | die("malloc"); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 148 | data->ptr = ptr; |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 149 | data->pingpong = 0; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 150 | data->hit = 1; |
| 151 | data->bytes_req = bytes_req; |
| 152 | data->bytes_alloc = bytes_alloc; |
| 153 | |
| 154 | rb_link_node(&data->node, parent, node); |
| 155 | rb_insert_color(&data->node, &root_alloc_stat); |
| 156 | } |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 157 | data->call_site = call_site; |
| 158 | data->alloc_cpu = cpu; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | static void insert_caller_stat(unsigned long call_site, |
| 162 | int bytes_req, int bytes_alloc) |
| 163 | { |
| 164 | struct rb_node **node = &root_caller_stat.rb_node; |
| 165 | struct rb_node *parent = NULL; |
| 166 | struct alloc_stat *data = NULL; |
| 167 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 168 | while (*node) { |
| 169 | parent = *node; |
| 170 | data = rb_entry(*node, struct alloc_stat, node); |
| 171 | |
| 172 | if (call_site > data->call_site) |
| 173 | node = &(*node)->rb_right; |
| 174 | else if (call_site < data->call_site) |
| 175 | node = &(*node)->rb_left; |
| 176 | else |
| 177 | break; |
| 178 | } |
| 179 | |
| 180 | if (data && data->call_site == call_site) { |
| 181 | data->hit++; |
| 182 | data->bytes_req += bytes_req; |
| 183 | data->bytes_alloc += bytes_req; |
| 184 | } else { |
| 185 | data = malloc(sizeof(*data)); |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 186 | if (!data) |
| 187 | die("malloc"); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 188 | data->call_site = call_site; |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 189 | data->pingpong = 0; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 190 | data->hit = 1; |
| 191 | data->bytes_req = bytes_req; |
| 192 | data->bytes_alloc = bytes_alloc; |
| 193 | |
| 194 | rb_link_node(&data->node, parent, node); |
| 195 | rb_insert_color(&data->node, &root_caller_stat); |
| 196 | } |
| 197 | } |
| 198 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 199 | static void process_alloc_event(void *data, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 200 | struct event *event, |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 201 | int cpu, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 202 | u64 timestamp __used, |
| 203 | struct thread *thread __used, |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 204 | int node) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 205 | { |
| 206 | unsigned long call_site; |
| 207 | unsigned long ptr; |
| 208 | int bytes_req; |
| 209 | int bytes_alloc; |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 210 | int node1, node2; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 211 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 212 | ptr = raw_field_value(event, "ptr", data); |
| 213 | call_site = raw_field_value(event, "call_site", data); |
| 214 | bytes_req = raw_field_value(event, "bytes_req", data); |
| 215 | bytes_alloc = raw_field_value(event, "bytes_alloc", data); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 216 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 217 | insert_alloc_stat(call_site, ptr, bytes_req, bytes_alloc, cpu); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 218 | insert_caller_stat(call_site, bytes_req, bytes_alloc); |
| 219 | |
| 220 | total_requested += bytes_req; |
| 221 | total_allocated += bytes_alloc; |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 222 | |
| 223 | if (node) { |
| 224 | node1 = cpunode_map[cpu]; |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 225 | node2 = raw_field_value(event, "node", data); |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 226 | if (node1 != node2) |
| 227 | nr_cross_allocs++; |
| 228 | } |
| 229 | nr_allocs++; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 230 | } |
| 231 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 232 | static int ptr_cmp(struct alloc_stat *, struct alloc_stat *); |
| 233 | static int callsite_cmp(struct alloc_stat *, struct alloc_stat *); |
| 234 | |
| 235 | static struct alloc_stat *search_alloc_stat(unsigned long ptr, |
| 236 | unsigned long call_site, |
| 237 | struct rb_root *root, |
| 238 | sort_fn_t sort_fn) |
| 239 | { |
| 240 | struct rb_node *node = root->rb_node; |
| 241 | struct alloc_stat key = { .ptr = ptr, .call_site = call_site }; |
| 242 | |
| 243 | while (node) { |
| 244 | struct alloc_stat *data; |
| 245 | int cmp; |
| 246 | |
| 247 | data = rb_entry(node, struct alloc_stat, node); |
| 248 | |
| 249 | cmp = sort_fn(&key, data); |
| 250 | if (cmp < 0) |
| 251 | node = node->rb_left; |
| 252 | else if (cmp > 0) |
| 253 | node = node->rb_right; |
| 254 | else |
| 255 | return data; |
| 256 | } |
| 257 | return NULL; |
| 258 | } |
| 259 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 260 | static void process_free_event(void *data, |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 261 | struct event *event, |
| 262 | int cpu, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 263 | u64 timestamp __used, |
| 264 | struct thread *thread __used) |
| 265 | { |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 266 | unsigned long ptr; |
| 267 | struct alloc_stat *s_alloc, *s_caller; |
| 268 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 269 | ptr = raw_field_value(event, "ptr", data); |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 270 | |
| 271 | s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp); |
| 272 | if (!s_alloc) |
| 273 | return; |
| 274 | |
| 275 | if (cpu != s_alloc->alloc_cpu) { |
| 276 | s_alloc->pingpong++; |
| 277 | |
| 278 | s_caller = search_alloc_stat(0, s_alloc->call_site, |
| 279 | &root_caller_stat, callsite_cmp); |
| 280 | assert(s_caller); |
| 281 | s_caller->pingpong++; |
| 282 | } |
| 283 | s_alloc->alloc_cpu = -1; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | static void |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 287 | process_raw_event(event_t *raw_event __used, void *data, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 288 | int cpu, u64 timestamp, struct thread *thread) |
| 289 | { |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 290 | struct event *event; |
| 291 | int type; |
| 292 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 293 | type = trace_parse_common_type(data); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 294 | event = trace_find_event(type); |
| 295 | |
| 296 | if (!strcmp(event->name, "kmalloc") || |
| 297 | !strcmp(event->name, "kmem_cache_alloc")) { |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 298 | process_alloc_event(data, event, cpu, timestamp, thread, 0); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 299 | return; |
| 300 | } |
| 301 | |
| 302 | if (!strcmp(event->name, "kmalloc_node") || |
| 303 | !strcmp(event->name, "kmem_cache_alloc_node")) { |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 304 | process_alloc_event(data, event, cpu, timestamp, thread, 1); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 305 | return; |
| 306 | } |
| 307 | |
| 308 | if (!strcmp(event->name, "kfree") || |
| 309 | !strcmp(event->name, "kmem_cache_free")) { |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 310 | process_free_event(data, event, cpu, timestamp, thread); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 311 | return; |
| 312 | } |
| 313 | } |
| 314 | |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 315 | static int process_sample_event(event_t *event) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 316 | { |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 317 | struct sample_data data; |
| 318 | struct thread *thread; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 319 | |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 320 | memset(&data, 0, sizeof(data)); |
| 321 | data.time = -1; |
| 322 | data.cpu = -1; |
| 323 | data.period = 1; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 324 | |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 325 | event__parse_sample(event, sample_type, &data); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 326 | |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 327 | dump_printf("(IP, %d): %d/%d: %p period: %Ld\n", |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 328 | event->header.misc, |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 329 | data.pid, data.tid, |
| 330 | (void *)(long)data.ip, |
| 331 | (long long)data.period); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 332 | |
OGAWA Hirofumi | 180f95e | 2009-12-06 20:08:24 +0900 | [diff] [blame] | 333 | thread = threads__findnew(event->ip.pid); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 334 | if (thread == NULL) { |
| 335 | pr_debug("problem processing %d event, skipping it.\n", |
| 336 | event->header.type); |
| 337 | return -1; |
| 338 | } |
| 339 | |
| 340 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
| 341 | |
Xiao Guangrong | f48f669 | 2009-12-07 13:04:04 +0800 | [diff] [blame] | 342 | process_raw_event(event, data.raw_data, data.cpu, |
Xiao Guangrong | d8bd9e0 | 2009-12-07 12:06:29 +0800 | [diff] [blame] | 343 | data.time, thread); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 344 | |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | static int sample_type_check(u64 type) |
| 349 | { |
| 350 | sample_type = type; |
| 351 | |
| 352 | if (!(sample_type & PERF_SAMPLE_RAW)) { |
| 353 | fprintf(stderr, |
| 354 | "No trace sample to read. Did you call perf record " |
| 355 | "without -R?"); |
| 356 | return -1; |
| 357 | } |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static struct perf_file_handler file_handler = { |
| 363 | .process_sample_event = process_sample_event, |
Arnaldo Carvalho de Melo | 62daacb | 2009-11-27 16:29:22 -0200 | [diff] [blame] | 364 | .process_comm_event = event__process_comm, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 365 | .sample_type_check = sample_type_check, |
| 366 | }; |
| 367 | |
| 368 | static int read_events(void) |
| 369 | { |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 370 | int err; |
| 371 | struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0); |
| 372 | |
| 373 | if (session == NULL) |
| 374 | return -ENOMEM; |
| 375 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 376 | register_idle_thread(); |
| 377 | register_perf_file_handler(&file_handler); |
| 378 | |
Arnaldo Carvalho de Melo | 94c744b | 2009-12-11 21:24:02 -0200 | [diff] [blame] | 379 | err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); |
| 380 | perf_session__delete(session); |
| 381 | return err; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) |
| 385 | { |
| 386 | if (n_alloc == 0) |
| 387 | return 0.0; |
| 388 | else |
| 389 | return 100.0 - (100.0 * n_req / n_alloc); |
| 390 | } |
| 391 | |
| 392 | static void __print_result(struct rb_root *root, int n_lines, int is_caller) |
| 393 | { |
| 394 | struct rb_node *next; |
| 395 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 396 | printf("%.102s\n", graph_dotted_line); |
| 397 | printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr"); |
| 398 | printf(" Total_alloc/Per | Total_req/Per | Hit | Ping-pong | Frag\n"); |
| 399 | printf("%.102s\n", graph_dotted_line); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 400 | |
| 401 | next = rb_first(root); |
| 402 | |
| 403 | while (next && n_lines--) { |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 404 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, |
| 405 | node); |
| 406 | struct symbol *sym = NULL; |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 407 | char buf[BUFSIZ]; |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 408 | u64 addr; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 409 | |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 410 | if (is_caller) { |
| 411 | addr = data->call_site; |
Li Zefan | 7707b6b | 2009-11-24 13:25:48 +0800 | [diff] [blame] | 412 | if (!raw_ip) |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 413 | sym = map_groups__find_function(kmaps, addr, NULL); |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 414 | } else |
| 415 | addr = data->ptr; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 416 | |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 417 | if (sym != NULL) |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 418 | snprintf(buf, sizeof(buf), "%s+%Lx", sym->name, |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 419 | addr - sym->start); |
| 420 | else |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 421 | snprintf(buf, sizeof(buf), "%#Lx", addr); |
| 422 | printf(" %-34s |", buf); |
Arnaldo Carvalho de Melo | 1b145ae | 2009-11-23 17:51:09 -0200 | [diff] [blame] | 423 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 424 | printf(" %9llu/%-5lu | %9llu/%-5lu | %6lu | %8lu | %6.3f%%\n", |
| 425 | (unsigned long long)data->bytes_alloc, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 426 | (unsigned long)data->bytes_alloc / data->hit, |
| 427 | (unsigned long long)data->bytes_req, |
| 428 | (unsigned long)data->bytes_req / data->hit, |
| 429 | (unsigned long)data->hit, |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 430 | (unsigned long)data->pingpong, |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 431 | fragmentation(data->bytes_req, data->bytes_alloc)); |
| 432 | |
| 433 | next = rb_next(next); |
| 434 | } |
| 435 | |
| 436 | if (n_lines == -1) |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 437 | printf(" ... | ... | ... | ... | ... | ... \n"); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 438 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 439 | printf("%.102s\n", graph_dotted_line); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | static void print_summary(void) |
| 443 | { |
| 444 | printf("\nSUMMARY\n=======\n"); |
| 445 | printf("Total bytes requested: %lu\n", total_requested); |
| 446 | printf("Total bytes allocated: %lu\n", total_allocated); |
| 447 | printf("Total bytes wasted on internal fragmentation: %lu\n", |
| 448 | total_allocated - total_requested); |
| 449 | printf("Internal fragmentation: %f%%\n", |
| 450 | fragmentation(total_requested, total_allocated)); |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 451 | printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | static void print_result(void) |
| 455 | { |
| 456 | if (caller_flag) |
| 457 | __print_result(&root_caller_sorted, caller_lines, 1); |
| 458 | if (alloc_flag) |
| 459 | __print_result(&root_alloc_sorted, alloc_lines, 0); |
| 460 | print_summary(); |
| 461 | } |
| 462 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 463 | struct sort_dimension { |
| 464 | const char name[20]; |
| 465 | sort_fn_t cmp; |
| 466 | struct list_head list; |
| 467 | }; |
| 468 | |
| 469 | static LIST_HEAD(caller_sort); |
| 470 | static LIST_HEAD(alloc_sort); |
| 471 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 472 | static void sort_insert(struct rb_root *root, struct alloc_stat *data, |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 473 | struct list_head *sort_list) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 474 | { |
| 475 | struct rb_node **new = &(root->rb_node); |
| 476 | struct rb_node *parent = NULL; |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 477 | struct sort_dimension *sort; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 478 | |
| 479 | while (*new) { |
| 480 | struct alloc_stat *this; |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 481 | int cmp = 0; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 482 | |
| 483 | this = rb_entry(*new, struct alloc_stat, node); |
| 484 | parent = *new; |
| 485 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 486 | list_for_each_entry(sort, sort_list, list) { |
| 487 | cmp = sort->cmp(data, this); |
| 488 | if (cmp) |
| 489 | break; |
| 490 | } |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 491 | |
| 492 | if (cmp > 0) |
| 493 | new = &((*new)->rb_left); |
| 494 | else |
| 495 | new = &((*new)->rb_right); |
| 496 | } |
| 497 | |
| 498 | rb_link_node(&data->node, parent, new); |
| 499 | rb_insert_color(&data->node, root); |
| 500 | } |
| 501 | |
| 502 | static void __sort_result(struct rb_root *root, struct rb_root *root_sorted, |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 503 | struct list_head *sort_list) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 504 | { |
| 505 | struct rb_node *node; |
| 506 | struct alloc_stat *data; |
| 507 | |
| 508 | for (;;) { |
| 509 | node = rb_first(root); |
| 510 | if (!node) |
| 511 | break; |
| 512 | |
| 513 | rb_erase(node, root); |
| 514 | data = rb_entry(node, struct alloc_stat, node); |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 515 | sort_insert(root_sorted, data, sort_list); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 516 | } |
| 517 | } |
| 518 | |
| 519 | static void sort_result(void) |
| 520 | { |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 521 | __sort_result(&root_alloc_stat, &root_alloc_sorted, &alloc_sort); |
| 522 | __sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 523 | } |
| 524 | |
| 525 | static int __cmd_kmem(void) |
| 526 | { |
| 527 | setup_pager(); |
| 528 | read_events(); |
| 529 | sort_result(); |
| 530 | print_result(); |
| 531 | |
| 532 | return 0; |
| 533 | } |
| 534 | |
| 535 | static const char * const kmem_usage[] = { |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 536 | "perf kmem [<options>] {record|stat}", |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 537 | NULL |
| 538 | }; |
| 539 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 540 | static int ptr_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 541 | { |
| 542 | if (l->ptr < r->ptr) |
| 543 | return -1; |
| 544 | else if (l->ptr > r->ptr) |
| 545 | return 1; |
| 546 | return 0; |
| 547 | } |
| 548 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 549 | static struct sort_dimension ptr_sort_dimension = { |
| 550 | .name = "ptr", |
| 551 | .cmp = ptr_cmp, |
| 552 | }; |
| 553 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 554 | static int callsite_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 555 | { |
| 556 | if (l->call_site < r->call_site) |
| 557 | return -1; |
| 558 | else if (l->call_site > r->call_site) |
| 559 | return 1; |
| 560 | return 0; |
| 561 | } |
| 562 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 563 | static struct sort_dimension callsite_sort_dimension = { |
| 564 | .name = "callsite", |
| 565 | .cmp = callsite_cmp, |
| 566 | }; |
| 567 | |
Pekka Enberg | f3ced7c | 2009-11-22 11:58:00 +0200 | [diff] [blame] | 568 | static int hit_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 569 | { |
| 570 | if (l->hit < r->hit) |
| 571 | return -1; |
| 572 | else if (l->hit > r->hit) |
| 573 | return 1; |
| 574 | return 0; |
| 575 | } |
| 576 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 577 | static struct sort_dimension hit_sort_dimension = { |
| 578 | .name = "hit", |
| 579 | .cmp = hit_cmp, |
| 580 | }; |
| 581 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 582 | static int bytes_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 583 | { |
| 584 | if (l->bytes_alloc < r->bytes_alloc) |
| 585 | return -1; |
| 586 | else if (l->bytes_alloc > r->bytes_alloc) |
| 587 | return 1; |
| 588 | return 0; |
| 589 | } |
| 590 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 591 | static struct sort_dimension bytes_sort_dimension = { |
| 592 | .name = "bytes", |
| 593 | .cmp = bytes_cmp, |
| 594 | }; |
| 595 | |
Pekka Enberg | f3ced7c | 2009-11-22 11:58:00 +0200 | [diff] [blame] | 596 | static int frag_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 597 | { |
| 598 | double x, y; |
| 599 | |
| 600 | x = fragmentation(l->bytes_req, l->bytes_alloc); |
| 601 | y = fragmentation(r->bytes_req, r->bytes_alloc); |
| 602 | |
| 603 | if (x < y) |
| 604 | return -1; |
| 605 | else if (x > y) |
| 606 | return 1; |
| 607 | return 0; |
| 608 | } |
| 609 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 610 | static struct sort_dimension frag_sort_dimension = { |
| 611 | .name = "frag", |
| 612 | .cmp = frag_cmp, |
| 613 | }; |
| 614 | |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 615 | static int pingpong_cmp(struct alloc_stat *l, struct alloc_stat *r) |
| 616 | { |
| 617 | if (l->pingpong < r->pingpong) |
| 618 | return -1; |
| 619 | else if (l->pingpong > r->pingpong) |
| 620 | return 1; |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | static struct sort_dimension pingpong_sort_dimension = { |
| 625 | .name = "pingpong", |
| 626 | .cmp = pingpong_cmp, |
| 627 | }; |
| 628 | |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 629 | static struct sort_dimension *avail_sorts[] = { |
| 630 | &ptr_sort_dimension, |
| 631 | &callsite_sort_dimension, |
| 632 | &hit_sort_dimension, |
| 633 | &bytes_sort_dimension, |
| 634 | &frag_sort_dimension, |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 635 | &pingpong_sort_dimension, |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 636 | }; |
| 637 | |
| 638 | #define NUM_AVAIL_SORTS \ |
| 639 | (int)(sizeof(avail_sorts) / sizeof(struct sort_dimension *)) |
| 640 | |
| 641 | static int sort_dimension__add(const char *tok, struct list_head *list) |
| 642 | { |
| 643 | struct sort_dimension *sort; |
| 644 | int i; |
| 645 | |
| 646 | for (i = 0; i < NUM_AVAIL_SORTS; i++) { |
| 647 | if (!strcmp(avail_sorts[i]->name, tok)) { |
| 648 | sort = malloc(sizeof(*sort)); |
| 649 | if (!sort) |
| 650 | die("malloc"); |
| 651 | memcpy(sort, avail_sorts[i], sizeof(*sort)); |
| 652 | list_add_tail(&sort->list, list); |
| 653 | return 0; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | return -1; |
| 658 | } |
| 659 | |
| 660 | static int setup_sorting(struct list_head *sort_list, const char *arg) |
| 661 | { |
| 662 | char *tok; |
| 663 | char *str = strdup(arg); |
| 664 | |
| 665 | if (!str) |
| 666 | die("strdup"); |
| 667 | |
| 668 | while (true) { |
| 669 | tok = strsep(&str, ","); |
| 670 | if (!tok) |
| 671 | break; |
| 672 | if (sort_dimension__add(tok, sort_list) < 0) { |
| 673 | error("Unknown --sort key: '%s'", tok); |
| 674 | return -1; |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | free(str); |
| 679 | return 0; |
| 680 | } |
| 681 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 682 | static int parse_sort_opt(const struct option *opt __used, |
| 683 | const char *arg, int unset __used) |
| 684 | { |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 685 | if (!arg) |
| 686 | return -1; |
| 687 | |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 688 | if (caller_flag > alloc_flag) |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 689 | return setup_sorting(&caller_sort, arg); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 690 | else |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 691 | return setup_sorting(&alloc_sort, arg); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 696 | static int parse_caller_opt(const struct option *opt __used, |
Ingo Molnar | 7931241 | 2009-12-10 08:43:34 +0100 | [diff] [blame] | 697 | const char *arg __used, int unset __used) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 698 | { |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 699 | caller_flag = (alloc_flag + 1); |
| 700 | return 0; |
| 701 | } |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 702 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 703 | static int parse_alloc_opt(const struct option *opt __used, |
Ingo Molnar | 7931241 | 2009-12-10 08:43:34 +0100 | [diff] [blame] | 704 | const char *arg __used, int unset __used) |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 705 | { |
| 706 | alloc_flag = (caller_flag + 1); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 707 | return 0; |
| 708 | } |
| 709 | |
| 710 | static int parse_line_opt(const struct option *opt __used, |
| 711 | const char *arg, int unset __used) |
| 712 | { |
| 713 | int lines; |
| 714 | |
| 715 | if (!arg) |
| 716 | return -1; |
| 717 | |
| 718 | lines = strtoul(arg, NULL, 10); |
| 719 | |
| 720 | if (caller_flag > alloc_flag) |
| 721 | caller_lines = lines; |
| 722 | else |
| 723 | alloc_lines = lines; |
| 724 | |
| 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | static const struct option kmem_options[] = { |
| 729 | OPT_STRING('i', "input", &input_name, "file", |
| 730 | "input file name"), |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 731 | OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL, |
| 732 | "show per-callsite statistics", |
| 733 | parse_caller_opt), |
| 734 | OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL, |
| 735 | "show per-allocation statistics", |
| 736 | parse_alloc_opt), |
Li Zefan | 29b3e15 | 2009-11-24 13:26:10 +0800 | [diff] [blame] | 737 | OPT_CALLBACK('s', "sort", NULL, "key[,key2...]", |
Li Zefan | 079d3f6 | 2009-11-24 13:26:55 +0800 | [diff] [blame] | 738 | "sort by keys: ptr, call_site, bytes, hit, pingpong, frag", |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 739 | parse_sort_opt), |
| 740 | OPT_CALLBACK('l', "line", NULL, "num", |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 741 | "show n lines", |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 742 | parse_line_opt), |
Li Zefan | 7707b6b | 2009-11-24 13:25:48 +0800 | [diff] [blame] | 743 | OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 744 | OPT_END() |
| 745 | }; |
| 746 | |
| 747 | static const char *record_args[] = { |
| 748 | "record", |
| 749 | "-a", |
| 750 | "-R", |
| 751 | "-M", |
| 752 | "-f", |
| 753 | "-c", "1", |
| 754 | "-e", "kmem:kmalloc", |
| 755 | "-e", "kmem:kmalloc_node", |
| 756 | "-e", "kmem:kfree", |
| 757 | "-e", "kmem:kmem_cache_alloc", |
| 758 | "-e", "kmem:kmem_cache_alloc_node", |
| 759 | "-e", "kmem:kmem_cache_free", |
| 760 | }; |
| 761 | |
| 762 | static int __cmd_record(int argc, const char **argv) |
| 763 | { |
| 764 | unsigned int rec_argc, i, j; |
| 765 | const char **rec_argv; |
| 766 | |
| 767 | rec_argc = ARRAY_SIZE(record_args) + argc - 1; |
| 768 | rec_argv = calloc(rec_argc + 1, sizeof(char *)); |
| 769 | |
| 770 | for (i = 0; i < ARRAY_SIZE(record_args); i++) |
| 771 | rec_argv[i] = strdup(record_args[i]); |
| 772 | |
| 773 | for (j = 1; j < (unsigned int)argc; j++, i++) |
| 774 | rec_argv[i] = argv[j]; |
| 775 | |
| 776 | return cmd_record(i, rec_argv, NULL); |
| 777 | } |
| 778 | |
| 779 | int cmd_kmem(int argc, const char **argv, const char *prefix __used) |
| 780 | { |
| 781 | symbol__init(0); |
| 782 | |
| 783 | argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); |
| 784 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 785 | if (!argc) |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 786 | usage_with_options(kmem_usage, kmem_options); |
| 787 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 788 | if (!strncmp(argv[0], "rec", 3)) { |
| 789 | return __cmd_record(argc, argv); |
| 790 | } else if (!strcmp(argv[0], "stat")) { |
| 791 | setup_cpunode_map(); |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 792 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 793 | if (list_empty(&caller_sort)) |
| 794 | setup_sorting(&caller_sort, default_sort_order); |
| 795 | if (list_empty(&alloc_sort)) |
| 796 | setup_sorting(&alloc_sort, default_sort_order); |
Li Zefan | 7d0d394 | 2009-11-24 13:26:31 +0800 | [diff] [blame] | 797 | |
Li Zefan | 90b86a9 | 2009-12-10 15:21:57 +0800 | [diff] [blame] | 798 | return __cmd_kmem(); |
| 799 | } |
| 800 | |
| 801 | return 0; |
Li Zefan | ba77c9e | 2009-11-20 15:53:25 +0800 | [diff] [blame] | 802 | } |
| 803 | |