License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2007-05-06 21:49:48 +00:00
|
|
|
/*
|
|
|
|
* Slabinfo: Tool to get reports about slabs
|
|
|
|
*
|
2008-07-04 16:59:22 +00:00
|
|
|
* (C) 2007 sgi, Christoph Lameter
|
2011-06-01 17:26:00 +00:00
|
|
|
* (C) 2011 Linux Foundation, Christoph Lameter
|
2007-05-06 21:49:48 +00:00
|
|
|
*
|
2011-06-01 17:26:00 +00:00
|
|
|
* Compile with:
|
2007-05-06 21:49:48 +00:00
|
|
|
*
|
|
|
|
* gcc -o slabinfo slabinfo.c
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
2007-10-17 06:31:29 +00:00
|
|
|
#include <strings.h>
|
2007-05-06 21:49:48 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <regex.h>
|
2007-05-09 09:32:37 +00:00
|
|
|
#include <errno.h>
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
#define MAX_SLABS 500
|
|
|
|
#define MAX_ALIASES 500
|
|
|
|
#define MAX_NODES 1024
|
|
|
|
|
|
|
|
struct slabinfo {
|
|
|
|
char *name;
|
|
|
|
int alias;
|
|
|
|
int refs;
|
|
|
|
int aliases, align, cache_dma, cpu_slabs, destroy_by_rcu;
|
2018-09-04 22:45:48 +00:00
|
|
|
unsigned int hwcache_align, object_size, objs_per_slab;
|
|
|
|
unsigned int sanity_checks, slab_size, store_user, trace;
|
2007-05-06 21:49:48 +00:00
|
|
|
int order, poison, reclaim_account, red_zone;
|
2008-04-14 16:11:40 +00:00
|
|
|
unsigned long partial, objects, slabs, objects_partial, objects_total;
|
2008-02-08 01:47:41 +00:00
|
|
|
unsigned long alloc_fastpath, alloc_slowpath;
|
|
|
|
unsigned long free_fastpath, free_slowpath;
|
|
|
|
unsigned long free_frozen, free_add_partial, free_remove_partial;
|
|
|
|
unsigned long alloc_from_partial, alloc_slab, free_slab, alloc_refill;
|
|
|
|
unsigned long cpuslab_flush, deactivate_full, deactivate_empty;
|
|
|
|
unsigned long deactivate_to_head, deactivate_to_tail;
|
2008-04-29 23:14:46 +00:00
|
|
|
unsigned long deactivate_remote_frees, order_fallback;
|
2011-06-01 17:26:00 +00:00
|
|
|
unsigned long cmpxchg_double_cpu_fail, cmpxchg_double_fail;
|
|
|
|
unsigned long alloc_node_mismatch, deactivate_bypass;
|
2011-08-09 21:12:28 +00:00
|
|
|
unsigned long cpu_partial_alloc, cpu_partial_free;
|
2007-05-06 21:49:48 +00:00
|
|
|
int numa[MAX_NODES];
|
|
|
|
int numa_partial[MAX_NODES];
|
|
|
|
} slabinfo[MAX_SLABS];
|
|
|
|
|
|
|
|
struct aliasinfo {
|
|
|
|
char *name;
|
|
|
|
char *ref;
|
|
|
|
struct slabinfo *slab;
|
|
|
|
} aliasinfo[MAX_ALIASES];
|
|
|
|
|
2015-11-06 02:45:34 +00:00
|
|
|
int slabs;
|
|
|
|
int actual_slabs;
|
|
|
|
int aliases;
|
|
|
|
int alias_targets;
|
|
|
|
int highest_node;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
char buffer[4096];
|
|
|
|
|
2015-11-06 02:45:34 +00:00
|
|
|
int show_empty;
|
|
|
|
int show_report;
|
|
|
|
int show_alias;
|
|
|
|
int show_slab;
|
2007-05-06 21:49:48 +00:00
|
|
|
int skip_zero = 1;
|
2015-11-06 02:45:34 +00:00
|
|
|
int show_numa;
|
|
|
|
int show_track;
|
|
|
|
int show_first_alias;
|
|
|
|
int validate;
|
|
|
|
int shrink;
|
|
|
|
int show_inverted;
|
|
|
|
int show_single_ref;
|
|
|
|
int show_totals;
|
|
|
|
int sort_size;
|
|
|
|
int sort_active;
|
|
|
|
int set_debug;
|
|
|
|
int show_ops;
|
2019-07-12 03:59:38 +00:00
|
|
|
int sort_partial;
|
2015-11-06 02:45:34 +00:00
|
|
|
int show_activity;
|
2015-11-06 02:45:20 +00:00
|
|
|
int output_lines = -1;
|
2015-11-06 02:45:22 +00:00
|
|
|
int sort_loss;
|
2015-11-06 02:45:28 +00:00
|
|
|
int extended_totals;
|
2015-11-06 02:45:31 +00:00
|
|
|
int show_bytes;
|
2017-11-16 01:31:59 +00:00
|
|
|
int unreclaim_only;
|
2007-05-09 09:32:37 +00:00
|
|
|
|
|
|
|
/* Debug options */
|
2015-11-06 02:45:34 +00:00
|
|
|
int sanity;
|
|
|
|
int redzone;
|
|
|
|
int poison;
|
|
|
|
int tracking;
|
|
|
|
int tracing;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
int page_size;
|
|
|
|
|
|
|
|
regex_t pattern;
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void fatal(const char *x, ...)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, x);
|
|
|
|
vfprintf(stderr, x, ap);
|
|
|
|
va_end(ap);
|
2007-10-17 06:31:29 +00:00
|
|
|
exit(EXIT_FAILURE);
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void usage(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation.\n\n"
|
2019-07-12 03:59:42 +00:00
|
|
|
"slabinfo [-aABDefhilLnoPrsStTUvXz1] [N=K] [-dafzput] [slab-regexp]\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
"-a|--aliases Show aliases\n"
|
2008-02-08 01:47:41 +00:00
|
|
|
"-A|--activity Most active slabs first\n"
|
2019-03-05 23:49:03 +00:00
|
|
|
"-B|--Bytes Show size in bytes\n"
|
2008-02-08 01:47:41 +00:00
|
|
|
"-D|--display-active Switch line format to activity\n"
|
|
|
|
"-e|--empty Show empty slabs\n"
|
2007-05-09 09:32:37 +00:00
|
|
|
"-f|--first-alias Show first alias\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
"-h|--help Show usage information\n"
|
2007-05-09 09:32:37 +00:00
|
|
|
"-i|--inverted Inverted list\n"
|
|
|
|
"-l|--slabs Show slabs\n"
|
2019-03-05 23:49:03 +00:00
|
|
|
"-L|--Loss Sort by loss\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
"-n|--numa Show NUMA information\n"
|
2019-03-05 23:49:03 +00:00
|
|
|
"-N|--lines=K Show the first K slabs\n"
|
2019-03-05 23:49:07 +00:00
|
|
|
"-o|--ops Show kmem_cache_ops\n"
|
2022-05-28 06:31:17 +00:00
|
|
|
"-P|--partial Sort by number of partial slabs\n"
|
2019-03-05 23:49:07 +00:00
|
|
|
"-r|--report Detailed report on single slabs\n"
|
2019-03-05 23:49:03 +00:00
|
|
|
"-s|--shrink Shrink slabs\n"
|
2007-05-09 09:32:37 +00:00
|
|
|
"-S|--Size Sort by size\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
"-t|--tracking Show alloc/free information\n"
|
|
|
|
"-T|--Totals Show summary information\n"
|
2019-03-05 23:49:07 +00:00
|
|
|
"-U|--Unreclaim Show unreclaimable slabs only\n"
|
2007-05-09 09:32:37 +00:00
|
|
|
"-v|--validate Validate slabs\n"
|
2019-07-12 03:59:34 +00:00
|
|
|
"-X|--Xtotals Show extended summary information\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
"-z|--zero Include empty slabs\n"
|
|
|
|
"-1|--1ref Single reference\n"
|
2019-03-05 23:49:03 +00:00
|
|
|
|
2019-03-05 23:49:10 +00:00
|
|
|
"\n"
|
|
|
|
"-d | --debug Switch off all debug options\n"
|
|
|
|
"-da | --debug=a Switch on all debug options (--debug=FZPU)\n"
|
|
|
|
|
|
|
|
"\n"
|
|
|
|
"-d[afzput] | --debug=[afzput]\n"
|
|
|
|
" f | F Sanity Checks (SLAB_CONSISTENCY_CHECKS)\n"
|
|
|
|
" z | Z Redzoning\n"
|
|
|
|
" p | P Poisoning\n"
|
|
|
|
" u | U Tracking\n"
|
|
|
|
" t | T Tracing\n"
|
2019-07-12 03:59:46 +00:00
|
|
|
|
|
|
|
"\nSorting options (--Loss, --Size, --Partial) are mutually exclusive\n"
|
2007-05-06 21:49:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long read_obj(const char *name)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
FILE *f = fopen(name, "r");
|
|
|
|
|
2022-11-08 12:47:57 +00:00
|
|
|
if (!f) {
|
2007-05-06 21:49:48 +00:00
|
|
|
buffer[0] = 0;
|
2022-11-08 12:47:57 +00:00
|
|
|
if (errno == EACCES)
|
|
|
|
fatal("%s, Try using superuser\n", strerror(errno));
|
|
|
|
} else {
|
2007-10-17 06:31:29 +00:00
|
|
|
if (!fgets(buffer, sizeof(buffer), f))
|
2007-05-06 21:49:48 +00:00
|
|
|
buffer[0] = 0;
|
|
|
|
fclose(f);
|
|
|
|
if (buffer[strlen(buffer)] == '\n')
|
|
|
|
buffer[strlen(buffer)] = 0;
|
|
|
|
}
|
|
|
|
return strlen(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the contents of an attribute
|
|
|
|
*/
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long get_obj(const char *name)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
if (!read_obj(name))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return atol(buffer);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long get_obj_and_str(const char *name, char **x)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
unsigned long result = 0;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
*x = NULL;
|
|
|
|
|
|
|
|
if (!read_obj(name)) {
|
|
|
|
x = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
result = strtoul(buffer, &p, 10);
|
|
|
|
while (*p == ' ')
|
|
|
|
p++;
|
|
|
|
if (*p)
|
|
|
|
*x = strdup(p);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void set_obj(struct slabinfo *s, const char *name, int n)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
char x[100];
|
2007-05-09 09:32:37 +00:00
|
|
|
FILE *f;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-10-17 06:31:29 +00:00
|
|
|
snprintf(x, 100, "%s/%s", s->name, name);
|
2007-05-09 09:32:37 +00:00
|
|
|
f = fopen(x, "w");
|
2007-05-06 21:49:48 +00:00
|
|
|
if (!f)
|
|
|
|
fatal("Cannot write to %s\n", x);
|
|
|
|
|
|
|
|
fprintf(f, "%d\n", n);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long read_slab_obj(struct slabinfo *s, const char *name)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
char x[100];
|
|
|
|
FILE *f;
|
2007-10-17 06:31:29 +00:00
|
|
|
size_t l;
|
2007-05-09 09:32:37 +00:00
|
|
|
|
2007-10-17 06:31:29 +00:00
|
|
|
snprintf(x, 100, "%s/%s", s->name, name);
|
2007-05-09 09:32:37 +00:00
|
|
|
f = fopen(x, "r");
|
|
|
|
if (!f) {
|
|
|
|
buffer[0] = 0;
|
|
|
|
l = 0;
|
|
|
|
} else {
|
|
|
|
l = fread(buffer, 1, sizeof(buffer), f);
|
|
|
|
buffer[l] = 0;
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2022-06-23 21:45:52 +00:00
|
|
|
static unsigned long read_debug_slab_obj(struct slabinfo *s, const char *name)
|
|
|
|
{
|
|
|
|
char x[128];
|
|
|
|
FILE *f;
|
|
|
|
size_t l;
|
|
|
|
|
|
|
|
snprintf(x, 128, "/sys/kernel/debug/slab/%s/%s", s->name, name);
|
|
|
|
f = fopen(x, "r");
|
|
|
|
if (!f) {
|
|
|
|
buffer[0] = 0;
|
|
|
|
l = 0;
|
|
|
|
} else {
|
|
|
|
l = fread(buffer, 1, sizeof(buffer), f);
|
|
|
|
buffer[l] = 0;
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
}
|
2007-05-09 09:32:37 +00:00
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
/*
|
|
|
|
* Put a size string together
|
|
|
|
*/
|
2009-09-22 23:43:42 +00:00
|
|
|
static int store_size(char *buffer, unsigned long value)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
unsigned long divisor = 1;
|
|
|
|
char trailer = 0;
|
|
|
|
int n;
|
|
|
|
|
2015-11-06 02:45:31 +00:00
|
|
|
if (!show_bytes) {
|
|
|
|
if (value > 1000000000UL) {
|
|
|
|
divisor = 100000000UL;
|
|
|
|
trailer = 'G';
|
|
|
|
} else if (value > 1000000UL) {
|
|
|
|
divisor = 100000UL;
|
|
|
|
trailer = 'M';
|
|
|
|
} else if (value > 1000UL) {
|
|
|
|
divisor = 100;
|
|
|
|
trailer = 'K';
|
|
|
|
}
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
value /= divisor;
|
|
|
|
n = sprintf(buffer, "%ld",value);
|
|
|
|
if (trailer) {
|
|
|
|
buffer[n] = trailer;
|
|
|
|
n++;
|
|
|
|
buffer[n] = 0;
|
|
|
|
}
|
|
|
|
if (divisor != 1) {
|
|
|
|
memmove(buffer + n - 2, buffer + n - 3, 4);
|
|
|
|
buffer[n-2] = '.';
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void decode_numa_list(int *numa, char *t)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
int node;
|
|
|
|
int nr;
|
|
|
|
|
|
|
|
memset(numa, 0, MAX_NODES * sizeof(int));
|
|
|
|
|
2007-05-17 05:10:55 +00:00
|
|
|
if (!t)
|
|
|
|
return;
|
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
while (*t == 'N') {
|
|
|
|
t++;
|
|
|
|
node = strtoul(t, &t, 10);
|
|
|
|
if (*t == '=') {
|
|
|
|
t++;
|
|
|
|
nr = strtoul(t, &t, 10);
|
|
|
|
numa[node] = nr;
|
|
|
|
if (node > highest_node)
|
|
|
|
highest_node = node;
|
|
|
|
}
|
|
|
|
while (*t == ' ')
|
|
|
|
t++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slab_validate(struct slabinfo *s)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2007-05-18 07:36:43 +00:00
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
set_obj(s, "validate", 1);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slab_shrink(struct slabinfo *s)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2007-05-18 07:36:43 +00:00
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
set_obj(s, "shrink", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int line = 0;
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void first_line(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2008-02-08 01:47:41 +00:00
|
|
|
if (show_activity)
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Name Objects Alloc Free"
|
|
|
|
" %%Fast Fallb O CmpX UL\n");
|
2008-02-08 01:47:41 +00:00
|
|
|
else
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Name Objects Objsize %s "
|
2015-11-06 02:45:22 +00:00
|
|
|
"Slabs/Part/Cpu O/S O %%Fr %%Ef Flg\n",
|
2015-11-06 02:45:31 +00:00
|
|
|
sort_loss ? " Loss" : "Space");
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the shortest alias of a slab
|
|
|
|
*/
|
2009-09-22 23:43:42 +00:00
|
|
|
static struct aliasinfo *find_one_alias(struct slabinfo *find)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct aliasinfo *a;
|
|
|
|
struct aliasinfo *best = NULL;
|
|
|
|
|
|
|
|
for(a = aliasinfo;a < aliasinfo + aliases; a++) {
|
|
|
|
if (a->slab == find &&
|
|
|
|
(!best || strlen(best->name) < strlen(a->name))) {
|
|
|
|
best = a;
|
|
|
|
if (strncmp(a->name,"kmall", 5) == 0)
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
}
|
2007-05-09 09:32:37 +00:00
|
|
|
return best;
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long slab_size(struct slabinfo *s)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
return s->slabs * (page_size << s->order);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static unsigned long slab_activity(struct slabinfo *s)
|
2008-02-08 01:47:41 +00:00
|
|
|
{
|
|
|
|
return s->alloc_fastpath + s->free_fastpath +
|
|
|
|
s->alloc_slowpath + s->free_slowpath;
|
|
|
|
}
|
|
|
|
|
2015-11-06 02:45:22 +00:00
|
|
|
static unsigned long slab_waste(struct slabinfo *s)
|
|
|
|
{
|
|
|
|
return slab_size(s) - s->objects * s->object_size;
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slab_numa(struct slabinfo *s, int mode)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
int node;
|
|
|
|
|
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!highest_node) {
|
|
|
|
printf("\n%s: No NUMA information available.\n", s->name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skip_zero && !s->slabs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!line) {
|
|
|
|
printf("\n%-21s:", mode ? "NUMA nodes" : "Slab");
|
|
|
|
for(node = 0; node <= highest_node; node++)
|
|
|
|
printf(" %4d", node);
|
|
|
|
printf("\n----------------------");
|
|
|
|
for(node = 0; node <= highest_node; node++)
|
|
|
|
printf("-----");
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("%-21s ", mode ? "All slabs" : s->name);
|
|
|
|
for(node = 0; node <= highest_node; node++) {
|
|
|
|
char b[20];
|
|
|
|
|
|
|
|
store_size(b, s->numa[node]);
|
|
|
|
printf(" %4s", b);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
if (mode) {
|
|
|
|
printf("%-21s ", "Partial slabs");
|
|
|
|
for(node = 0; node <= highest_node; node++) {
|
|
|
|
char b[20];
|
|
|
|
|
|
|
|
store_size(b, s->numa_partial[node]);
|
|
|
|
printf(" %4s", b);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
line++;
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void show_tracking(struct slabinfo *s)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
printf("\n%s: Kernel object allocation\n", s->name);
|
|
|
|
printf("-----------------------------------------------------------------------\n");
|
2022-06-23 21:45:52 +00:00
|
|
|
if (read_debug_slab_obj(s, "alloc_traces"))
|
|
|
|
printf("%s", buffer);
|
|
|
|
else if (read_slab_obj(s, "alloc_calls"))
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("%s", buffer);
|
2007-05-09 09:32:37 +00:00
|
|
|
else
|
|
|
|
printf("No Data\n");
|
|
|
|
|
|
|
|
printf("\n%s: Kernel object freeing\n", s->name);
|
|
|
|
printf("------------------------------------------------------------------------\n");
|
2022-06-23 21:45:52 +00:00
|
|
|
if (read_debug_slab_obj(s, "free_traces"))
|
|
|
|
printf("%s", buffer);
|
|
|
|
else if (read_slab_obj(s, "free_calls"))
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("%s", buffer);
|
2007-05-09 09:32:37 +00:00
|
|
|
else
|
|
|
|
printf("No Data\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void ops(struct slabinfo *s)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (read_slab_obj(s, "ops")) {
|
|
|
|
printf("\n%s: kmem_cache operations\n", s->name);
|
|
|
|
printf("--------------------------------------------\n");
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("%s", buffer);
|
2007-05-09 09:32:37 +00:00
|
|
|
} else
|
|
|
|
printf("\n%s has no kmem_cache operations\n", s->name);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static const char *onoff(int x)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
return "On ";
|
|
|
|
return "Off";
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slab_stats(struct slabinfo *s)
|
2008-02-08 01:47:41 +00:00
|
|
|
{
|
|
|
|
unsigned long total_alloc;
|
|
|
|
unsigned long total_free;
|
|
|
|
unsigned long total;
|
|
|
|
|
|
|
|
if (!s->alloc_slab)
|
|
|
|
return;
|
|
|
|
|
|
|
|
total_alloc = s->alloc_fastpath + s->alloc_slowpath;
|
|
|
|
total_free = s->free_fastpath + s->free_slowpath;
|
|
|
|
|
|
|
|
if (!total_alloc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
printf("Slab Perf Counter Alloc Free %%Al %%Fr\n");
|
|
|
|
printf("--------------------------------------------------\n");
|
|
|
|
printf("Fastpath %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->alloc_fastpath, s->free_fastpath,
|
|
|
|
s->alloc_fastpath * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_fastpath * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
printf("Slowpath %8lu %8lu %3lu %3lu\n",
|
|
|
|
total_alloc - s->alloc_fastpath, s->free_slowpath,
|
|
|
|
(total_alloc - s->alloc_fastpath) * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_slowpath * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
printf("Page Alloc %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->alloc_slab, s->free_slab,
|
|
|
|
s->alloc_slab * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_slab * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
printf("Add partial %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->deactivate_to_head + s->deactivate_to_tail,
|
|
|
|
s->free_add_partial,
|
|
|
|
(s->deactivate_to_head + s->deactivate_to_tail) * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_add_partial * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
printf("Remove partial %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->alloc_from_partial, s->free_remove_partial,
|
|
|
|
s->alloc_from_partial * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_remove_partial * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
|
2011-08-09 21:12:28 +00:00
|
|
|
printf("Cpu partial list %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->cpu_partial_alloc, s->cpu_partial_free,
|
|
|
|
s->cpu_partial_alloc * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->cpu_partial_free * 100 / total_free : 0);
|
2011-08-09 21:12:28 +00:00
|
|
|
|
2008-02-08 01:47:41 +00:00
|
|
|
printf("RemoteObj/SlabFrozen %8lu %8lu %3lu %3lu\n",
|
|
|
|
s->deactivate_remote_frees, s->free_frozen,
|
|
|
|
s->deactivate_remote_frees * 100 / total_alloc,
|
2012-06-26 01:30:31 +00:00
|
|
|
total_free ? s->free_frozen * 100 / total_free : 0);
|
2008-02-08 01:47:41 +00:00
|
|
|
|
|
|
|
printf("Total %8lu %8lu\n\n", total_alloc, total_free);
|
|
|
|
|
|
|
|
if (s->cpuslab_flush)
|
|
|
|
printf("Flushes %8lu\n", s->cpuslab_flush);
|
|
|
|
|
|
|
|
total = s->deactivate_full + s->deactivate_empty +
|
2011-06-01 17:26:00 +00:00
|
|
|
s->deactivate_to_head + s->deactivate_to_tail + s->deactivate_bypass;
|
|
|
|
|
|
|
|
if (total) {
|
2016-06-24 21:50:21 +00:00
|
|
|
printf("\nSlab Deactivation Occurrences %%\n");
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("-------------------------------------------------\n");
|
|
|
|
printf("Slab full %7lu %3lu%%\n",
|
|
|
|
s->deactivate_full, (s->deactivate_full * 100) / total);
|
|
|
|
printf("Slab empty %7lu %3lu%%\n",
|
|
|
|
s->deactivate_empty, (s->deactivate_empty * 100) / total);
|
|
|
|
printf("Moved to head of partial list %7lu %3lu%%\n",
|
|
|
|
s->deactivate_to_head, (s->deactivate_to_head * 100) / total);
|
|
|
|
printf("Moved to tail of partial list %7lu %3lu%%\n",
|
2008-02-08 01:47:41 +00:00
|
|
|
s->deactivate_to_tail, (s->deactivate_to_tail * 100) / total);
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("Deactivation bypass %7lu %3lu%%\n",
|
|
|
|
s->deactivate_bypass, (s->deactivate_bypass * 100) / total);
|
|
|
|
printf("Refilled from foreign frees %7lu %3lu%%\n",
|
|
|
|
s->alloc_refill, (s->alloc_refill * 100) / total);
|
|
|
|
printf("Node mismatch %7lu %3lu%%\n",
|
|
|
|
s->alloc_node_mismatch, (s->alloc_node_mismatch * 100) / total);
|
|
|
|
}
|
|
|
|
|
2016-07-20 22:45:05 +00:00
|
|
|
if (s->cmpxchg_double_fail || s->cmpxchg_double_cpu_fail) {
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("\nCmpxchg_double Looping\n------------------------\n");
|
|
|
|
printf("Locked Cmpxchg Double redos %lu\nUnlocked Cmpxchg Double redos %lu\n",
|
|
|
|
s->cmpxchg_double_fail, s->cmpxchg_double_cpu_fail);
|
2016-07-20 22:45:05 +00:00
|
|
|
}
|
2008-02-08 01:47:41 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void report(struct slabinfo *s)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
2007-05-17 05:10:55 +00:00
|
|
|
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("\nSlabcache: %-15s Aliases: %2d Order : %2d Objects: %lu\n",
|
2007-05-17 05:10:55 +00:00
|
|
|
s->name, s->aliases, s->order, s->objects);
|
2007-05-09 09:32:37 +00:00
|
|
|
if (s->hwcache_align)
|
|
|
|
printf("** Hardware cacheline aligned\n");
|
|
|
|
if (s->cache_dma)
|
|
|
|
printf("** Memory is allocated in a special DMA zone\n");
|
|
|
|
if (s->destroy_by_rcu)
|
|
|
|
printf("** Slabs are destroyed via RCU\n");
|
|
|
|
if (s->reclaim_account)
|
|
|
|
printf("** Reclaim accounting active\n");
|
|
|
|
|
|
|
|
printf("\nSizes (bytes) Slabs Debug Memory\n");
|
|
|
|
printf("------------------------------------------------------------------------\n");
|
|
|
|
printf("Object : %7d Total : %7ld Sanity Checks : %s Total: %7ld\n",
|
|
|
|
s->object_size, s->slabs, onoff(s->sanity_checks),
|
|
|
|
s->slabs * (page_size << s->order));
|
|
|
|
printf("SlabObj: %7d Full : %7ld Redzoning : %s Used : %7ld\n",
|
|
|
|
s->slab_size, s->slabs - s->partial - s->cpu_slabs,
|
|
|
|
onoff(s->red_zone), s->objects * s->object_size);
|
|
|
|
printf("SlabSiz: %7d Partial: %7ld Poisoning : %s Loss : %7ld\n",
|
|
|
|
page_size << s->order, s->partial, onoff(s->poison),
|
|
|
|
s->slabs * (page_size << s->order) - s->objects * s->object_size);
|
|
|
|
printf("Loss : %7d CpuSlab: %7d Tracking : %s Lalig: %7ld\n",
|
|
|
|
s->slab_size - s->object_size, s->cpu_slabs, onoff(s->store_user),
|
|
|
|
(s->slab_size - s->object_size) * s->objects);
|
|
|
|
printf("Align : %7d Objects: %7d Tracing : %s Lpadd: %7ld\n",
|
|
|
|
s->align, s->objs_per_slab, onoff(s->trace),
|
|
|
|
((page_size << s->order) - s->objs_per_slab * s->slab_size) *
|
|
|
|
s->slabs);
|
|
|
|
|
|
|
|
ops(s);
|
|
|
|
show_tracking(s);
|
|
|
|
slab_numa(s, 1);
|
2008-02-08 01:47:41 +00:00
|
|
|
slab_stats(s);
|
2007-05-09 09:32:37 +00:00
|
|
|
}
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slabcache(struct slabinfo *s)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
char size_str[20];
|
|
|
|
char dist_str[40];
|
|
|
|
char flags[20];
|
|
|
|
char *p = flags;
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
2017-11-16 01:31:59 +00:00
|
|
|
if (unreclaim_only && s->reclaim_account)
|
|
|
|
return;
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
if (actual_slabs == 1) {
|
|
|
|
report(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skip_zero && !show_empty && !s->slabs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (show_empty && s->slabs)
|
2007-05-06 21:49:48 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-06 02:45:22 +00:00
|
|
|
if (sort_loss == 0)
|
|
|
|
store_size(size_str, slab_size(s));
|
|
|
|
else
|
|
|
|
store_size(size_str, slab_waste(s));
|
2008-04-14 16:11:40 +00:00
|
|
|
snprintf(dist_str, 40, "%lu/%lu/%d", s->slabs - s->cpu_slabs,
|
|
|
|
s->partial, s->cpu_slabs);
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
if (!line++)
|
|
|
|
first_line();
|
|
|
|
|
|
|
|
if (s->aliases)
|
|
|
|
*p++ = '*';
|
|
|
|
if (s->cache_dma)
|
|
|
|
*p++ = 'd';
|
|
|
|
if (s->hwcache_align)
|
|
|
|
*p++ = 'A';
|
|
|
|
if (s->poison)
|
|
|
|
*p++ = 'P';
|
|
|
|
if (s->reclaim_account)
|
|
|
|
*p++ = 'a';
|
|
|
|
if (s->red_zone)
|
|
|
|
*p++ = 'Z';
|
|
|
|
if (s->sanity_checks)
|
|
|
|
*p++ = 'F';
|
|
|
|
if (s->store_user)
|
|
|
|
*p++ = 'U';
|
|
|
|
if (s->trace)
|
|
|
|
*p++ = 'T';
|
|
|
|
|
|
|
|
*p = 0;
|
2008-02-08 01:47:41 +00:00
|
|
|
if (show_activity) {
|
|
|
|
unsigned long total_alloc;
|
|
|
|
unsigned long total_free;
|
|
|
|
|
|
|
|
total_alloc = s->alloc_fastpath + s->alloc_slowpath;
|
|
|
|
total_free = s->free_fastpath + s->free_slowpath;
|
|
|
|
|
2011-06-01 17:26:00 +00:00
|
|
|
printf("%-21s %8ld %10ld %10ld %3ld %3ld %5ld %1d %4ld %4ld\n",
|
2008-02-08 01:47:41 +00:00
|
|
|
s->name, s->objects,
|
|
|
|
total_alloc, total_free,
|
|
|
|
total_alloc ? (s->alloc_fastpath * 100 / total_alloc) : 0,
|
2008-04-29 23:14:46 +00:00
|
|
|
total_free ? (s->free_fastpath * 100 / total_free) : 0,
|
2011-06-01 17:26:00 +00:00
|
|
|
s->order_fallback, s->order, s->cmpxchg_double_fail,
|
|
|
|
s->cmpxchg_double_cpu_fail);
|
2015-11-06 02:45:28 +00:00
|
|
|
} else {
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("%-21s %8ld %7d %15s %14s %4d %1d %3ld %3ld %s\n",
|
2008-02-08 01:47:41 +00:00
|
|
|
s->name, s->objects, s->object_size, size_str, dist_str,
|
|
|
|
s->objs_per_slab, s->order,
|
|
|
|
s->slabs ? (s->partial * 100) / s->slabs : 100,
|
|
|
|
s->slabs ? (s->objects * s->object_size * 100) /
|
|
|
|
(s->slabs * (page_size << s->order)) : 100,
|
|
|
|
flags);
|
2015-11-06 02:45:28 +00:00
|
|
|
}
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
/*
|
|
|
|
* Analyze debug options. Return false if something is amiss.
|
|
|
|
*/
|
2009-09-22 23:43:42 +00:00
|
|
|
static int debug_opt_scan(char *opt)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2007-05-09 09:32:37 +00:00
|
|
|
if (!opt || !opt[0] || strcmp(opt, "-") == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (strcasecmp(opt, "a") == 0) {
|
|
|
|
sanity = 1;
|
|
|
|
poison = 1;
|
|
|
|
redzone = 1;
|
|
|
|
tracking = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
for ( ; *opt; opt++)
|
2010-10-21 18:01:56 +00:00
|
|
|
switch (*opt) {
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'F' : case 'f':
|
|
|
|
if (sanity)
|
|
|
|
return 0;
|
|
|
|
sanity = 1;
|
|
|
|
break;
|
|
|
|
case 'P' : case 'p':
|
|
|
|
if (poison)
|
|
|
|
return 0;
|
|
|
|
poison = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'Z' : case 'z':
|
|
|
|
if (redzone)
|
|
|
|
return 0;
|
|
|
|
redzone = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'U' : case 'u':
|
|
|
|
if (tracking)
|
|
|
|
return 0;
|
|
|
|
tracking = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'T' : case 't':
|
|
|
|
if (tracing)
|
|
|
|
return 0;
|
|
|
|
tracing = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static int slab_empty(struct slabinfo *s)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
2007-05-09 09:32:37 +00:00
|
|
|
if (s->objects > 0)
|
|
|
|
return 0;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
/*
|
|
|
|
* We may still have slabs even if there are no objects. Shrinking will
|
|
|
|
* remove them.
|
|
|
|
*/
|
|
|
|
if (s->slabs != 0)
|
|
|
|
set_obj(s, "shrink", 1);
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void slab_debug(struct slabinfo *s)
|
2007-05-09 09:32:37 +00:00
|
|
|
{
|
2007-05-18 07:36:43 +00:00
|
|
|
if (strcmp(s->name, "*") == 0)
|
|
|
|
return;
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
if (sanity && !s->sanity_checks) {
|
2020-01-31 06:14:17 +00:00
|
|
|
set_obj(s, "sanity_checks", 1);
|
2007-05-09 09:32:37 +00:00
|
|
|
}
|
|
|
|
if (!sanity && s->sanity_checks) {
|
|
|
|
if (slab_empty(s))
|
2020-01-31 06:14:17 +00:00
|
|
|
set_obj(s, "sanity_checks", 0);
|
2007-05-09 09:32:37 +00:00
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot disable sanity checks\n", s->name);
|
|
|
|
}
|
|
|
|
if (redzone && !s->red_zone) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "red_zone", 1);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot enable redzoning\n", s->name);
|
|
|
|
}
|
|
|
|
if (!redzone && s->red_zone) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "red_zone", 0);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot disable redzoning\n", s->name);
|
|
|
|
}
|
|
|
|
if (poison && !s->poison) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "poison", 1);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot enable poisoning\n", s->name);
|
|
|
|
}
|
|
|
|
if (!poison && s->poison) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "poison", 0);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot disable poisoning\n", s->name);
|
|
|
|
}
|
|
|
|
if (tracking && !s->store_user) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "store_user", 1);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot enable tracking\n", s->name);
|
|
|
|
}
|
|
|
|
if (!tracking && s->store_user) {
|
|
|
|
if (slab_empty(s))
|
|
|
|
set_obj(s, "store_user", 0);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s not empty cannot disable tracking\n", s->name);
|
|
|
|
}
|
|
|
|
if (tracing && !s->trace) {
|
|
|
|
if (slabs == 1)
|
|
|
|
set_obj(s, "trace", 1);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
|
|
|
|
}
|
|
|
|
if (!tracing && s->trace)
|
|
|
|
set_obj(s, "trace", 1);
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void totals(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct slabinfo *s;
|
|
|
|
|
|
|
|
int used_slabs = 0;
|
|
|
|
char b1[20], b2[20], b3[20], b4[20];
|
|
|
|
unsigned long long max = 1ULL << 63;
|
|
|
|
|
|
|
|
/* Object size */
|
|
|
|
unsigned long long min_objsize = max, max_objsize = 0, avg_objsize;
|
|
|
|
|
|
|
|
/* Number of partial slabs in a slabcache */
|
|
|
|
unsigned long long min_partial = max, max_partial = 0,
|
|
|
|
avg_partial, total_partial = 0;
|
|
|
|
|
|
|
|
/* Number of slabs in a slab cache */
|
|
|
|
unsigned long long min_slabs = max, max_slabs = 0,
|
|
|
|
avg_slabs, total_slabs = 0;
|
|
|
|
|
|
|
|
/* Size of the whole slab */
|
|
|
|
unsigned long long min_size = max, max_size = 0,
|
|
|
|
avg_size, total_size = 0;
|
|
|
|
|
|
|
|
/* Bytes used for object storage in a slab */
|
|
|
|
unsigned long long min_used = max, max_used = 0,
|
|
|
|
avg_used, total_used = 0;
|
|
|
|
|
|
|
|
/* Waste: Bytes used for alignment and padding */
|
|
|
|
unsigned long long min_waste = max, max_waste = 0,
|
|
|
|
avg_waste, total_waste = 0;
|
|
|
|
/* Number of objects in a slab */
|
|
|
|
unsigned long long min_objects = max, max_objects = 0,
|
|
|
|
avg_objects, total_objects = 0;
|
|
|
|
/* Waste per object */
|
|
|
|
unsigned long long min_objwaste = max,
|
|
|
|
max_objwaste = 0, avg_objwaste,
|
|
|
|
total_objwaste = 0;
|
|
|
|
|
|
|
|
/* Memory per object */
|
|
|
|
unsigned long long min_memobj = max,
|
|
|
|
max_memobj = 0, avg_memobj,
|
|
|
|
total_objsize = 0;
|
|
|
|
|
|
|
|
/* Percentage of partial slabs per slab */
|
|
|
|
unsigned long min_ppart = 100, max_ppart = 0,
|
|
|
|
avg_ppart, total_ppart = 0;
|
|
|
|
|
|
|
|
/* Number of objects in partial slabs */
|
|
|
|
unsigned long min_partobj = max, max_partobj = 0,
|
|
|
|
avg_partobj, total_partobj = 0;
|
|
|
|
|
|
|
|
/* Percentage of partial objects of all objects in a slab */
|
|
|
|
unsigned long min_ppartobj = 100, max_ppartobj = 0,
|
|
|
|
avg_ppartobj, total_ppartobj = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (s = slabinfo; s < slabinfo + slabs; s++) {
|
|
|
|
unsigned long long size;
|
|
|
|
unsigned long used;
|
|
|
|
unsigned long long wasted;
|
|
|
|
unsigned long long objwaste;
|
|
|
|
unsigned long percentage_partial_slabs;
|
|
|
|
unsigned long percentage_partial_objs;
|
|
|
|
|
|
|
|
if (!s->slabs || !s->objects)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
used_slabs++;
|
|
|
|
|
|
|
|
size = slab_size(s);
|
|
|
|
used = s->objects * s->object_size;
|
|
|
|
wasted = size - used;
|
|
|
|
objwaste = s->slab_size - s->object_size;
|
|
|
|
|
|
|
|
percentage_partial_slabs = s->partial * 100 / s->slabs;
|
|
|
|
if (percentage_partial_slabs > 100)
|
|
|
|
percentage_partial_slabs = 100;
|
|
|
|
|
2008-04-14 16:11:40 +00:00
|
|
|
percentage_partial_objs = s->objects_partial * 100
|
2007-05-06 21:49:48 +00:00
|
|
|
/ s->objects;
|
|
|
|
|
|
|
|
if (percentage_partial_objs > 100)
|
|
|
|
percentage_partial_objs = 100;
|
|
|
|
|
|
|
|
if (s->object_size < min_objsize)
|
|
|
|
min_objsize = s->object_size;
|
|
|
|
if (s->partial < min_partial)
|
|
|
|
min_partial = s->partial;
|
|
|
|
if (s->slabs < min_slabs)
|
|
|
|
min_slabs = s->slabs;
|
|
|
|
if (size < min_size)
|
|
|
|
min_size = size;
|
|
|
|
if (wasted < min_waste)
|
|
|
|
min_waste = wasted;
|
|
|
|
if (objwaste < min_objwaste)
|
|
|
|
min_objwaste = objwaste;
|
|
|
|
if (s->objects < min_objects)
|
|
|
|
min_objects = s->objects;
|
|
|
|
if (used < min_used)
|
|
|
|
min_used = used;
|
2008-04-14 16:11:40 +00:00
|
|
|
if (s->objects_partial < min_partobj)
|
|
|
|
min_partobj = s->objects_partial;
|
2007-05-06 21:49:48 +00:00
|
|
|
if (percentage_partial_slabs < min_ppart)
|
|
|
|
min_ppart = percentage_partial_slabs;
|
|
|
|
if (percentage_partial_objs < min_ppartobj)
|
|
|
|
min_ppartobj = percentage_partial_objs;
|
|
|
|
if (s->slab_size < min_memobj)
|
|
|
|
min_memobj = s->slab_size;
|
|
|
|
|
|
|
|
if (s->object_size > max_objsize)
|
|
|
|
max_objsize = s->object_size;
|
|
|
|
if (s->partial > max_partial)
|
|
|
|
max_partial = s->partial;
|
|
|
|
if (s->slabs > max_slabs)
|
|
|
|
max_slabs = s->slabs;
|
|
|
|
if (size > max_size)
|
|
|
|
max_size = size;
|
|
|
|
if (wasted > max_waste)
|
|
|
|
max_waste = wasted;
|
|
|
|
if (objwaste > max_objwaste)
|
|
|
|
max_objwaste = objwaste;
|
|
|
|
if (s->objects > max_objects)
|
|
|
|
max_objects = s->objects;
|
|
|
|
if (used > max_used)
|
|
|
|
max_used = used;
|
2008-04-14 16:11:40 +00:00
|
|
|
if (s->objects_partial > max_partobj)
|
|
|
|
max_partobj = s->objects_partial;
|
2007-05-06 21:49:48 +00:00
|
|
|
if (percentage_partial_slabs > max_ppart)
|
|
|
|
max_ppart = percentage_partial_slabs;
|
|
|
|
if (percentage_partial_objs > max_ppartobj)
|
|
|
|
max_ppartobj = percentage_partial_objs;
|
|
|
|
if (s->slab_size > max_memobj)
|
|
|
|
max_memobj = s->slab_size;
|
|
|
|
|
|
|
|
total_partial += s->partial;
|
|
|
|
total_slabs += s->slabs;
|
|
|
|
total_size += size;
|
|
|
|
total_waste += wasted;
|
|
|
|
|
|
|
|
total_objects += s->objects;
|
|
|
|
total_used += used;
|
2008-04-14 16:11:40 +00:00
|
|
|
total_partobj += s->objects_partial;
|
2007-05-06 21:49:48 +00:00
|
|
|
total_ppart += percentage_partial_slabs;
|
|
|
|
total_ppartobj += percentage_partial_objs;
|
|
|
|
|
|
|
|
total_objwaste += s->objects * objwaste;
|
|
|
|
total_objsize += s->objects * s->slab_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!total_objects) {
|
|
|
|
printf("No objects\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!used_slabs) {
|
|
|
|
printf("No slabs\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Per slab averages */
|
|
|
|
avg_partial = total_partial / used_slabs;
|
|
|
|
avg_slabs = total_slabs / used_slabs;
|
|
|
|
avg_size = total_size / used_slabs;
|
|
|
|
avg_waste = total_waste / used_slabs;
|
|
|
|
|
|
|
|
avg_objects = total_objects / used_slabs;
|
|
|
|
avg_used = total_used / used_slabs;
|
|
|
|
avg_partobj = total_partobj / used_slabs;
|
|
|
|
avg_ppart = total_ppart / used_slabs;
|
|
|
|
avg_ppartobj = total_ppartobj / used_slabs;
|
|
|
|
|
|
|
|
/* Per object object sizes */
|
|
|
|
avg_objsize = total_used / total_objects;
|
|
|
|
avg_objwaste = total_objwaste / total_objects;
|
|
|
|
avg_partobj = total_partobj * 100 / total_objects;
|
|
|
|
avg_memobj = total_objsize / total_objects;
|
|
|
|
|
|
|
|
printf("Slabcache Totals\n");
|
|
|
|
printf("----------------\n");
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Slabcaches : %15d Aliases : %11d->%-3d Active: %3d\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
slabs, aliases, alias_targets, used_slabs);
|
|
|
|
|
|
|
|
store_size(b1, total_size);store_size(b2, total_waste);
|
|
|
|
store_size(b3, total_waste * 100 / total_used);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Memory used: %15s # Loss : %15s MRatio:%6s%%\n", b1, b2, b3);
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
store_size(b1, total_objects);store_size(b2, total_partobj);
|
|
|
|
store_size(b3, total_partobj * 100 / total_objects);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("# Objects : %15s # PartObj: %15s ORatio:%6s%%\n", b1, b2, b3);
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
printf("\n");
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Per Cache Average "
|
|
|
|
"Min Max Total\n");
|
|
|
|
printf("---------------------------------------"
|
|
|
|
"-------------------------------------\n");
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
store_size(b1, avg_objects);store_size(b2, min_objects);
|
|
|
|
store_size(b3, max_objects);store_size(b4, total_objects);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("#Objects %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_slabs);store_size(b2, min_slabs);
|
|
|
|
store_size(b3, max_slabs);store_size(b4, total_slabs);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("#Slabs %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_partial);store_size(b2, min_partial);
|
|
|
|
store_size(b3, max_partial);store_size(b4, total_partial);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("#PartSlab %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
store_size(b1, avg_ppart);store_size(b2, min_ppart);
|
|
|
|
store_size(b3, max_ppart);
|
|
|
|
store_size(b4, total_partial * 100 / total_slabs);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("%%PartSlab%15s%% %15s%% %15s%% %15s%%\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_partobj);store_size(b2, min_partobj);
|
|
|
|
store_size(b3, max_partobj);
|
|
|
|
store_size(b4, total_partobj);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("PartObjs %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_ppartobj);store_size(b2, min_ppartobj);
|
|
|
|
store_size(b3, max_ppartobj);
|
|
|
|
store_size(b4, total_partobj * 100 / total_objects);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("%% PartObj%15s%% %15s%% %15s%% %15s%%\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_size);store_size(b2, min_size);
|
|
|
|
store_size(b3, max_size);store_size(b4, total_size);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Memory %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_used);store_size(b2, min_used);
|
|
|
|
store_size(b3, max_used);store_size(b4, total_used);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Used %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
store_size(b1, avg_waste);store_size(b2, min_waste);
|
|
|
|
store_size(b3, max_waste);store_size(b4, total_waste);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Loss %15s %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3, b4);
|
|
|
|
|
|
|
|
printf("\n");
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Per Object Average "
|
|
|
|
"Min Max\n");
|
|
|
|
printf("---------------------------------------"
|
|
|
|
"--------------------\n");
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
store_size(b1, avg_memobj);store_size(b2, min_memobj);
|
|
|
|
store_size(b3, max_memobj);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Memory %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3);
|
|
|
|
store_size(b1, avg_objsize);store_size(b2, min_objsize);
|
|
|
|
store_size(b3, max_objsize);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("User %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3);
|
|
|
|
|
|
|
|
store_size(b1, avg_objwaste);store_size(b2, min_objwaste);
|
|
|
|
store_size(b3, max_objwaste);
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("Loss %15s %15s %15s\n",
|
2007-05-06 21:49:48 +00:00
|
|
|
b1, b2, b3);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void sort_slabs(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct slabinfo *s1,*s2;
|
|
|
|
|
|
|
|
for (s1 = slabinfo; s1 < slabinfo + slabs; s1++) {
|
|
|
|
for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) {
|
|
|
|
int result;
|
|
|
|
|
2022-05-28 06:31:17 +00:00
|
|
|
if (sort_size) {
|
|
|
|
if (slab_size(s1) == slab_size(s2))
|
|
|
|
result = strcasecmp(s1->name, s2->name);
|
|
|
|
else
|
|
|
|
result = slab_size(s1) < slab_size(s2);
|
|
|
|
} else if (sort_active) {
|
|
|
|
if (slab_activity(s1) == slab_activity(s2))
|
|
|
|
result = strcasecmp(s1->name, s2->name);
|
|
|
|
else
|
|
|
|
result = slab_activity(s1) < slab_activity(s2);
|
|
|
|
} else if (sort_loss) {
|
|
|
|
if (slab_waste(s1) == slab_waste(s2))
|
|
|
|
result = strcasecmp(s1->name, s2->name);
|
|
|
|
else
|
|
|
|
result = slab_waste(s1) < slab_waste(s2);
|
|
|
|
} else if (sort_partial) {
|
|
|
|
if (s1->partial == s2->partial)
|
|
|
|
result = strcasecmp(s1->name, s2->name);
|
|
|
|
else
|
|
|
|
result = s1->partial < s2->partial;
|
|
|
|
} else
|
2007-05-06 21:49:48 +00:00
|
|
|
result = strcasecmp(s1->name, s2->name);
|
|
|
|
|
|
|
|
if (show_inverted)
|
|
|
|
result = -result;
|
|
|
|
|
|
|
|
if (result > 0) {
|
|
|
|
struct slabinfo t;
|
|
|
|
|
|
|
|
memcpy(&t, s1, sizeof(struct slabinfo));
|
|
|
|
memcpy(s1, s2, sizeof(struct slabinfo));
|
|
|
|
memcpy(s2, &t, sizeof(struct slabinfo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void sort_aliases(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct aliasinfo *a1,*a2;
|
|
|
|
|
|
|
|
for (a1 = aliasinfo; a1 < aliasinfo + aliases; a1++) {
|
|
|
|
for (a2 = a1 + 1; a2 < aliasinfo + aliases; a2++) {
|
|
|
|
char *n1, *n2;
|
|
|
|
|
|
|
|
n1 = a1->name;
|
|
|
|
n2 = a2->name;
|
|
|
|
if (show_alias && !show_inverted) {
|
|
|
|
n1 = a1->ref;
|
|
|
|
n2 = a2->ref;
|
|
|
|
}
|
|
|
|
if (strcasecmp(n1, n2) > 0) {
|
|
|
|
struct aliasinfo t;
|
|
|
|
|
|
|
|
memcpy(&t, a1, sizeof(struct aliasinfo));
|
|
|
|
memcpy(a1, a2, sizeof(struct aliasinfo));
|
|
|
|
memcpy(a2, &t, sizeof(struct aliasinfo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void link_slabs(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct aliasinfo *a;
|
|
|
|
struct slabinfo *s;
|
|
|
|
|
|
|
|
for (a = aliasinfo; a < aliasinfo + aliases; a++) {
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
for (s = slabinfo; s < slabinfo + slabs; s++)
|
2007-05-06 21:49:48 +00:00
|
|
|
if (strcmp(a->ref, s->name) == 0) {
|
|
|
|
a->slab = s;
|
|
|
|
s->refs++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (s == slabinfo + slabs)
|
|
|
|
fatal("Unresolved alias %s\n", a->ref);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void alias(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct aliasinfo *a;
|
|
|
|
char *active = NULL;
|
|
|
|
|
|
|
|
sort_aliases();
|
|
|
|
link_slabs();
|
|
|
|
|
|
|
|
for(a = aliasinfo; a < aliasinfo + aliases; a++) {
|
|
|
|
|
|
|
|
if (!show_single_ref && a->slab->refs == 1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!show_inverted) {
|
|
|
|
if (active) {
|
|
|
|
if (strcmp(a->slab->name, active) == 0) {
|
|
|
|
printf(" %s", a->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2007-05-09 09:32:37 +00:00
|
|
|
printf("\n%-12s <- %s", a->slab->name, a->name);
|
2007-05-06 21:49:48 +00:00
|
|
|
active = a->slab->name;
|
|
|
|
}
|
|
|
|
else
|
2015-11-06 02:45:31 +00:00
|
|
|
printf("%-15s -> %s\n", a->name, a->slab->name);
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
if (active)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void rename_slabs(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct slabinfo *s;
|
|
|
|
struct aliasinfo *a;
|
|
|
|
|
|
|
|
for (s = slabinfo; s < slabinfo + slabs; s++) {
|
|
|
|
if (*s->name != ':')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (s->refs > 1 && !show_first_alias)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
a = find_one_alias(s);
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
if (a)
|
|
|
|
s->name = a->name;
|
|
|
|
else {
|
|
|
|
s->name = "*";
|
|
|
|
actual_slabs--;
|
|
|
|
}
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static int slab_mismatch(char *slab)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
return regexec(&pattern, slab, 0, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void read_slab_dir(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
|
|
|
struct slabinfo *slab = slabinfo;
|
|
|
|
struct aliasinfo *alias = aliasinfo;
|
|
|
|
char *p;
|
|
|
|
char *t;
|
|
|
|
int count;
|
|
|
|
|
2008-02-05 07:35:48 +00:00
|
|
|
if (chdir("/sys/kernel/slab") && chdir("/sys/slab"))
|
2007-05-09 09:32:37 +00:00
|
|
|
fatal("SYSFS support for SLUB not active\n");
|
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
dir = opendir(".");
|
|
|
|
while ((de = readdir(dir))) {
|
|
|
|
if (de->d_name[0] == '.' ||
|
2007-05-09 09:32:37 +00:00
|
|
|
(de->d_name[0] != ':' && slab_mismatch(de->d_name)))
|
|
|
|
continue;
|
2007-05-06 21:49:48 +00:00
|
|
|
switch (de->d_type) {
|
|
|
|
case DT_LNK:
|
2010-10-21 18:01:56 +00:00
|
|
|
alias->name = strdup(de->d_name);
|
2011-10-17 14:48:10 +00:00
|
|
|
count = readlink(de->d_name, buffer, sizeof(buffer)-1);
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
if (count < 0)
|
|
|
|
fatal("Cannot read symlink %s\n", de->d_name);
|
|
|
|
|
|
|
|
buffer[count] = 0;
|
|
|
|
p = buffer + count;
|
|
|
|
while (p > buffer && p[-1] != '/')
|
|
|
|
p--;
|
|
|
|
alias->ref = strdup(p);
|
|
|
|
alias++;
|
|
|
|
break;
|
|
|
|
case DT_DIR:
|
|
|
|
if (chdir(de->d_name))
|
|
|
|
fatal("Unable to access slab %s\n", slab->name);
|
2010-10-21 18:01:56 +00:00
|
|
|
slab->name = strdup(de->d_name);
|
2007-05-06 21:49:48 +00:00
|
|
|
slab->alias = 0;
|
|
|
|
slab->refs = 0;
|
|
|
|
slab->aliases = get_obj("aliases");
|
|
|
|
slab->align = get_obj("align");
|
|
|
|
slab->cache_dma = get_obj("cache_dma");
|
|
|
|
slab->cpu_slabs = get_obj("cpu_slabs");
|
|
|
|
slab->destroy_by_rcu = get_obj("destroy_by_rcu");
|
|
|
|
slab->hwcache_align = get_obj("hwcache_align");
|
|
|
|
slab->object_size = get_obj("object_size");
|
|
|
|
slab->objects = get_obj("objects");
|
2008-04-14 16:11:40 +00:00
|
|
|
slab->objects_partial = get_obj("objects_partial");
|
|
|
|
slab->objects_total = get_obj("objects_total");
|
2007-05-06 21:49:48 +00:00
|
|
|
slab->objs_per_slab = get_obj("objs_per_slab");
|
|
|
|
slab->order = get_obj("order");
|
|
|
|
slab->partial = get_obj("partial");
|
|
|
|
slab->partial = get_obj_and_str("partial", &t);
|
|
|
|
decode_numa_list(slab->numa_partial, t);
|
2007-10-17 06:31:29 +00:00
|
|
|
free(t);
|
2007-05-06 21:49:48 +00:00
|
|
|
slab->poison = get_obj("poison");
|
|
|
|
slab->reclaim_account = get_obj("reclaim_account");
|
|
|
|
slab->red_zone = get_obj("red_zone");
|
|
|
|
slab->sanity_checks = get_obj("sanity_checks");
|
|
|
|
slab->slab_size = get_obj("slab_size");
|
|
|
|
slab->slabs = get_obj_and_str("slabs", &t);
|
|
|
|
decode_numa_list(slab->numa, t);
|
2007-10-17 06:31:29 +00:00
|
|
|
free(t);
|
2007-05-06 21:49:48 +00:00
|
|
|
slab->store_user = get_obj("store_user");
|
|
|
|
slab->trace = get_obj("trace");
|
2008-02-08 01:47:41 +00:00
|
|
|
slab->alloc_fastpath = get_obj("alloc_fastpath");
|
|
|
|
slab->alloc_slowpath = get_obj("alloc_slowpath");
|
|
|
|
slab->free_fastpath = get_obj("free_fastpath");
|
|
|
|
slab->free_slowpath = get_obj("free_slowpath");
|
|
|
|
slab->free_frozen= get_obj("free_frozen");
|
|
|
|
slab->free_add_partial = get_obj("free_add_partial");
|
|
|
|
slab->free_remove_partial = get_obj("free_remove_partial");
|
|
|
|
slab->alloc_from_partial = get_obj("alloc_from_partial");
|
|
|
|
slab->alloc_slab = get_obj("alloc_slab");
|
|
|
|
slab->alloc_refill = get_obj("alloc_refill");
|
|
|
|
slab->free_slab = get_obj("free_slab");
|
|
|
|
slab->cpuslab_flush = get_obj("cpuslab_flush");
|
|
|
|
slab->deactivate_full = get_obj("deactivate_full");
|
|
|
|
slab->deactivate_empty = get_obj("deactivate_empty");
|
|
|
|
slab->deactivate_to_head = get_obj("deactivate_to_head");
|
|
|
|
slab->deactivate_to_tail = get_obj("deactivate_to_tail");
|
|
|
|
slab->deactivate_remote_frees = get_obj("deactivate_remote_frees");
|
2008-04-29 23:14:46 +00:00
|
|
|
slab->order_fallback = get_obj("order_fallback");
|
2011-06-01 17:26:00 +00:00
|
|
|
slab->cmpxchg_double_cpu_fail = get_obj("cmpxchg_double_cpu_fail");
|
|
|
|
slab->cmpxchg_double_fail = get_obj("cmpxchg_double_fail");
|
2011-08-09 21:12:28 +00:00
|
|
|
slab->cpu_partial_alloc = get_obj("cpu_partial_alloc");
|
|
|
|
slab->cpu_partial_free = get_obj("cpu_partial_free");
|
2011-06-01 17:26:00 +00:00
|
|
|
slab->alloc_node_mismatch = get_obj("alloc_node_mismatch");
|
|
|
|
slab->deactivate_bypass = get_obj("deactivate_bypass");
|
2007-05-06 21:49:48 +00:00
|
|
|
chdir("..");
|
|
|
|
if (slab->name[0] == ':')
|
|
|
|
alias_targets++;
|
|
|
|
slab++;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
fatal("Unknown file type %lx\n", de->d_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
|
|
|
slabs = slab - slabinfo;
|
2007-05-09 09:32:37 +00:00
|
|
|
actual_slabs = slabs;
|
2007-05-06 21:49:48 +00:00
|
|
|
aliases = alias - aliasinfo;
|
|
|
|
if (slabs > MAX_SLABS)
|
|
|
|
fatal("Too many slabs\n");
|
|
|
|
if (aliases > MAX_ALIASES)
|
|
|
|
fatal("Too many aliases\n");
|
|
|
|
}
|
|
|
|
|
2009-09-22 23:43:42 +00:00
|
|
|
static void output_slabs(void)
|
2007-05-06 21:49:48 +00:00
|
|
|
{
|
|
|
|
struct slabinfo *slab;
|
2015-11-06 02:45:28 +00:00
|
|
|
int lines = output_lines;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
2015-11-06 02:45:20 +00:00
|
|
|
for (slab = slabinfo; (slab < slabinfo + slabs) &&
|
2015-11-06 02:45:28 +00:00
|
|
|
lines != 0; slab++) {
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
if (slab->alias)
|
|
|
|
continue;
|
|
|
|
|
2015-11-06 02:45:28 +00:00
|
|
|
if (lines != -1)
|
|
|
|
lines--;
|
2007-05-06 21:49:48 +00:00
|
|
|
|
|
|
|
if (show_numa)
|
2007-05-09 09:32:37 +00:00
|
|
|
slab_numa(slab, 0);
|
|
|
|
else if (show_track)
|
2007-05-06 21:49:48 +00:00
|
|
|
show_tracking(slab);
|
2007-05-09 09:32:37 +00:00
|
|
|
else if (validate)
|
2007-05-06 21:49:48 +00:00
|
|
|
slab_validate(slab);
|
2007-05-09 09:32:37 +00:00
|
|
|
else if (shrink)
|
2007-05-06 21:49:48 +00:00
|
|
|
slab_shrink(slab);
|
2007-05-09 09:32:37 +00:00
|
|
|
else if (set_debug)
|
|
|
|
slab_debug(slab);
|
|
|
|
else if (show_ops)
|
|
|
|
ops(slab);
|
|
|
|
else if (show_slab)
|
|
|
|
slabcache(slab);
|
2007-05-17 05:10:55 +00:00
|
|
|
else if (show_report)
|
|
|
|
report(slab);
|
2007-05-06 21:49:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 03:59:38 +00:00
|
|
|
static void _xtotals(char *heading, char *underline,
|
|
|
|
int loss, int size, int partial)
|
|
|
|
{
|
|
|
|
printf("%s%s", heading, underline);
|
|
|
|
line = 0;
|
|
|
|
sort_loss = loss;
|
|
|
|
sort_size = size;
|
|
|
|
sort_partial = partial;
|
|
|
|
sort_slabs();
|
|
|
|
output_slabs();
|
|
|
|
}
|
|
|
|
|
2015-11-06 02:45:28 +00:00
|
|
|
static void xtotals(void)
|
|
|
|
{
|
2019-07-12 03:59:38 +00:00
|
|
|
char *heading, *underline;
|
|
|
|
|
2015-11-06 02:45:28 +00:00
|
|
|
totals();
|
|
|
|
|
|
|
|
link_slabs();
|
|
|
|
rename_slabs();
|
|
|
|
|
2019-07-12 03:59:38 +00:00
|
|
|
heading = "\nSlabs sorted by size\n";
|
|
|
|
underline = "--------------------\n";
|
|
|
|
_xtotals(heading, underline, 0, 1, 0);
|
|
|
|
|
|
|
|
heading = "\nSlabs sorted by loss\n";
|
|
|
|
underline = "--------------------\n";
|
|
|
|
_xtotals(heading, underline, 1, 0, 0);
|
|
|
|
|
|
|
|
heading = "\nSlabs sorted by number of partial slabs\n";
|
|
|
|
underline = "---------------------------------------\n";
|
|
|
|
_xtotals(heading, underline, 0, 0, 1);
|
2015-11-06 02:45:28 +00:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2007-05-06 21:49:48 +00:00
|
|
|
struct option opts[] = {
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "aliases", no_argument, NULL, 'a' },
|
|
|
|
{ "activity", no_argument, NULL, 'A' },
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "Bytes", no_argument, NULL, 'B'},
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "debug", optional_argument, NULL, 'd' },
|
|
|
|
{ "display-activity", no_argument, NULL, 'D' },
|
|
|
|
{ "empty", no_argument, NULL, 'e' },
|
|
|
|
{ "first-alias", no_argument, NULL, 'f' },
|
|
|
|
{ "help", no_argument, NULL, 'h' },
|
|
|
|
{ "inverted", no_argument, NULL, 'i'},
|
2015-11-06 02:45:25 +00:00
|
|
|
{ "slabs", no_argument, NULL, 'l' },
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "Loss", no_argument, NULL, 'L'},
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "numa", no_argument, NULL, 'n' },
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "lines", required_argument, NULL, 'N'},
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "ops", no_argument, NULL, 'o' },
|
2019-07-12 03:59:42 +00:00
|
|
|
{ "partial", no_argument, NULL, 'p'},
|
2015-11-06 02:45:25 +00:00
|
|
|
{ "report", no_argument, NULL, 'r' },
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "shrink", no_argument, NULL, 's' },
|
2015-11-06 02:45:25 +00:00
|
|
|
{ "Size", no_argument, NULL, 'S'},
|
|
|
|
{ "tracking", no_argument, NULL, 't'},
|
|
|
|
{ "Totals", no_argument, NULL, 'T'},
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "Unreclaim", no_argument, NULL, 'U'},
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "validate", no_argument, NULL, 'v' },
|
2019-07-12 03:59:34 +00:00
|
|
|
{ "Xtotals", no_argument, NULL, 'X'},
|
tools/vm/slabinfo: use getopt no_argument/optional_argument
This patchset adds 'extended' slabinfo mode that provides additional
information:
-- totals summary
-- slabs sorted by size
-- slabs sorted by loss (waste)
The patches also introduces several new slabinfo options to limit the
number of slabs reported, sort slabs by loss (waste); and some fixes.
Extended output example (slabinfo -X -N 2):
Slabcache Totals
----------------
Slabcaches : 91 Aliases : 119->69 Active: 63
Memory used: 199798784 # Loss : 10689376 MRatio: 5%
# Objects : 324301 # PartObj: 18151 ORatio: 5%
Per Cache Average Min Max Total
----------------------------------------------------------------------------
#Objects 5147 1 89068 324301
#Slabs 199 1 3886 12537
#PartSlab 12 0 240 778
%PartSlab 32% 0% 100% 6%
PartObjs 5 0 4569 18151
% PartObj 26% 0% 100% 5%
Memory 3171409 8192 127336448 199798784
Used 3001736 160 121429728 189109408
Loss 169672 0 5906720 10689376
Per Object Average Min Max
-----------------------------------------------------------
Memory 585 8 8192
User 583 8 8192
Loss 2 0 64
Slabs sorted by size
--------------------
Name Objects Objsize Space Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 127336448 3871/0/15 18 3 0 95 a
dentry 89068 288 26058752 3164/0/17 28 1 0 98 a
Slabs sorted by loss
--------------------
Name Objects Objsize Loss Slabs/Part/Cpu O/S O %Fr %Ef Flg
ext4_inode_cache 69948 1736 5906720 3871/0/15 18 3 0 95 a
inode_cache 11628 864 537472 642/0/4 18 2 0 94 a
The last patch in the series addresses Linus' comment from
http://marc.info/?l=linux-mm&m=144148518703321&w=2
(well, it's been some time. sorry.)
gnuplot script takes the slabinfo records file, where every record is a `slabinfo -X'
output. So the basic workflow is, for example, as follows:
while [ 1 ]; do slabinfo -X -N 2 >> stats; sleep 1; done
^C
slabinfo-gnuplot.sh stats
The last command will produce 3 png files (and 3 stats files)
-- graph of slabinfo totals
-- graph of slabs by size
-- graph of slabs by loss
It's also possible to select a range of records for plotting (a range of collected
slabinfo outputs) via `-r 10,100` (for example); and compare totals from several
measurements (to visially compare slabs behaviour (10,50 range)) using
pre-parsed totals files:
slabinfo-gnuplot.sh -r 10,50 -t stats-totals1 .. stats-totals2
This also, technically, supports ktest. Upload new slabinfo to target,
collect the stats and give the resulting stats file to slabinfo-gnuplot
This patch (of 8):
Use getopt constants in `struct option' ->has_arg instead of numerical
representations.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 02:45:17 +00:00
|
|
|
{ "zero", no_argument, NULL, 'z' },
|
|
|
|
{ "1ref", no_argument, NULL, '1'},
|
2007-05-06 21:49:48 +00:00
|
|
|
{ NULL, 0, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
int err;
|
|
|
|
char *pattern_source;
|
|
|
|
|
|
|
|
page_size = getpagesize();
|
|
|
|
|
2019-07-12 03:59:42 +00:00
|
|
|
while ((c = getopt_long(argc, argv, "aABd::DefhilLnN:oPrsStTUvXz1",
|
2007-05-09 09:32:37 +00:00
|
|
|
opts, NULL)) != -1)
|
2007-10-17 06:31:29 +00:00
|
|
|
switch (c) {
|
2007-05-06 21:49:48 +00:00
|
|
|
case 'a':
|
|
|
|
show_alias = 1;
|
|
|
|
break;
|
2008-02-08 01:47:41 +00:00
|
|
|
case 'A':
|
|
|
|
sort_active = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'B':
|
|
|
|
show_bytes = 1;
|
|
|
|
break;
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'd':
|
|
|
|
set_debug = 1;
|
|
|
|
if (!debug_opt_scan(optarg))
|
|
|
|
fatal("Invalid debug option '%s'\n", optarg);
|
|
|
|
break;
|
2008-02-08 01:47:41 +00:00
|
|
|
case 'D':
|
|
|
|
show_activity = 1;
|
|
|
|
break;
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'e':
|
|
|
|
show_empty = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
case 'f':
|
|
|
|
show_first_alias = 1;
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
case 'i':
|
|
|
|
show_inverted = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'l':
|
|
|
|
show_slab = 1;
|
|
|
|
break;
|
|
|
|
case 'L':
|
|
|
|
sort_loss = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
case 'n':
|
|
|
|
show_numa = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'N':
|
|
|
|
if (optarg) {
|
|
|
|
output_lines = atoi(optarg);
|
|
|
|
if (output_lines < 1)
|
|
|
|
output_lines = 1;
|
|
|
|
}
|
|
|
|
break;
|
2007-05-09 09:32:37 +00:00
|
|
|
case 'o':
|
|
|
|
show_ops = 1;
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
show_report = 1;
|
|
|
|
break;
|
2019-07-12 03:59:42 +00:00
|
|
|
case 'P':
|
|
|
|
sort_partial = 1;
|
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
case 's':
|
|
|
|
shrink = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'S':
|
|
|
|
sort_size = 1;
|
2007-05-06 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
show_track = 1;
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
show_totals = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'U':
|
|
|
|
unreclaim_only = 1;
|
2015-11-06 02:45:20 +00:00
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'v':
|
|
|
|
validate = 1;
|
2015-11-06 02:45:22 +00:00
|
|
|
break;
|
2015-11-06 02:45:28 +00:00
|
|
|
case 'X':
|
|
|
|
if (output_lines == -1)
|
|
|
|
output_lines = 1;
|
|
|
|
extended_totals = 1;
|
2015-11-06 02:45:31 +00:00
|
|
|
show_bytes = 1;
|
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case 'z':
|
|
|
|
skip_zero = 0;
|
2015-11-06 02:45:28 +00:00
|
|
|
break;
|
2019-07-12 03:59:34 +00:00
|
|
|
case '1':
|
|
|
|
show_single_ref = 1;
|
2017-11-16 01:31:59 +00:00
|
|
|
break;
|
2007-05-06 21:49:48 +00:00
|
|
|
default:
|
|
|
|
fatal("%s: Invalid option '%c'\n", argv[0], optopt);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-05-09 09:32:37 +00:00
|
|
|
if (!show_slab && !show_alias && !show_track && !show_report
|
|
|
|
&& !validate && !shrink && !set_debug && !show_ops)
|
2007-05-06 21:49:48 +00:00
|
|
|
show_slab = 1;
|
|
|
|
|
|
|
|
if (argc > optind)
|
|
|
|
pattern_source = argv[optind];
|
|
|
|
else
|
|
|
|
pattern_source = ".*";
|
|
|
|
|
|
|
|
err = regcomp(&pattern, pattern_source, REG_ICASE|REG_NOSUB);
|
|
|
|
if (err)
|
|
|
|
fatal("%s: Invalid pattern '%s' code %d\n",
|
|
|
|
argv[0], pattern_source, err);
|
|
|
|
read_slab_dir();
|
2015-11-06 02:45:28 +00:00
|
|
|
if (show_alias) {
|
2007-05-06 21:49:48 +00:00
|
|
|
alias();
|
2015-11-06 02:45:28 +00:00
|
|
|
} else if (extended_totals) {
|
|
|
|
xtotals();
|
|
|
|
} else if (show_totals) {
|
2007-05-06 21:49:48 +00:00
|
|
|
totals();
|
2015-11-06 02:45:28 +00:00
|
|
|
} else {
|
2007-05-06 21:49:48 +00:00
|
|
|
link_slabs();
|
|
|
|
rename_slabs();
|
|
|
|
sort_slabs();
|
|
|
|
output_slabs();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|