builtin-kmem.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. #include "builtin.h"
  2. #include "perf.h"
  3. #include "util/evlist.h"
  4. #include "util/evsel.h"
  5. #include "util/util.h"
  6. #include "util/cache.h"
  7. #include "util/symbol.h"
  8. #include "util/thread.h"
  9. #include "util/header.h"
  10. #include "util/session.h"
  11. #include "util/tool.h"
  12. #include "util/parse-options.h"
  13. #include "util/trace-event.h"
  14. #include "util/data.h"
  15. #include "util/cpumap.h"
  16. #include "util/debug.h"
  17. #include <linux/rbtree.h>
  18. #include <linux/string.h>
  19. struct alloc_stat;
  20. typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
  21. static int alloc_flag;
  22. static int caller_flag;
  23. static int alloc_lines = -1;
  24. static int caller_lines = -1;
  25. static bool raw_ip;
  26. struct alloc_stat {
  27. u64 call_site;
  28. u64 ptr;
  29. u64 bytes_req;
  30. u64 bytes_alloc;
  31. u32 hit;
  32. u32 pingpong;
  33. short alloc_cpu;
  34. struct rb_node node;
  35. };
  36. static struct rb_root root_alloc_stat;
  37. static struct rb_root root_alloc_sorted;
  38. static struct rb_root root_caller_stat;
  39. static struct rb_root root_caller_sorted;
  40. static unsigned long total_requested, total_allocated;
  41. static unsigned long nr_allocs, nr_cross_allocs;
  42. static int insert_alloc_stat(unsigned long call_site, unsigned long ptr,
  43. int bytes_req, int bytes_alloc, int cpu)
  44. {
  45. struct rb_node **node = &root_alloc_stat.rb_node;
  46. struct rb_node *parent = NULL;
  47. struct alloc_stat *data = NULL;
  48. while (*node) {
  49. parent = *node;
  50. data = rb_entry(*node, struct alloc_stat, node);
  51. if (ptr > data->ptr)
  52. node = &(*node)->rb_right;
  53. else if (ptr < data->ptr)
  54. node = &(*node)->rb_left;
  55. else
  56. break;
  57. }
  58. if (data && data->ptr == ptr) {
  59. data->hit++;
  60. data->bytes_req += bytes_req;
  61. data->bytes_alloc += bytes_alloc;
  62. } else {
  63. data = malloc(sizeof(*data));
  64. if (!data) {
  65. pr_err("%s: malloc failed\n", __func__);
  66. return -1;
  67. }
  68. data->ptr = ptr;
  69. data->pingpong = 0;
  70. data->hit = 1;
  71. data->bytes_req = bytes_req;
  72. data->bytes_alloc = bytes_alloc;
  73. rb_link_node(&data->node, parent, node);
  74. rb_insert_color(&data->node, &root_alloc_stat);
  75. }
  76. data->call_site = call_site;
  77. data->alloc_cpu = cpu;
  78. return 0;
  79. }
  80. static int insert_caller_stat(unsigned long call_site,
  81. int bytes_req, int bytes_alloc)
  82. {
  83. struct rb_node **node = &root_caller_stat.rb_node;
  84. struct rb_node *parent = NULL;
  85. struct alloc_stat *data = NULL;
  86. while (*node) {
  87. parent = *node;
  88. data = rb_entry(*node, struct alloc_stat, node);
  89. if (call_site > data->call_site)
  90. node = &(*node)->rb_right;
  91. else if (call_site < data->call_site)
  92. node = &(*node)->rb_left;
  93. else
  94. break;
  95. }
  96. if (data && data->call_site == call_site) {
  97. data->hit++;
  98. data->bytes_req += bytes_req;
  99. data->bytes_alloc += bytes_alloc;
  100. } else {
  101. data = malloc(sizeof(*data));
  102. if (!data) {
  103. pr_err("%s: malloc failed\n", __func__);
  104. return -1;
  105. }
  106. data->call_site = call_site;
  107. data->pingpong = 0;
  108. data->hit = 1;
  109. data->bytes_req = bytes_req;
  110. data->bytes_alloc = bytes_alloc;
  111. rb_link_node(&data->node, parent, node);
  112. rb_insert_color(&data->node, &root_caller_stat);
  113. }
  114. return 0;
  115. }
  116. static int perf_evsel__process_alloc_event(struct perf_evsel *evsel,
  117. struct perf_sample *sample)
  118. {
  119. unsigned long ptr = perf_evsel__intval(evsel, sample, "ptr"),
  120. call_site = perf_evsel__intval(evsel, sample, "call_site");
  121. int bytes_req = perf_evsel__intval(evsel, sample, "bytes_req"),
  122. bytes_alloc = perf_evsel__intval(evsel, sample, "bytes_alloc");
  123. if (insert_alloc_stat(call_site, ptr, bytes_req, bytes_alloc, sample->cpu) ||
  124. insert_caller_stat(call_site, bytes_req, bytes_alloc))
  125. return -1;
  126. total_requested += bytes_req;
  127. total_allocated += bytes_alloc;
  128. nr_allocs++;
  129. return 0;
  130. }
  131. static int perf_evsel__process_alloc_node_event(struct perf_evsel *evsel,
  132. struct perf_sample *sample)
  133. {
  134. int ret = perf_evsel__process_alloc_event(evsel, sample);
  135. if (!ret) {
  136. int node1 = cpu__get_node(sample->cpu),
  137. node2 = perf_evsel__intval(evsel, sample, "node");
  138. if (node1 != node2)
  139. nr_cross_allocs++;
  140. }
  141. return ret;
  142. }
  143. static int ptr_cmp(struct alloc_stat *, struct alloc_stat *);
  144. static int callsite_cmp(struct alloc_stat *, struct alloc_stat *);
  145. static struct alloc_stat *search_alloc_stat(unsigned long ptr,
  146. unsigned long call_site,
  147. struct rb_root *root,
  148. sort_fn_t sort_fn)
  149. {
  150. struct rb_node *node = root->rb_node;
  151. struct alloc_stat key = { .ptr = ptr, .call_site = call_site };
  152. while (node) {
  153. struct alloc_stat *data;
  154. int cmp;
  155. data = rb_entry(node, struct alloc_stat, node);
  156. cmp = sort_fn(&key, data);
  157. if (cmp < 0)
  158. node = node->rb_left;
  159. else if (cmp > 0)
  160. node = node->rb_right;
  161. else
  162. return data;
  163. }
  164. return NULL;
  165. }
  166. static int perf_evsel__process_free_event(struct perf_evsel *evsel,
  167. struct perf_sample *sample)
  168. {
  169. unsigned long ptr = perf_evsel__intval(evsel, sample, "ptr");
  170. struct alloc_stat *s_alloc, *s_caller;
  171. s_alloc = search_alloc_stat(ptr, 0, &root_alloc_stat, ptr_cmp);
  172. if (!s_alloc)
  173. return 0;
  174. if ((short)sample->cpu != s_alloc->alloc_cpu) {
  175. s_alloc->pingpong++;
  176. s_caller = search_alloc_stat(0, s_alloc->call_site,
  177. &root_caller_stat, callsite_cmp);
  178. if (!s_caller)
  179. return -1;
  180. s_caller->pingpong++;
  181. }
  182. s_alloc->alloc_cpu = -1;
  183. return 0;
  184. }
  185. typedef int (*tracepoint_handler)(struct perf_evsel *evsel,
  186. struct perf_sample *sample);
  187. static int process_sample_event(struct perf_tool *tool __maybe_unused,
  188. union perf_event *event,
  189. struct perf_sample *sample,
  190. struct perf_evsel *evsel,
  191. struct machine *machine)
  192. {
  193. struct thread *thread = machine__findnew_thread(machine, sample->pid,
  194. sample->tid);
  195. if (thread == NULL) {
  196. pr_debug("problem processing %d event, skipping it.\n",
  197. event->header.type);
  198. return -1;
  199. }
  200. dump_printf(" ... thread: %s:%d\n", thread__comm_str(thread), thread->tid);
  201. if (evsel->handler != NULL) {
  202. tracepoint_handler f = evsel->handler;
  203. return f(evsel, sample);
  204. }
  205. return 0;
  206. }
  207. static struct perf_tool perf_kmem = {
  208. .sample = process_sample_event,
  209. .comm = perf_event__process_comm,
  210. .ordered_samples = true,
  211. };
  212. static double fragmentation(unsigned long n_req, unsigned long n_alloc)
  213. {
  214. if (n_alloc == 0)
  215. return 0.0;
  216. else
  217. return 100.0 - (100.0 * n_req / n_alloc);
  218. }
  219. static void __print_result(struct rb_root *root, struct perf_session *session,
  220. int n_lines, int is_caller)
  221. {
  222. struct rb_node *next;
  223. struct machine *machine = &session->machines.host;
  224. printf("%.102s\n", graph_dotted_line);
  225. printf(" %-34s |", is_caller ? "Callsite": "Alloc Ptr");
  226. printf(" Total_alloc/Per | Total_req/Per | Hit | Ping-pong | Frag\n");
  227. printf("%.102s\n", graph_dotted_line);
  228. next = rb_first(root);
  229. while (next && n_lines--) {
  230. struct alloc_stat *data = rb_entry(next, struct alloc_stat,
  231. node);
  232. struct symbol *sym = NULL;
  233. struct map *map;
  234. char buf[BUFSIZ];
  235. u64 addr;
  236. if (is_caller) {
  237. addr = data->call_site;
  238. if (!raw_ip)
  239. sym = machine__find_kernel_function(machine, addr, &map, NULL);
  240. } else
  241. addr = data->ptr;
  242. if (sym != NULL)
  243. snprintf(buf, sizeof(buf), "%s+%" PRIx64 "", sym->name,
  244. addr - map->unmap_ip(map, sym->start));
  245. else
  246. snprintf(buf, sizeof(buf), "%#" PRIx64 "", addr);
  247. printf(" %-34s |", buf);
  248. printf(" %9llu/%-5lu | %9llu/%-5lu | %8lu | %8lu | %6.3f%%\n",
  249. (unsigned long long)data->bytes_alloc,
  250. (unsigned long)data->bytes_alloc / data->hit,
  251. (unsigned long long)data->bytes_req,
  252. (unsigned long)data->bytes_req / data->hit,
  253. (unsigned long)data->hit,
  254. (unsigned long)data->pingpong,
  255. fragmentation(data->bytes_req, data->bytes_alloc));
  256. next = rb_next(next);
  257. }
  258. if (n_lines == -1)
  259. printf(" ... | ... | ... | ... | ... | ... \n");
  260. printf("%.102s\n", graph_dotted_line);
  261. }
  262. static void print_summary(void)
  263. {
  264. printf("\nSUMMARY\n=======\n");
  265. printf("Total bytes requested: %lu\n", total_requested);
  266. printf("Total bytes allocated: %lu\n", total_allocated);
  267. printf("Total bytes wasted on internal fragmentation: %lu\n",
  268. total_allocated - total_requested);
  269. printf("Internal fragmentation: %f%%\n",
  270. fragmentation(total_requested, total_allocated));
  271. printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
  272. }
  273. static void print_result(struct perf_session *session)
  274. {
  275. if (caller_flag)
  276. __print_result(&root_caller_sorted, session, caller_lines, 1);
  277. if (alloc_flag)
  278. __print_result(&root_alloc_sorted, session, alloc_lines, 0);
  279. print_summary();
  280. }
  281. struct sort_dimension {
  282. const char name[20];
  283. sort_fn_t cmp;
  284. struct list_head list;
  285. };
  286. static LIST_HEAD(caller_sort);
  287. static LIST_HEAD(alloc_sort);
  288. static void sort_insert(struct rb_root *root, struct alloc_stat *data,
  289. struct list_head *sort_list)
  290. {
  291. struct rb_node **new = &(root->rb_node);
  292. struct rb_node *parent = NULL;
  293. struct sort_dimension *sort;
  294. while (*new) {
  295. struct alloc_stat *this;
  296. int cmp = 0;
  297. this = rb_entry(*new, struct alloc_stat, node);
  298. parent = *new;
  299. list_for_each_entry(sort, sort_list, list) {
  300. cmp = sort->cmp(data, this);
  301. if (cmp)
  302. break;
  303. }
  304. if (cmp > 0)
  305. new = &((*new)->rb_left);
  306. else
  307. new = &((*new)->rb_right);
  308. }
  309. rb_link_node(&data->node, parent, new);
  310. rb_insert_color(&data->node, root);
  311. }
  312. static void __sort_result(struct rb_root *root, struct rb_root *root_sorted,
  313. struct list_head *sort_list)
  314. {
  315. struct rb_node *node;
  316. struct alloc_stat *data;
  317. for (;;) {
  318. node = rb_first(root);
  319. if (!node)
  320. break;
  321. rb_erase(node, root);
  322. data = rb_entry(node, struct alloc_stat, node);
  323. sort_insert(root_sorted, data, sort_list);
  324. }
  325. }
  326. static void sort_result(void)
  327. {
  328. __sort_result(&root_alloc_stat, &root_alloc_sorted, &alloc_sort);
  329. __sort_result(&root_caller_stat, &root_caller_sorted, &caller_sort);
  330. }
  331. static int __cmd_kmem(void)
  332. {
  333. int err = -EINVAL;
  334. struct perf_session *session;
  335. const struct perf_evsel_str_handler kmem_tracepoints[] = {
  336. { "kmem:kmalloc", perf_evsel__process_alloc_event, },
  337. { "kmem:kmem_cache_alloc", perf_evsel__process_alloc_event, },
  338. { "kmem:kmalloc_node", perf_evsel__process_alloc_node_event, },
  339. { "kmem:kmem_cache_alloc_node", perf_evsel__process_alloc_node_event, },
  340. { "kmem:kfree", perf_evsel__process_free_event, },
  341. { "kmem:kmem_cache_free", perf_evsel__process_free_event, },
  342. };
  343. struct perf_data_file file = {
  344. .path = input_name,
  345. .mode = PERF_DATA_MODE_READ,
  346. };
  347. session = perf_session__new(&file, false, &perf_kmem);
  348. if (session == NULL)
  349. return -ENOMEM;
  350. if (perf_session__create_kernel_maps(session) < 0)
  351. goto out_delete;
  352. if (!perf_session__has_traces(session, "kmem record"))
  353. goto out_delete;
  354. if (perf_session__set_tracepoints_handlers(session, kmem_tracepoints)) {
  355. pr_err("Initializing perf session tracepoint handlers failed\n");
  356. return -1;
  357. }
  358. setup_pager();
  359. err = perf_session__process_events(session, &perf_kmem);
  360. if (err != 0)
  361. goto out_delete;
  362. sort_result();
  363. print_result(session);
  364. out_delete:
  365. perf_session__delete(session);
  366. return err;
  367. }
  368. static int ptr_cmp(struct alloc_stat *l, struct alloc_stat *r)
  369. {
  370. if (l->ptr < r->ptr)
  371. return -1;
  372. else if (l->ptr > r->ptr)
  373. return 1;
  374. return 0;
  375. }
  376. static struct sort_dimension ptr_sort_dimension = {
  377. .name = "ptr",
  378. .cmp = ptr_cmp,
  379. };
  380. static int callsite_cmp(struct alloc_stat *l, struct alloc_stat *r)
  381. {
  382. if (l->call_site < r->call_site)
  383. return -1;
  384. else if (l->call_site > r->call_site)
  385. return 1;
  386. return 0;
  387. }
  388. static struct sort_dimension callsite_sort_dimension = {
  389. .name = "callsite",
  390. .cmp = callsite_cmp,
  391. };
  392. static int hit_cmp(struct alloc_stat *l, struct alloc_stat *r)
  393. {
  394. if (l->hit < r->hit)
  395. return -1;
  396. else if (l->hit > r->hit)
  397. return 1;
  398. return 0;
  399. }
  400. static struct sort_dimension hit_sort_dimension = {
  401. .name = "hit",
  402. .cmp = hit_cmp,
  403. };
  404. static int bytes_cmp(struct alloc_stat *l, struct alloc_stat *r)
  405. {
  406. if (l->bytes_alloc < r->bytes_alloc)
  407. return -1;
  408. else if (l->bytes_alloc > r->bytes_alloc)
  409. return 1;
  410. return 0;
  411. }
  412. static struct sort_dimension bytes_sort_dimension = {
  413. .name = "bytes",
  414. .cmp = bytes_cmp,
  415. };
  416. static int frag_cmp(struct alloc_stat *l, struct alloc_stat *r)
  417. {
  418. double x, y;
  419. x = fragmentation(l->bytes_req, l->bytes_alloc);
  420. y = fragmentation(r->bytes_req, r->bytes_alloc);
  421. if (x < y)
  422. return -1;
  423. else if (x > y)
  424. return 1;
  425. return 0;
  426. }
  427. static struct sort_dimension frag_sort_dimension = {
  428. .name = "frag",
  429. .cmp = frag_cmp,
  430. };
  431. static int pingpong_cmp(struct alloc_stat *l, struct alloc_stat *r)
  432. {
  433. if (l->pingpong < r->pingpong)
  434. return -1;
  435. else if (l->pingpong > r->pingpong)
  436. return 1;
  437. return 0;
  438. }
  439. static struct sort_dimension pingpong_sort_dimension = {
  440. .name = "pingpong",
  441. .cmp = pingpong_cmp,
  442. };
  443. static struct sort_dimension *avail_sorts[] = {
  444. &ptr_sort_dimension,
  445. &callsite_sort_dimension,
  446. &hit_sort_dimension,
  447. &bytes_sort_dimension,
  448. &frag_sort_dimension,
  449. &pingpong_sort_dimension,
  450. };
  451. #define NUM_AVAIL_SORTS ((int)ARRAY_SIZE(avail_sorts))
  452. static int sort_dimension__add(const char *tok, struct list_head *list)
  453. {
  454. struct sort_dimension *sort;
  455. int i;
  456. for (i = 0; i < NUM_AVAIL_SORTS; i++) {
  457. if (!strcmp(avail_sorts[i]->name, tok)) {
  458. sort = memdup(avail_sorts[i], sizeof(*avail_sorts[i]));
  459. if (!sort) {
  460. pr_err("%s: memdup failed\n", __func__);
  461. return -1;
  462. }
  463. list_add_tail(&sort->list, list);
  464. return 0;
  465. }
  466. }
  467. return -1;
  468. }
  469. static int setup_sorting(struct list_head *sort_list, const char *arg)
  470. {
  471. char *tok;
  472. char *str = strdup(arg);
  473. if (!str) {
  474. pr_err("%s: strdup failed\n", __func__);
  475. return -1;
  476. }
  477. while (true) {
  478. tok = strsep(&str, ",");
  479. if (!tok)
  480. break;
  481. if (sort_dimension__add(tok, sort_list) < 0) {
  482. error("Unknown --sort key: '%s'", tok);
  483. free(str);
  484. return -1;
  485. }
  486. }
  487. free(str);
  488. return 0;
  489. }
  490. static int parse_sort_opt(const struct option *opt __maybe_unused,
  491. const char *arg, int unset __maybe_unused)
  492. {
  493. if (!arg)
  494. return -1;
  495. if (caller_flag > alloc_flag)
  496. return setup_sorting(&caller_sort, arg);
  497. else
  498. return setup_sorting(&alloc_sort, arg);
  499. return 0;
  500. }
  501. static int parse_caller_opt(const struct option *opt __maybe_unused,
  502. const char *arg __maybe_unused,
  503. int unset __maybe_unused)
  504. {
  505. caller_flag = (alloc_flag + 1);
  506. return 0;
  507. }
  508. static int parse_alloc_opt(const struct option *opt __maybe_unused,
  509. const char *arg __maybe_unused,
  510. int unset __maybe_unused)
  511. {
  512. alloc_flag = (caller_flag + 1);
  513. return 0;
  514. }
  515. static int parse_line_opt(const struct option *opt __maybe_unused,
  516. const char *arg, int unset __maybe_unused)
  517. {
  518. int lines;
  519. if (!arg)
  520. return -1;
  521. lines = strtoul(arg, NULL, 10);
  522. if (caller_flag > alloc_flag)
  523. caller_lines = lines;
  524. else
  525. alloc_lines = lines;
  526. return 0;
  527. }
  528. static int __cmd_record(int argc, const char **argv)
  529. {
  530. const char * const record_args[] = {
  531. "record", "-a", "-R", "-c", "1",
  532. "-e", "kmem:kmalloc",
  533. "-e", "kmem:kmalloc_node",
  534. "-e", "kmem:kfree",
  535. "-e", "kmem:kmem_cache_alloc",
  536. "-e", "kmem:kmem_cache_alloc_node",
  537. "-e", "kmem:kmem_cache_free",
  538. };
  539. unsigned int rec_argc, i, j;
  540. const char **rec_argv;
  541. rec_argc = ARRAY_SIZE(record_args) + argc - 1;
  542. rec_argv = calloc(rec_argc + 1, sizeof(char *));
  543. if (rec_argv == NULL)
  544. return -ENOMEM;
  545. for (i = 0; i < ARRAY_SIZE(record_args); i++)
  546. rec_argv[i] = strdup(record_args[i]);
  547. for (j = 1; j < (unsigned int)argc; j++, i++)
  548. rec_argv[i] = argv[j];
  549. return cmd_record(i, rec_argv, NULL);
  550. }
  551. int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
  552. {
  553. const char * const default_sort_order = "frag,hit,bytes";
  554. const struct option kmem_options[] = {
  555. OPT_STRING('i', "input", &input_name, "file", "input file name"),
  556. OPT_CALLBACK_NOOPT(0, "caller", NULL, NULL,
  557. "show per-callsite statistics", parse_caller_opt),
  558. OPT_CALLBACK_NOOPT(0, "alloc", NULL, NULL,
  559. "show per-allocation statistics", parse_alloc_opt),
  560. OPT_CALLBACK('s', "sort", NULL, "key[,key2...]",
  561. "sort by keys: ptr, call_site, bytes, hit, pingpong, frag",
  562. parse_sort_opt),
  563. OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt),
  564. OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
  565. OPT_END()
  566. };
  567. const char *const kmem_subcommands[] = { "record", "stat", NULL };
  568. const char *kmem_usage[] = {
  569. NULL,
  570. NULL
  571. };
  572. argc = parse_options_subcommand(argc, argv, kmem_options,
  573. kmem_subcommands, kmem_usage, 0);
  574. if (!argc)
  575. usage_with_options(kmem_usage, kmem_options);
  576. symbol__init();
  577. if (!strncmp(argv[0], "rec", 3)) {
  578. return __cmd_record(argc, argv);
  579. } else if (!strcmp(argv[0], "stat")) {
  580. if (cpu__setup_cpunode_map())
  581. return -1;
  582. if (list_empty(&caller_sort))
  583. setup_sorting(&caller_sort, default_sort_order);
  584. if (list_empty(&alloc_sort))
  585. setup_sorting(&alloc_sort, default_sort_order);
  586. return __cmd_kmem();
  587. } else
  588. usage_with_options(kmem_usage, kmem_options);
  589. return 0;
  590. }