Allow to specify shmem size in script.
Change-Id: Icd2b7db1780a81f8760759dd759bc4531e018b6b
diff --git a/tools/heap_profile b/tools/heap_profile
index 0e29f86..942c807 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -88,6 +88,7 @@
heapprofd_config {{
all: {all}
+ shmem_size_bytes: {shmem_size}
sampling_interval_bytes: {interval}
{target_cfg}
{continuous_dump_cfg}
@@ -136,6 +137,10 @@
parser.add_argument("--disable-selinux", action="store_true",
help="Disable SELinux enforcement for duration of "
"profile")
+ parser.add_argument("--shmem-size", help="Size of buffer between client and "
+ "heapprofd. Default 8MiB. Needs to be a power of two "
+ "multiple of 4096, at least 8192.", type=int,
+ default=8 * 1048576)
args = parser.parse_args()
@@ -149,6 +154,15 @@
if args.interval is None:
print("FATAL: No interval given.", file=sys.stderr)
fail = True
+ if args.shmem_size % 4096:
+ print("FATAL: shmem-size is not a multiple of 4096.", file=sys.stderr)
+ fail = True
+ if args.shmem_size < 8192:
+ print("FATAL: shmem-size is less than 8192.", file=sys.stderr)
+ fail = True
+ if args.shmem_size & (args.shmem_size - 1):
+ print("FATAL: shmem-size is not a power of two.", file=sys.stderr)
+ fail = True
if fail:
parser.print_help()
return 1
@@ -179,7 +193,8 @@
dump_interval=args.continuous_dump)
cfg = CFG.format(all=str(args.all == True).lower(), interval=args.interval,
duration=args.duration, target_cfg=target_cfg,
- continuous_dump_cfg=continuous_dump_cfg)
+ continuous_dump_cfg=continuous_dump_cfg,
+ shmem_size=args.shmem_size)
if args.disable_selinux:
enforcing = subprocess.check_output(['adb', 'shell', 'getenforce'])