2 * Slabinfo: Tool to get reports about slabs
4 * (C) 2007 sgi, Christoph Lameter <clameter@sgi.com>
8 * gcc -o slabinfo slabinfo.c
12 #include <sys/types.h>
22 #define MAX_ALIASES 500
23 #define MAX_NODES 1024
29 int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu;
30 int hwcache_align, object_size, objs_per_slab;
31 int sanity_checks, slab_size, store_user, trace;
32 int order, poison, reclaim_account, red_zone;
33 unsigned long partial, objects, slabs;
35 int numa_partial[MAX_NODES];
36 } slabinfo[MAX_SLABS];
41 struct slabinfo *slab;
42 } aliasinfo[MAX_ALIASES];
47 int alias_targets = 0;
59 int show_first_alias = 0;
62 int show_inverted = 0;
63 int show_single_ref = 0;
80 void fatal(const char *x, ...)
85 vfprintf(stderr, x, ap);
92 printf("slabinfo 5/7/2007. (c) 2007 sgi. clameter@sgi.com\n\n"
93 "slabinfo [-ahnpvtsz] [-d debugopts] [slab-regexp]\n"
94 "-a|--aliases Show aliases\n"
95 "-d<options>|--debug=<options> Set/Clear Debug options\n"
96 "-e|--empty Show empty slabs\n"
97 "-f|--first-alias Show first alias\n"
98 "-h|--help Show usage information\n"
99 "-i|--inverted Inverted list\n"
100 "-l|--slabs Show slabs\n"
101 "-n|--numa Show NUMA information\n"
102 "-o|--ops Show kmem_cache_ops\n"
103 "-s|--shrink Shrink slabs\n"
104 "-r|--report Detailed report on single slabs\n"
105 "-S|--Size Sort by size\n"
106 "-t|--tracking Show alloc/free information\n"
107 "-T|--Totals Show summary information\n"
108 "-v|--validate Validate slabs\n"
109 "-z|--zero Include empty slabs\n"
110 "-1|--1ref Single reference\n"
111 "\nValid debug options (FZPUT may be combined)\n"
112 "a / A Switch on all debug options (=FZUP)\n"
113 "- Switch off all debug options\n"
114 "f / F Sanity Checks (SLAB_DEBUG_FREE)\n"
122 unsigned long read_obj(char *name)
124 FILE *f = fopen(name, "r");
129 if (!fgets(buffer,sizeof(buffer), f))
132 if (buffer[strlen(buffer)] == '\n')
133 buffer[strlen(buffer)] = 0;
135 return strlen(buffer);
140 * Get the contents of an attribute
142 unsigned long get_obj(char *name)
150 unsigned long get_obj_and_str(char *name, char **x)
152 unsigned long result = 0;
157 if (!read_obj(name)) {
161 result = strtoul(buffer, &p, 10);
169 void set_obj(struct slabinfo *s, char *name, int n)
174 sprintf(x, "%s/%s", s->name, name);
177 fatal("Cannot write to %s\n", x);
179 fprintf(f, "%d\n", n);
183 unsigned long read_slab_obj(struct slabinfo *s, char *name)
189 sprintf(x, "%s/%s", s->name, name);
195 l = fread(buffer, 1, sizeof(buffer), f);
204 * Put a size string together
206 int store_size(char *buffer, unsigned long value)
208 unsigned long divisor = 1;
212 if (value > 1000000000UL) {
213 divisor = 100000000UL;
215 } else if (value > 1000000UL) {
218 } else if (value > 1000UL) {
224 n = sprintf(buffer, "%ld",value);
231 memmove(buffer + n - 2, buffer + n - 3, 4);
238 void decode_numa_list(int *numa, char *t)
243 memset(numa, 0, MAX_NODES * sizeof(int));
247 node = strtoul(t, &t, 10);
250 nr = strtoul(t, &t, 10);
252 if (node > highest_node)
260 void slab_validate(struct slabinfo *s)
262 set_obj(s, "validate", 1);
265 void slab_shrink(struct slabinfo *s)
267 set_obj(s, "shrink", 1);
272 void first_line(void)
274 printf("Name Objects Objsize Space "
275 "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n");
279 * Find the shortest alias of a slab
281 struct aliasinfo *find_one_alias(struct slabinfo *find)
284 struct aliasinfo *best = NULL;
286 for(a = aliasinfo;a < aliasinfo + aliases; a++) {
287 if (a->slab == find &&
288 (!best || strlen(best->name) < strlen(a->name))) {
290 if (strncmp(a->name,"kmall", 5) == 0)
297 unsigned long slab_size(struct slabinfo *s)
299 return s->slabs * (page_size << s->order);
302 void slab_numa(struct slabinfo *s, int mode)
306 if (strcmp(s->name, "*") == 0)
310 printf("\n%s: No NUMA information available.\n", s->name);
314 if (skip_zero && !s->slabs)
318 printf("\n%-21s:", mode ? "NUMA nodes" : "Slab");
319 for(node = 0; node <= highest_node; node++)
320 printf(" %4d", node);
321 printf("\n----------------------");
322 for(node = 0; node <= highest_node; node++)
326 printf("%-21s ", mode ? "All slabs" : s->name);
327 for(node = 0; node <= highest_node; node++) {
330 store_size(b, s->numa[node]);
335 printf("%-21s ", "Partial slabs");
336 for(node = 0; node <= highest_node; node++) {
339 store_size(b, s->numa_partial[node]);
347 void show_tracking(struct slabinfo *s)
349 printf("\n%s: Kernel object allocation\n", s->name);
350 printf("-----------------------------------------------------------------------\n");
351 if (read_slab_obj(s, "alloc_calls"))
356 printf("\n%s: Kernel object freeing\n", s->name);
357 printf("------------------------------------------------------------------------\n");
358 if (read_slab_obj(s, "free_calls"))
365 void ops(struct slabinfo *s)
367 if (strcmp(s->name, "*") == 0)
370 if (read_slab_obj(s, "ops")) {
371 printf("\n%s: kmem_cache operations\n", s->name);
372 printf("--------------------------------------------\n");
375 printf("\n%s has no kmem_cache operations\n", s->name);
378 const char *onoff(int x)
385 void report(struct slabinfo *s)
387 if (strcmp(s->name, "*") == 0)
389 printf("\nSlabcache: %-20s Aliases: %2d Order : %2d\n", s->name, s->aliases, s->order);
390 if (s->hwcache_align)
391 printf("** Hardware cacheline aligned\n");
393 printf("** Memory is allocated in a special DMA zone\n");
394 if (s->destroy_by_rcu)
395 printf("** Slabs are destroyed via RCU\n");
396 if (s->reclaim_account)
397 printf("** Reclaim accounting active\n");
399 printf("\nSizes (bytes) Slabs Debug Memory\n");
400 printf("------------------------------------------------------------------------\n");
401 printf("Object : %7d Total : %7ld Sanity Checks : %s Total: %7ld\n",
402 s->object_size, s->slabs, onoff(s->sanity_checks),
403 s->slabs * (page_size << s->order));
404 printf("SlabObj: %7d Full : %7ld Redzoning : %s Used : %7ld\n",
405 s->slab_size, s->slabs - s->partial - s->cpu_slabs,
406 onoff(s->red_zone), s->objects * s->object_size);
407 printf("SlabSiz: %7d Partial: %7ld Poisoning : %s Loss : %7ld\n",
408 page_size << s->order, s->partial, onoff(s->poison),
409 s->slabs * (page_size << s->order) - s->objects * s->object_size);
410 printf("Loss : %7d CpuSlab: %7d Tracking : %s Lalig: %7ld\n",
411 s->slab_size - s->object_size, s->cpu_slabs, onoff(s->store_user),
412 (s->slab_size - s->object_size) * s->objects);
413 printf("Align : %7d Objects: %7d Tracing : %s Lpadd: %7ld\n",
414 s->align, s->objs_per_slab, onoff(s->trace),
415 ((page_size << s->order) - s->objs_per_slab * s->slab_size) *
423 void slabcache(struct slabinfo *s)
430 if (strcmp(s->name, "*") == 0)
433 if (actual_slabs == 1) {
438 if (skip_zero && !show_empty && !s->slabs)
441 if (show_empty && s->slabs)
444 store_size(size_str, slab_size(s));
445 sprintf(dist_str,"%lu/%lu/%d", s->slabs, s->partial, s->cpu_slabs);
454 if (s->hwcache_align)
458 if (s->reclaim_account)
462 if (s->sanity_checks)
470 printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n",
471 s->name, s->objects, s->object_size, size_str, dist_str,
472 s->objs_per_slab, s->order,
473 s->slabs ? (s->partial * 100) / s->slabs : 100,
474 s->slabs ? (s->objects * s->object_size * 100) /
475 (s->slabs * (page_size << s->order)) : 100,
480 * Analyze debug options. Return false if something is amiss.
482 int debug_opt_scan(char *opt)
484 if (!opt || !opt[0] || strcmp(opt, "-") == 0)
487 if (strcasecmp(opt, "a") == 0) {
531 int slab_empty(struct slabinfo *s)
537 * We may still have slabs even if there are no objects. Shrinking will
541 set_obj(s, "shrink", 1);
546 void slab_debug(struct slabinfo *s)
548 if (sanity && !s->sanity_checks) {
549 set_obj(s, "sanity", 1);
551 if (!sanity && s->sanity_checks) {
553 set_obj(s, "sanity", 0);
555 fprintf(stderr, "%s not empty cannot disable sanity checks\n", s->name);
557 if (redzone && !s->red_zone) {
559 set_obj(s, "red_zone", 1);
561 fprintf(stderr, "%s not empty cannot enable redzoning\n", s->name);
563 if (!redzone && s->red_zone) {
565 set_obj(s, "red_zone", 0);
567 fprintf(stderr, "%s not empty cannot disable redzoning\n", s->name);
569 if (poison && !s->poison) {
571 set_obj(s, "poison", 1);
573 fprintf(stderr, "%s not empty cannot enable poisoning\n", s->name);
575 if (!poison && s->poison) {
577 set_obj(s, "poison", 0);
579 fprintf(stderr, "%s not empty cannot disable poisoning\n", s->name);
581 if (tracking && !s->store_user) {
583 set_obj(s, "store_user", 1);
585 fprintf(stderr, "%s not empty cannot enable tracking\n", s->name);
587 if (!tracking && s->store_user) {
589 set_obj(s, "store_user", 0);
591 fprintf(stderr, "%s not empty cannot disable tracking\n", s->name);
593 if (tracing && !s->trace) {
595 set_obj(s, "trace", 1);
597 fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
599 if (!tracing && s->trace)
600 set_obj(s, "trace", 1);
608 char b1[20], b2[20], b3[20], b4[20];
609 unsigned long long max = 1ULL << 63;
612 unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
614 /* Number of partial slabs in a slabcache */
615 unsigned long long min_partial = max, max_partial = 0,
616 avg_partial, total_partial = 0;
618 /* Number of slabs in a slab cache */
619 unsigned long long min_slabs = max, max_slabs = 0,
620 avg_slabs, total_slabs = 0;
622 /* Size of the whole slab */
623 unsigned long long min_size = max, max_size = 0,
624 avg_size, total_size = 0;
626 /* Bytes used for object storage in a slab */
627 unsigned long long min_used = max, max_used = 0,
628 avg_used, total_used = 0;
630 /* Waste: Bytes used for alignment and padding */
631 unsigned long long min_waste = max, max_waste = 0,
632 avg_waste, total_waste = 0;
633 /* Number of objects in a slab */
634 unsigned long long min_objects = max, max_objects = 0,
635 avg_objects, total_objects = 0;
636 /* Waste per object */
637 unsigned long long min_objwaste = max,
638 max_objwaste = 0, avg_objwaste,
641 /* Memory per object */
642 unsigned long long min_memobj = max,
643 max_memobj = 0, avg_memobj,
646 /* Percentage of partial slabs per slab */
647 unsigned long min_ppart = 100, max_ppart = 0,
648 avg_ppart, total_ppart = 0;
650 /* Number of objects in partial slabs */
651 unsigned long min_partobj = max, max_partobj = 0,
652 avg_partobj, total_partobj = 0;
654 /* Percentage of partial objects of all objects in a slab */
655 unsigned long min_ppartobj = 100, max_ppartobj = 0,
656 avg_ppartobj, total_ppartobj = 0;
659 for (s = slabinfo; s < slabinfo + slabs; s++) {
660 unsigned long long size;
662 unsigned long long wasted;
663 unsigned long long objwaste;
664 long long objects_in_partial_slabs;
665 unsigned long percentage_partial_slabs;
666 unsigned long percentage_partial_objs;
668 if (!s->slabs || !s->objects)
674 used = s->objects * s->object_size;
675 wasted = size - used;
676 objwaste = s->slab_size - s->object_size;
678 objects_in_partial_slabs = s->objects -
679 (s->slabs - s->partial - s ->cpu_slabs) *
682 if (objects_in_partial_slabs < 0)
683 objects_in_partial_slabs = 0;
685 percentage_partial_slabs = s->partial * 100 / s->slabs;
686 if (percentage_partial_slabs > 100)
687 percentage_partial_slabs = 100;
689 percentage_partial_objs = objects_in_partial_slabs * 100
692 if (percentage_partial_objs > 100)
693 percentage_partial_objs = 100;
695 if (s->object_size < min_objsize)
696 min_objsize = s->object_size;
697 if (s->partial < min_partial)
698 min_partial = s->partial;
699 if (s->slabs < min_slabs)
700 min_slabs = s->slabs;
703 if (wasted < min_waste)
705 if (objwaste < min_objwaste)
706 min_objwaste = objwaste;
707 if (s->objects < min_objects)
708 min_objects = s->objects;
711 if (objects_in_partial_slabs < min_partobj)
712 min_partobj = objects_in_partial_slabs;
713 if (percentage_partial_slabs < min_ppart)
714 min_ppart = percentage_partial_slabs;
715 if (percentage_partial_objs < min_ppartobj)
716 min_ppartobj = percentage_partial_objs;
717 if (s->slab_size < min_memobj)
718 min_memobj = s->slab_size;
720 if (s->object_size > max_objsize)
721 max_objsize = s->object_size;
722 if (s->partial > max_partial)
723 max_partial = s->partial;
724 if (s->slabs > max_slabs)
725 max_slabs = s->slabs;
728 if (wasted > max_waste)
730 if (objwaste > max_objwaste)
731 max_objwaste = objwaste;
732 if (s->objects > max_objects)
733 max_objects = s->objects;
736 if (objects_in_partial_slabs > max_partobj)
737 max_partobj = objects_in_partial_slabs;
738 if (percentage_partial_slabs > max_ppart)
739 max_ppart = percentage_partial_slabs;
740 if (percentage_partial_objs > max_ppartobj)
741 max_ppartobj = percentage_partial_objs;
742 if (s->slab_size > max_memobj)
743 max_memobj = s->slab_size;
745 total_partial += s->partial;
746 total_slabs += s->slabs;
748 total_waste += wasted;
750 total_objects += s->objects;
752 total_partobj += objects_in_partial_slabs;
753 total_ppart += percentage_partial_slabs;
754 total_ppartobj += percentage_partial_objs;
756 total_objwaste += s->objects * objwaste;
757 total_objsize += s->objects * s->slab_size;
760 if (!total_objects) {
761 printf("No objects\n");
765 printf("No slabs\n");
769 /* Per slab averages */
770 avg_partial = total_partial / used_slabs;
771 avg_slabs = total_slabs / used_slabs;
772 avg_size = total_size / used_slabs;
773 avg_waste = total_waste / used_slabs;
775 avg_objects = total_objects / used_slabs;
776 avg_used = total_used / used_slabs;
777 avg_partobj = total_partobj / used_slabs;
778 avg_ppart = total_ppart / used_slabs;
779 avg_ppartobj = total_ppartobj / used_slabs;
781 /* Per object object sizes */
782 avg_objsize = total_used / total_objects;
783 avg_objwaste = total_objwaste / total_objects;
784 avg_partobj = total_partobj * 100 / total_objects;
785 avg_memobj = total_objsize / total_objects;
787 printf("Slabcache Totals\n");
788 printf("----------------\n");
789 printf("Slabcaches : %3d Aliases : %3d->%-3d Active: %3d\n",
790 slabs, aliases, alias_targets, used_slabs);
792 store_size(b1, total_size);store_size(b2, total_waste);
793 store_size(b3, total_waste * 100 / total_used);
794 printf("Memory used: %6s # Loss : %6s MRatio: %6s%%\n", b1, b2, b3);
796 store_size(b1, total_objects);store_size(b2, total_partobj);
797 store_size(b3, total_partobj * 100 / total_objects);
798 printf("# Objects : %6s # PartObj: %6s ORatio: %6s%%\n", b1, b2, b3);
801 printf("Per Cache Average Min Max Total\n");
802 printf("---------------------------------------------------------\n");
804 store_size(b1, avg_objects);store_size(b2, min_objects);
805 store_size(b3, max_objects);store_size(b4, total_objects);
806 printf("#Objects %10s %10s %10s %10s\n",
809 store_size(b1, avg_slabs);store_size(b2, min_slabs);
810 store_size(b3, max_slabs);store_size(b4, total_slabs);
811 printf("#Slabs %10s %10s %10s %10s\n",
814 store_size(b1, avg_partial);store_size(b2, min_partial);
815 store_size(b3, max_partial);store_size(b4, total_partial);
816 printf("#PartSlab %10s %10s %10s %10s\n",
818 store_size(b1, avg_ppart);store_size(b2, min_ppart);
819 store_size(b3, max_ppart);
820 store_size(b4, total_partial * 100 / total_slabs);
821 printf("%%PartSlab %10s%% %10s%% %10s%% %10s%%\n",
824 store_size(b1, avg_partobj);store_size(b2, min_partobj);
825 store_size(b3, max_partobj);
826 store_size(b4, total_partobj);
827 printf("PartObjs %10s %10s %10s %10s\n",
830 store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj);
831 store_size(b3, max_ppartobj);
832 store_size(b4, total_partobj * 100 / total_objects);
833 printf("%% PartObj %10s%% %10s%% %10s%% %10s%%\n",
836 store_size(b1, avg_size);store_size(b2, min_size);
837 store_size(b3, max_size);store_size(b4, total_size);
838 printf("Memory %10s %10s %10s %10s\n",
841 store_size(b1, avg_used);store_size(b2, min_used);
842 store_size(b3, max_used);store_size(b4, total_used);
843 printf("Used %10s %10s %10s %10s\n",
846 store_size(b1, avg_waste);store_size(b2, min_waste);
847 store_size(b3, max_waste);store_size(b4, total_waste);
848 printf("Loss %10s %10s %10s %10s\n",
852 printf("Per Object Average Min Max\n");
853 printf("---------------------------------------------\n");
855 store_size(b1, avg_memobj);store_size(b2, min_memobj);
856 store_size(b3, max_memobj);
857 printf("Memory %10s %10s %10s\n",
859 store_size(b1, avg_objsize);store_size(b2, min_objsize);
860 store_size(b3, max_objsize);
861 printf("User %10s %10s %10s\n",
864 store_size(b1, avg_objwaste);store_size(b2, min_objwaste);
865 store_size(b3, max_objwaste);
866 printf("Loss %10s %10s %10s\n",
870 void sort_slabs(void)
872 struct slabinfo *s1,*s2;
874 for (s1 = slabinfo; s1 < slabinfo + slabs; s1++) {
875 for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) {
879 result = slab_size(s1) < slab_size(s2);
881 result = strcasecmp(s1->name, s2->name);
889 memcpy(&t, s1, sizeof(struct slabinfo));
890 memcpy(s1, s2, sizeof(struct slabinfo));
891 memcpy(s2, &t, sizeof(struct slabinfo));
897 void sort_aliases(void)
899 struct aliasinfo *a1,*a2;
901 for (a1 = aliasinfo; a1 < aliasinfo + aliases; a1++) {
902 for (a2 = a1 + 1; a2 < aliasinfo + aliases; a2++) {
907 if (show_alias && !show_inverted) {
911 if (strcasecmp(n1, n2) > 0) {
914 memcpy(&t, a1, sizeof(struct aliasinfo));
915 memcpy(a1, a2, sizeof(struct aliasinfo));
916 memcpy(a2, &t, sizeof(struct aliasinfo));
922 void link_slabs(void)
927 for (a = aliasinfo; a < aliasinfo + aliases; a++) {
929 for (s = slabinfo; s < slabinfo + slabs; s++)
930 if (strcmp(a->ref, s->name) == 0) {
935 if (s == slabinfo + slabs)
936 fatal("Unresolved alias %s\n", a->ref);
948 for(a = aliasinfo; a < aliasinfo + aliases; a++) {
950 if (!show_single_ref && a->slab->refs == 1)
953 if (!show_inverted) {
955 if (strcmp(a->slab->name, active) == 0) {
956 printf(" %s", a->name);
960 printf("\n%-12s <- %s", a->slab->name, a->name);
961 active = a->slab->name;
964 printf("%-20s -> %s\n", a->name, a->slab->name);
971 void rename_slabs(void)
976 for (s = slabinfo; s < slabinfo + slabs; s++) {
980 if (s->refs > 1 && !show_first_alias)
983 a = find_one_alias(s);
994 int slab_mismatch(char *slab)
996 return regexec(&pattern, slab, 0, NULL, 0);
999 void read_slab_dir(void)
1003 struct slabinfo *slab = slabinfo;
1004 struct aliasinfo *alias = aliasinfo;
1009 if (chdir("/sys/slab"))
1010 fatal("SYSFS support for SLUB not active\n");
1013 while ((de = readdir(dir))) {
1014 if (de->d_name[0] == '.' ||
1015 (de->d_name[0] != ':' && slab_mismatch(de->d_name)))
1017 switch (de->d_type) {
1019 alias->name = strdup(de->d_name);
1020 count = readlink(de->d_name, buffer, sizeof(buffer));
1023 fatal("Cannot read symlink %s\n", de->d_name);
1027 while (p > buffer && p[-1] != '/')
1029 alias->ref = strdup(p);
1033 if (chdir(de->d_name))
1034 fatal("Unable to access slab %s\n", slab->name);
1035 slab->name = strdup(de->d_name);
1038 slab->aliases = get_obj("aliases");
1039 slab->align = get_obj("align");
1040 slab->cache_dma = get_obj("cache_dma");
1041 slab->cpu_slabs = get_obj("cpu_slabs");
1042 slab->destroy_by_rcu = get_obj("destroy_by_rcu");
1043 slab->hwcache_align = get_obj("hwcache_align");
1044 slab->object_size = get_obj("object_size");
1045 slab->objects = get_obj("objects");
1046 slab->objs_per_slab = get_obj("objs_per_slab");
1047 slab->order = get_obj("order");
1048 slab->partial = get_obj("partial");
1049 slab->partial = get_obj_and_str("partial", &t);
1050 decode_numa_list(slab->numa_partial, t);
1051 slab->poison = get_obj("poison");
1052 slab->reclaim_account = get_obj("reclaim_account");
1053 slab->red_zone = get_obj("red_zone");
1054 slab->sanity_checks = get_obj("sanity_checks");
1055 slab->slab_size = get_obj("slab_size");
1056 slab->slabs = get_obj_and_str("slabs", &t);
1057 decode_numa_list(slab->numa, t);
1058 slab->store_user = get_obj("store_user");
1059 slab->trace = get_obj("trace");
1061 if (slab->name[0] == ':')
1066 fatal("Unknown file type %lx\n", de->d_type);
1070 slabs = slab - slabinfo;
1071 actual_slabs = slabs;
1072 aliases = alias - aliasinfo;
1073 if (slabs > MAX_SLABS)
1074 fatal("Too many slabs\n");
1075 if (aliases > MAX_ALIASES)
1076 fatal("Too many aliases\n");
1079 void output_slabs(void)
1081 struct slabinfo *slab;
1083 for (slab = slabinfo; slab < slabinfo + slabs; slab++) {
1091 else if (show_track)
1092 show_tracking(slab);
1094 slab_validate(slab);
1106 struct option opts[] = {
1107 { "aliases", 0, NULL, 'a' },
1108 { "debug", 2, NULL, 'd' },
1109 { "empty", 0, NULL, 'e' },
1110 { "first-alias", 0, NULL, 'f' },
1111 { "help", 0, NULL, 'h' },
1112 { "inverted", 0, NULL, 'i'},
1113 { "numa", 0, NULL, 'n' },
1114 { "ops", 0, NULL, 'o' },
1115 { "report", 0, NULL, 'r' },
1116 { "shrink", 0, NULL, 's' },
1117 { "slabs", 0, NULL, 'l' },
1118 { "track", 0, NULL, 't'},
1119 { "validate", 0, NULL, 'v' },
1120 { "zero", 0, NULL, 'z' },
1121 { "1ref", 0, NULL, '1'},
1122 { NULL, 0, NULL, 0 }
1125 int main(int argc, char *argv[])
1129 char *pattern_source;
1131 page_size = getpagesize();
1133 while ((c = getopt_long(argc, argv, "ad::efhil1noprstvzTS",
1137 show_single_ref = 1;
1144 if (!debug_opt_scan(optarg))
1145 fatal("Invalid debug option '%s'\n", optarg);
1151 show_first_alias = 1;
1191 fatal("%s: Invalid option '%c'\n", argv[0], optopt);
1195 if (!show_slab && !show_alias && !show_track && !show_report
1196 && !validate && !shrink && !set_debug && !show_ops)
1200 pattern_source = argv[optind];
1202 pattern_source = ".*";
1204 err = regcomp(&pattern, pattern_source, REG_ICASE|REG_NOSUB);
1206 fatal("%s: Invalid pattern '%s' code %d\n",
1207 argv[0], pattern_source, err);