Skip to content

Commit

Permalink
libbpf-tools/memleak: Fixes off-by-one error for -Z and -z option (
Browse files Browse the repository at this point in the history
…iovisor#5149)

These are the description of each options written in memleak tool
(libbpf-tools and tools directory):
  -z option: capture only allocations larger than this size
  -Z option: capture only allocations smaller than this size

But actually they work like this
  -z option: capture only allocations larger than or equal to this size
  -Z option: capture only allocations smaller than or equal to this size

Which means, there was off-by-one errors. So, fixes the explanation message.
  • Loading branch information
Bojun-Seo authored Dec 1, 2024
1 parent 8d85dcf commit 9e390e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libbpf-tools/memleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ static const struct argp_option argp_options[] = {
{"wa-missing-free", 'F', 0, 0, "workaround to alleviate misjudgments when free is missing", 0 },
{"sample-rate", 's', "SAMPLE_RATE", 0, "sample every N-th allocation to decrease the overhead", 0 },
{"top", 'T', "TOP_STACKS", 0, "display only this many top allocating stacks (by size)", 0 },
{"min-size", 'z', "MIN_SIZE", 0, "capture only allocations larger than this size", 0 },
{"max-size", 'Z', "MAX_SIZE", 0, "capture only allocations smaller than this size", 0 },
{"min-size", 'z', "MIN_SIZE", 0, "capture only allocations larger than or equal to this size", 0 },
{"max-size", 'Z', "MAX_SIZE", 0, "capture only allocations smaller than or equal to this size", 0 },
{"obj", 'O', "OBJECT", 0, "attach to allocator functions in the specified object", 0 },
{"percpu", 'P', NULL, 0, "trace percpu allocations", 0 },
{"symbols-prefix", 'S', "SYMBOLS_PREFIX", 0, "memory allocator symbols prefix", 0 },
Expand Down
4 changes: 2 additions & 2 deletions tools/memleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def run_command_get_pid(command):
parser.add_argument("-T", "--top", type=int, default=10,
help="display only this many top allocating stacks (by size)")
parser.add_argument("-z", "--min-size", type=int,
help="capture only allocations larger than this size")
help="capture only allocations larger than or equal to this size")
parser.add_argument("-Z", "--max-size", type=int,
help="capture only allocations smaller than this size")
help="capture only allocations smaller than or equal to this size")
parser.add_argument("-O", "--obj", type=str, default="c",
help="attach to allocator functions in the specified object")
parser.add_argument("--ebpf", action="store_true",
Expand Down
4 changes: 2 additions & 2 deletions tools/memleak_example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ optional arguments:
sample every N-th allocation to decrease the overhead
-T TOP, --top TOP display only this many top allocating stacks (by size)
-z MIN_SIZE, --min-size MIN_SIZE
capture only allocations larger than this size
capture only allocations larger than or equal to this size
-Z MAX_SIZE, --max-size MAX_SIZE
capture only allocations smaller than this size
capture only allocations smaller than or equal to this size
-O OBJ, --obj OBJ attach to allocator functions in the specified object
--sort KEY report sorted in given key; available key list: size,
count
Expand Down

0 comments on commit 9e390e9

Please sign in to comment.