mcexec: --extend-heap-by: argument to specify heap extension size
This commit is contained in:
@ -129,6 +129,7 @@ struct program_load_desc {
|
||||
unsigned long interp_align;
|
||||
unsigned long mpol_flags;
|
||||
unsigned long mpol_threshold;
|
||||
unsigned long heap_extension;
|
||||
int nr_processes;
|
||||
char shell_path[SHELL_PATH_MAX_LEN];
|
||||
__cpu_set_unit cpu_set[PLD_CPU_SET_SIZE];
|
||||
|
||||
@ -160,6 +160,7 @@ static int mpol_no_stack = 0;
|
||||
static int mpol_no_bss = 0;
|
||||
static int no_bind_ikc_map = 0;
|
||||
static unsigned long mpol_threshold = 0;
|
||||
static unsigned long heap_extension = (2*1024*1024);
|
||||
static int profile = 0;
|
||||
static int disable_sched_yield = 0;
|
||||
|
||||
@ -1116,7 +1117,7 @@ static int reduce_stack(struct rlimit *orig_rlim, char *argv[])
|
||||
|
||||
void print_usage(char **argv)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-c target_core] [-n nr_partitions] [--mpol-threshold=N] [--mpol-no-heap] [--mpol-no-bss] [--mpol-no-stack] [<mcos-id>] (program) [args...]\n", argv[0]);
|
||||
fprintf(stderr, "usage: %s [-c target_core] [-n nr_partitions] [--mpol-threshold=N] [--enable-straight-map] [--extend-heap-by=N] [--mpol-no-heap] [--mpol-no-bss] [--mpol-no-stack] [<mcos-id>] (program) [args...]\n", argv[0]);
|
||||
}
|
||||
|
||||
void init_sigaction(void)
|
||||
@ -1329,6 +1330,12 @@ static struct option mcexec_options[] = {
|
||||
.flag = &disable_sched_yield,
|
||||
.val = 1,
|
||||
},
|
||||
{
|
||||
.name = "extend-heap-by",
|
||||
.has_arg = required_argument,
|
||||
.flag = NULL,
|
||||
.val = 'h',
|
||||
},
|
||||
/* end */
|
||||
{ NULL, 0, NULL, 0, },
|
||||
};
|
||||
@ -1381,7 +1388,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Parse options ("+" denotes stop at the first non-option) */
|
||||
while ((opt = getopt_long(argc, argv, "+c:n:t:m:", mcexec_options, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "+c:n:t:m:h:", mcexec_options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
target_core = atoi(optarg);
|
||||
@ -1399,6 +1406,10 @@ int main(int argc, char **argv)
|
||||
mpol_threshold = atol(optarg);
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
heap_extension = atol(optarg);
|
||||
break;
|
||||
|
||||
case 0: /* long opt */
|
||||
break;
|
||||
|
||||
@ -1788,6 +1799,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
desc->mpol_threshold = mpol_threshold;
|
||||
desc->heap_extension = heap_extension;
|
||||
|
||||
if (ioctl(fd, MCEXEC_UP_PREPARE_IMAGE, (unsigned long)desc) != 0) {
|
||||
perror("prepare");
|
||||
|
||||
@ -209,11 +209,44 @@ int prepare_process_ranges_args_envs(struct thread *thread,
|
||||
pn->at_entry += aout_base;
|
||||
}
|
||||
|
||||
vm->region.brk_start =
|
||||
vm->region.brk_end =
|
||||
vm->region.brk_end_allocated =
|
||||
vm->region.brk_start = vm->region.brk_end =
|
||||
(vm->region.data_end + LARGE_PAGE_SIZE - 1) & LARGE_PAGE_MASK;
|
||||
|
||||
#if 0
|
||||
{
|
||||
void *heap;
|
||||
|
||||
dkprintf("%s: requested heap size: %lu\n",
|
||||
__FUNCTION__, proc->heap_extension);
|
||||
heap = ihk_mc_alloc_aligned_pages(proc->heap_extension >> PAGE_SHIFT,
|
||||
LARGE_PAGE_P2ALIGN, IHK_MC_AP_NOWAIT |
|
||||
(!(proc->mpol_flags & MPOL_NO_HEAP) ? IHK_MC_AP_USER : 0));
|
||||
|
||||
if (!heap) {
|
||||
kprintf("%s: error: allocating heap\n", __FUNCTION__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
flags = VR_PROT_READ | VR_PROT_WRITE;
|
||||
flags |= VRFLAG_PROT_TO_MAXPROT(flags);
|
||||
if (add_process_memory_range(vm, vm->region.brk_start,
|
||||
vm->region.brk_start + proc->heap_extension,
|
||||
virt_to_phys(heap),
|
||||
flags, NULL, 0, LARGE_PAGE_P2ALIGN, NULL) != 0) {
|
||||
ihk_mc_free_pages(heap, proc->heap_extension >> PAGE_SHIFT);
|
||||
kprintf("%s: error: adding memory range for heap\n", __FUNCTION__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
vm->region.brk_end_allocated = vm->region.brk_end +
|
||||
proc->heap_extension;
|
||||
dkprintf("%s: heap @ 0x%lx:%lu\n",
|
||||
__FUNCTION__, vm->region.brk_start, proc->heap_extension);
|
||||
}
|
||||
#else
|
||||
vm->region.brk_end_allocated = vm->region.brk_end;
|
||||
#endif
|
||||
|
||||
/* Map, copy and update args and envs */
|
||||
flags = VR_PROT_READ | VR_PROT_WRITE;
|
||||
flags |= VRFLAG_PROT_TO_MAXPROT(flags);
|
||||
@ -433,6 +466,7 @@ static int process_msg_prepare_process(unsigned long rphys)
|
||||
proc->mpol_flags = pn->mpol_flags;
|
||||
proc->mpol_threshold = pn->mpol_threshold;
|
||||
proc->nr_processes = pn->nr_processes;
|
||||
proc->heap_extension = pn->heap_extension;
|
||||
#ifdef PROFILE_ENABLE
|
||||
proc->profile = pn->profile;
|
||||
thread->profile = pn->profile;
|
||||
|
||||
@ -534,9 +534,10 @@ struct process {
|
||||
|
||||
long maxrss;
|
||||
long maxrss_children;
|
||||
/* Memory policy flags */
|
||||
/* Memory policy flags and memory specific options */
|
||||
unsigned long mpol_flags;
|
||||
size_t mpol_threshold;
|
||||
unsigned long heap_extension;
|
||||
|
||||
// perf_event
|
||||
int perf_status;
|
||||
|
||||
@ -194,6 +194,7 @@ struct program_load_desc {
|
||||
unsigned long interp_align;
|
||||
unsigned long mpol_flags;
|
||||
unsigned long mpol_threshold;
|
||||
unsigned long heap_extension;
|
||||
int nr_processes;
|
||||
char shell_path[SHELL_PATH_MAX_LEN];
|
||||
__cpu_set_unit cpu_set[PLD_CPU_SET_SIZE];
|
||||
|
||||
@ -2067,7 +2067,8 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
void *p;
|
||||
int rc;
|
||||
|
||||
new_end_allocated = (address + (8 * LARGE_PAGE_SIZE) - 1) & LARGE_PAGE_MASK;
|
||||
new_end_allocated = (address + vm->proc->heap_extension +
|
||||
(LARGE_PAGE_SIZE - 1)) & LARGE_PAGE_MASK;
|
||||
|
||||
if (flag & VR_DEMAND_PAGING) {
|
||||
p = 0;
|
||||
@ -2085,7 +2086,7 @@ unsigned long extend_process_region(struct process_vm *vm,
|
||||
|
||||
if ((rc = add_process_memory_range(vm, end_allocated, new_end_allocated,
|
||||
(p == 0 ? 0 : virt_to_phys(p)), flag, NULL, 0,
|
||||
LARGE_PAGE_SHIFT, NULL)) != 0) {
|
||||
LARGE_PAGE_P2ALIGN, NULL)) != 0) {
|
||||
ihk_mc_free_pages(p, (new_end_allocated - end_allocated) >> PAGE_SHIFT);
|
||||
return end_allocated;
|
||||
}
|
||||
|
||||
@ -1802,6 +1802,7 @@ static void munmap_all(void)
|
||||
|
||||
/* free vm_ranges which do_munmap() failed to remove. */
|
||||
free_process_memory_ranges(thread->vm);
|
||||
|
||||
return;
|
||||
} /* munmap_all() */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user