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));
250 node = strtoul(t, &t, 10);
253 nr = strtoul(t, &t, 10);
255 if (node > highest_node)
263 void slab_validate(struct slabinfo *s)
265 set_obj(s, "validate", 1);
268 void slab_shrink(struct slabinfo *s)
270 set_obj(s, "shrink", 1);
275 void first_line(void)
277 printf("Name Objects Objsize Space "
278 "Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n");
282 * Find the shortest alias of a slab
284 struct aliasinfo *find_one_alias(struct slabinfo *find)
287 struct aliasinfo *best = NULL;
289 for(a = aliasinfo;a < aliasinfo + aliases; a++) {
290 if (a->slab == find &&
291 (!best || strlen(best->name) < strlen(a->name))) {
293 if (strncmp(a->name,"kmall", 5) == 0)
300 unsigned long slab_size(struct slabinfo *s)
302 return s->slabs * (page_size << s->order);
305 void slab_numa(struct slabinfo *s, int mode)
309 if (strcmp(s->name, "*") == 0)
313 printf("\n%s: No NUMA information available.\n", s->name);
317 if (skip_zero && !s->slabs)
321 printf("\n%-21s:", mode ? "NUMA nodes" : "Slab");
322 for(node = 0; node <= highest_node; node++)
323 printf(" %4d", node);
324 printf("\n----------------------");
325 for(node = 0; node <= highest_node; node++)
329 printf("%-21s ", mode ? "All slabs" : s->name);
330 for(node = 0; node <= highest_node; node++) {
333 store_size(b, s->numa[node]);
338 printf("%-21s ", "Partial slabs");
339 for(node = 0; node <= highest_node; node++) {
342 store_size(b, s->numa_partial[node]);
350 void show_tracking(struct slabinfo *s)
352 printf("\n%s: Kernel object allocation\n", s->name);
353 printf("-----------------------------------------------------------------------\n");
354 if (read_slab_obj(s, "alloc_calls"))
359 printf("\n%s: Kernel object freeing\n", s->name);
360 printf("------------------------------------------------------------------------\n");
361 if (read_slab_obj(s, "free_calls"))
368 void ops(struct slabinfo *s)
370 if (strcmp(s->name, "*") == 0)
373 if (read_slab_obj(s, "ops")) {
374 printf("\n%s: kmem_cache operations\n", s->name);
375 printf("--------------------------------------------\n");
378 printf("\n%s has no kmem_cache operations\n", s->name);
381 const char *onoff(int x)
388 void report(struct slabinfo *s)
390 if (strcmp(s->name, "*") == 0)
393 printf("\nSlabcache: %-20s Aliases: %2d Order : %2d Objects: %d\n",
394 s->name, s->aliases, s->order, s->objects);
395 if (s->hwcache_align)
396 printf("** Hardware cacheline aligned\n");
398 printf("** Memory is allocated in a special DMA zone\n");
399 if (s->destroy_by_rcu)
400 printf("** Slabs are destroyed via RCU\n");
401 if (s->reclaim_account)
402 printf("** Reclaim accounting active\n");
404 printf("\nSizes (bytes) Slabs Debug Memory\n");
405 printf("------------------------------------------------------------------------\n");
406 printf("Object : %7d Total : %7ld Sanity Checks : %s Total: %7ld\n",
407 s->object_size, s->slabs, onoff(s->sanity_checks),
408 s->slabs * (page_size << s->order));
409 printf("SlabObj: %7d Full : %7ld Redzoning : %s Used : %7ld\n",
410 s->slab_size, s->slabs - s->partial - s->cpu_slabs,
411 onoff(s->red_zone), s->objects * s->object_size);
412 printf("SlabSiz: %7d Partial: %7ld Poisoning : %s Loss : %7ld\n",
413 page_size << s->order, s->partial, onoff(s->poison),
414 s->slabs * (page_size << s->order) - s->objects * s->object_size);
415 printf("Loss : %7d CpuSlab: %7d Tracking : %s Lalig: %7ld\n",
416 s->slab_size - s->object_size, s->cpu_slabs, onoff(s->store_user),
417 (s->slab_size - s->object_size) * s->objects);
418 printf("Align : %7d Objects: %7d Tracing : %s Lpadd: %7ld\n",
419 s->align, s->objs_per_slab, onoff(s->trace),
420 ((page_size << s->order) - s->objs_per_slab * s->slab_size) *
428 void slabcache(struct slabinfo *s)
435 if (strcmp(s->name, "*") == 0)
438 if (actual_slabs == 1) {
443 if (skip_zero && !show_empty && !s->slabs)
446 if (show_empty && s->slabs)
449 store_size(size_str, slab_size(s));
450 sprintf(dist_str,"%lu/%lu/%d", s->slabs, s->partial, s->cpu_slabs);
459 if (s->hwcache_align)
463 if (s->reclaim_account)
467 if (s->sanity_checks)
475 printf("%-21s %8ld %7d %8s %14s %4d %1d %3ld %3ld %s\n",
476 s->name, s->objects, s->object_size, size_str, dist_str,
477 s->objs_per_slab, s->order,
478 s->slabs ? (s->partial * 100) / s->slabs : 100,
479 s->slabs ? (s->objects * s->object_size * 100) /
480 (s->slabs * (page_size << s->order)) : 100,
485 * Analyze debug options. Return false if something is amiss.
487 int debug_opt_scan(char *opt)
489 if (!opt || !opt[0] || strcmp(opt, "-") == 0)
492 if (strcasecmp(opt, "a") == 0) {
536 int slab_empty(struct slabinfo *s)
542 * We may still have slabs even if there are no objects. Shrinking will
546 set_obj(s, "shrink", 1);
551 void slab_debug(struct slabinfo *s)
553 if (sanity && !s->sanity_checks) {
554 set_obj(s, "sanity", 1);
556 if (!sanity && s->sanity_checks) {
558 set_obj(s, "sanity", 0);
560 fprintf(stderr, "%s not empty cannot disable sanity checks\n", s->name);
562 if (redzone && !s->red_zone) {
564 set_obj(s, "red_zone", 1);
566 fprintf(stderr, "%s not empty cannot enable redzoning\n", s->name);
568 if (!redzone && s->red_zone) {
570 set_obj(s, "red_zone", 0);
572 fprintf(stderr, "%s not empty cannot disable redzoning\n", s->name);
574 if (poison && !s->poison) {
576 set_obj(s, "poison", 1);
578 fprintf(stderr, "%s not empty cannot enable poisoning\n", s->name);
580 if (!poison && s->poison) {
582 set_obj(s, "poison", 0);
584 fprintf(stderr, "%s not empty cannot disable poisoning\n", s->name);
586 if (tracking && !s->store_user) {
588 set_obj(s, "store_user", 1);
590 fprintf(stderr, "%s not empty cannot enable tracking\n", s->name);
592 if (!tracking && s->store_user) {
594 set_obj(s, "store_user", 0);
596 fprintf(stderr, "%s not empty cannot disable tracking\n", s->name);
598 if (tracing && !s->trace) {
600 set_obj(s, "trace", 1);
602 fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
604 if (!tracing && s->trace)
605 set_obj(s, "trace", 1);
613 char b1[20], b2[20], b3[20], b4[20];
614 unsigned long long max = 1ULL << 63;
617 unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
619 /* Number of partial slabs in a slabcache */
620 unsigned long long min_partial = max, max_partial = 0,
621 avg_partial, total_partial = 0;
623 /* Number of slabs in a slab cache */
624 unsigned long long min_slabs = max, max_slabs = 0,
625 avg_slabs, total_slabs = 0;
627 /* Size of the whole slab */
628 unsigned long long min_size = max, max_size = 0,
629 avg_size, total_size = 0;
631 /* Bytes used for object storage in a slab */
632 unsigned long long min_used = max, max_used = 0,
633 avg_used, total_used = 0;
635 /* Waste: Bytes used for alignment and padding */
636 unsigned long long min_waste = max, max_waste = 0,
637 avg_waste, total_waste = 0;
638 /* Number of objects in a slab */
639 unsigned long long min_objects = max, max_objects = 0,
640 avg_objects, total_objects = 0;
641 /* Waste per object */
642 unsigned long long min_objwaste = max,
643 max_objwaste = 0, avg_objwaste,
646 /* Memory per object */
647 unsigned long long min_memobj = max,
648 max_memobj = 0, avg_memobj,
651 /* Percentage of partial slabs per slab */
652 unsigned long min_ppart = 100, max_ppart = 0,
653 avg_ppart, total_ppart = 0;
655 /* Number of objects in partial slabs */
656 unsigned long min_partobj = max, max_partobj = 0,
657 avg_partobj, total_partobj = 0;
659 /* Percentage of partial objects of all objects in a slab */
660 unsigned long min_ppartobj = 100, max_ppartobj = 0,
661 avg_ppartobj, total_ppartobj = 0;
664 for (s = slabinfo; s < slabinfo + slabs; s++) {
665 unsigned long long size;
667 unsigned long long wasted;
668 unsigned long long objwaste;
669 long long objects_in_partial_slabs;
670 unsigned long percentage_partial_slabs;
671 unsigned long percentage_partial_objs;
673 if (!s->slabs || !s->objects)
679 used = s->objects * s->object_size;
680 wasted = size - used;
681 objwaste = s->slab_size - s->object_size;
683 objects_in_partial_slabs = s->objects -
684 (s->slabs - s->partial - s ->cpu_slabs) *
687 if (objects_in_partial_slabs < 0)
688 objects_in_partial_slabs = 0;
690 percentage_partial_slabs = s->partial * 100 / s->slabs;
691 if (percentage_partial_slabs > 100)
692 percentage_partial_slabs = 100;
694 percentage_partial_objs = objects_in_partial_slabs * 100
697 if (percentage_partial_objs > 100)
698 percentage_partial_objs = 100;
700 if (s->object_size < min_objsize)
701 min_objsize = s->object_size;
702 if (s->partial < min_partial)
703 min_partial = s->partial;
704 if (s->slabs < min_slabs)
705 min_slabs = s->slabs;
708 if (wasted < min_waste)
710 if (objwaste < min_objwaste)
711 min_objwaste = objwaste;
712 if (s->objects < min_objects)
713 min_objects = s->objects;
716 if (objects_in_partial_slabs < min_partobj)
717 min_partobj = objects_in_partial_slabs;
718 if (percentage_partial_slabs < min_ppart)
719 min_ppart = percentage_partial_slabs;
720 if (percentage_partial_objs < min_ppartobj)
721 min_ppartobj = percentage_partial_objs;
722 if (s->slab_size < min_memobj)
723 min_memobj = s->slab_size;
725 if (s->object_size > max_objsize)
726 max_objsize = s->object_size;
727 if (s->partial > max_partial)
728 max_partial = s->partial;
729 if (s->slabs > max_slabs)
730 max_slabs = s->slabs;
733 if (wasted > max_waste)
735 if (objwaste > max_objwaste)
736 max_objwaste = objwaste;
737 if (s->objects > max_objects)
738 max_objects = s->objects;
741 if (objects_in_partial_slabs > max_partobj)
742 max_partobj = objects_in_partial_slabs;
743 if (percentage_partial_slabs > max_ppart)
744 max_ppart = percentage_partial_slabs;
745 if (percentage_partial_objs > max_ppartobj)
746 max_ppartobj = percentage_partial_objs;
747 if (s->slab_size > max_memobj)
748 max_memobj = s->slab_size;
750 total_partial += s->partial;
751 total_slabs += s->slabs;
753 total_waste += wasted;
755 total_objects += s->objects;
757 total_partobj += objects_in_partial_slabs;
758 total_ppart += percentage_partial_slabs;
759 total_ppartobj += percentage_partial_objs;
761 total_objwaste += s->objects * objwaste;
762 total_objsize += s->objects * s->slab_size;
765 if (!total_objects) {
766 printf("No objects\n");
770 printf("No slabs\n");
774 /* Per slab averages */
775 avg_partial = total_partial / used_slabs;
776 avg_slabs = total_slabs / used_slabs;
777 avg_size = total_size / used_slabs;
778 avg_waste = total_waste / used_slabs;
780 avg_objects = total_objects / used_slabs;
781 avg_used = total_used / used_slabs;
782 avg_partobj = total_partobj / used_slabs;
783 avg_ppart = total_ppart / used_slabs;
784 avg_ppartobj = total_ppartobj / used_slabs;
786 /* Per object object sizes */
787 avg_objsize = total_used / total_objects;
788 avg_objwaste = total_objwaste / total_objects;
789 avg_partobj = total_partobj * 100 / total_objects;
790 avg_memobj = total_objsize / total_objects;
792 printf("Slabcache Totals\n");
793 printf("----------------\n");
794 printf("Slabcaches : %3d Aliases : %3d->%-3d Active: %3d\n",
795 slabs, aliases, alias_targets, used_slabs);
797 store_size(b1, total_size);store_size(b2, total_waste);
798 store_size(b3, total_waste * 100 / total_used);
799 printf("Memory used: %6s # Loss : %6s MRatio:%6s%%\n", b1, b2, b3);
801 store_size(b1, total_objects);store_size(b2, total_partobj);
802 store_size(b3, total_partobj * 100 / total_objects);
803 printf("# Objects : %6s # PartObj: %6s ORatio:%6s%%\n", b1, b2, b3);
806 printf("Per Cache Average Min Max Total\n");
807 printf("---------------------------------------------------------\n");
809 store_size(b1, avg_objects);store_size(b2, min_objects);
810 store_size(b3, max_objects);store_size(b4, total_objects);
811 printf("#Objects %10s %10s %10s %10s\n",
814 store_size(b1, avg_slabs);store_size(b2, min_slabs);
815 store_size(b3, max_slabs);store_size(b4, total_slabs);
816 printf("#Slabs %10s %10s %10s %10s\n",
819 store_size(b1, avg_partial);store_size(b2, min_partial);
820 store_size(b3, max_partial);store_size(b4, total_partial);
821 printf("#PartSlab %10s %10s %10s %10s\n",
823 store_size(b1, avg_ppart);store_size(b2, min_ppart);
824 store_size(b3, max_ppart);
825 store_size(b4, total_partial * 100 / total_slabs);
826 printf("%%PartSlab%10s%% %10s%% %10s%% %10s%%\n",
829 store_size(b1, avg_partobj);store_size(b2, min_partobj);
830 store_size(b3, max_partobj);
831 store_size(b4, total_partobj);
832 printf("PartObjs %10s %10s %10s %10s\n",
835 store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj);
836 store_size(b3, max_ppartobj);
837 store_size(b4, total_partobj * 100 / total_objects);
838 printf("%% PartObj%10s%% %10s%% %10s%% %10s%%\n",
841 store_size(b1, avg_size);store_size(b2, min_size);
842 store_size(b3, max_size);store_size(b4, total_size);
843 printf("Memory %10s %10s %10s %10s\n",
846 store_size(b1, avg_used);store_size(b2, min_used);
847 store_size(b3, max_used);store_size(b4, total_used);
848 printf("Used %10s %10s %10s %10s\n",
851 store_size(b1, avg_waste);store_size(b2, min_waste);
852 store_size(b3, max_waste);store_size(b4, total_waste);
853 printf("Loss %10s %10s %10s %10s\n",
857 printf("Per Object Average Min Max\n");
858 printf("---------------------------------------------\n");
860 store_size(b1, avg_memobj);store_size(b2, min_memobj);
861 store_size(b3, max_memobj);
862 printf("Memory %10s %10s %10s\n",
864 store_size(b1, avg_objsize);store_size(b2, min_objsize);
865 store_size(b3, max_objsize);
866 printf("User %10s %10s %10s\n",
869 store_size(b1, avg_objwaste);store_size(b2, min_objwaste);
870 store_size(b3, max_objwaste);
871 printf("Loss %10s %10s %10s\n",
875 void sort_slabs(void)
877 struct slabinfo *s1,*s2;
879 for (s1 = slabinfo; s1 < slabinfo + slabs; s1++) {
880 for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) {
884 result = slab_size(s1) < slab_size(s2);
886 result = strcasecmp(s1->name, s2->name);
894 memcpy(&t, s1, sizeof(struct slabinfo));
895 memcpy(s1, s2, sizeof(struct slabinfo));
896 memcpy(s2, &t, sizeof(struct slabinfo));
902 void sort_aliases(void)
904 struct aliasinfo *a1,*a2;
906 for (a1 = aliasinfo; a1 < aliasinfo + aliases; a1++) {
907 for (a2 = a1 + 1; a2 < aliasinfo + aliases; a2++) {
912 if (show_alias && !show_inverted) {
916 if (strcasecmp(n1, n2) > 0) {
919 memcpy(&t, a1, sizeof(struct aliasinfo));
920 memcpy(a1, a2, sizeof(struct aliasinfo));
921 memcpy(a2, &t, sizeof(struct aliasinfo));
927 void link_slabs(void)
932 for (a = aliasinfo; a < aliasinfo + aliases; a++) {
934 for (s = slabinfo; s < slabinfo + slabs; s++)
935 if (strcmp(a->ref, s->name) == 0) {
940 if (s == slabinfo + slabs)
941 fatal("Unresolved alias %s\n", a->ref);
953 for(a = aliasinfo; a < aliasinfo + aliases; a++) {
955 if (!show_single_ref && a->slab->refs == 1)
958 if (!show_inverted) {
960 if (strcmp(a->slab->name, active) == 0) {
961 printf(" %s", a->name);
965 printf("\n%-12s <- %s", a->slab->name, a->name);
966 active = a->slab->name;
969 printf("%-20s -> %s\n", a->name, a->slab->name);
976 void rename_slabs(void)
981 for (s = slabinfo; s < slabinfo + slabs; s++) {
985 if (s->refs > 1 && !show_first_alias)
988 a = find_one_alias(s);
999 int slab_mismatch(char *slab)
1001 return regexec(&pattern, slab, 0, NULL, 0);
1004 void read_slab_dir(void)
1008 struct slabinfo *slab = slabinfo;
1009 struct aliasinfo *alias = aliasinfo;
1014 if (chdir("/sys/slab"))
1015 fatal("SYSFS support for SLUB not active\n");
1018 while ((de = readdir(dir))) {
1019 if (de->d_name[0] == '.' ||
1020 (de->d_name[0] != ':' && slab_mismatch(de->d_name)))
1022 switch (de->d_type) {
1024 alias->name = strdup(de->d_name);
1025 count = readlink(de->d_name, buffer, sizeof(buffer));
1028 fatal("Cannot read symlink %s\n", de->d_name);
1032 while (p > buffer && p[-1] != '/')
1034 alias->ref = strdup(p);
1038 if (chdir(de->d_name))
1039 fatal("Unable to access slab %s\n", slab->name);
1040 slab->name = strdup(de->d_name);
1043 slab->aliases = get_obj("aliases");
1044 slab->align = get_obj("align");
1045 slab->cache_dma = get_obj("cache_dma");
1046 slab->cpu_slabs = get_obj("cpu_slabs");
1047 slab->destroy_by_rcu = get_obj("destroy_by_rcu");
1048 slab->hwcache_align = get_obj("hwcache_align");
1049 slab->object_size = get_obj("object_size");
1050 slab->objects = get_obj("objects");
1051 slab->objs_per_slab = get_obj("objs_per_slab");
1052 slab->order = get_obj("order");
1053 slab->partial = get_obj("partial");
1054 slab->partial = get_obj_and_str("partial", &t);
1055 decode_numa_list(slab->numa_partial, t);
1056 slab->poison = get_obj("poison");
1057 slab->reclaim_account = get_obj("reclaim_account");
1058 slab->red_zone = get_obj("red_zone");
1059 slab->sanity_checks = get_obj("sanity_checks");
1060 slab->slab_size = get_obj("slab_size");
1061 slab->slabs = get_obj_and_str("slabs", &t);
1062 decode_numa_list(slab->numa, t);
1063 slab->store_user = get_obj("store_user");
1064 slab->trace = get_obj("trace");
1066 if (slab->name[0] == ':')
1071 fatal("Unknown file type %lx\n", de->d_type);
1075 slabs = slab - slabinfo;
1076 actual_slabs = slabs;
1077 aliases = alias - aliasinfo;
1078 if (slabs > MAX_SLABS)
1079 fatal("Too many slabs\n");
1080 if (aliases > MAX_ALIASES)
1081 fatal("Too many aliases\n");
1084 void output_slabs(void)
1086 struct slabinfo *slab;
1088 for (slab = slabinfo; slab < slabinfo + slabs; slab++) {
1096 else if (show_track)
1097 show_tracking(slab);
1099 slab_validate(slab);
1108 else if (show_report)
1113 struct option opts[] = {
1114 { "aliases", 0, NULL, 'a' },
1115 { "debug", 2, NULL, 'd' },
1116 { "empty", 0, NULL, 'e' },
1117 { "first-alias", 0, NULL, 'f' },
1118 { "help", 0, NULL, 'h' },
1119 { "inverted", 0, NULL, 'i'},
1120 { "numa", 0, NULL, 'n' },
1121 { "ops", 0, NULL, 'o' },
1122 { "report", 0, NULL, 'r' },
1123 { "shrink", 0, NULL, 's' },
1124 { "slabs", 0, NULL, 'l' },
1125 { "track", 0, NULL, 't'},
1126 { "validate", 0, NULL, 'v' },
1127 { "zero", 0, NULL, 'z' },
1128 { "1ref", 0, NULL, '1'},
1129 { NULL, 0, NULL, 0 }
1132 int main(int argc, char *argv[])
1136 char *pattern_source;
1138 page_size = getpagesize();
1140 while ((c = getopt_long(argc, argv, "ad::efhil1noprstvzTS",
1144 show_single_ref = 1;
1151 if (!debug_opt_scan(optarg))
1152 fatal("Invalid debug option '%s'\n", optarg);
1158 show_first_alias = 1;
1198 fatal("%s: Invalid option '%c'\n", argv[0], optopt);
1202 if (!show_slab && !show_alias && !show_track && !show_report
1203 && !validate && !shrink && !set_debug && !show_ops)
1207 pattern_source = argv[optind];
1209 pattern_source = ".*";
1211 err = regcomp(&pattern, pattern_source, REG_ICASE|REG_NOSUB);
1213 fatal("%s: Invalid pattern '%s' code %d\n",
1214 argv[0], pattern_source, err);