From 74250405e042ecf0f11adc42f00968b39d93fe3e Mon Sep 17 00:00:00 2001 From: Maksym Planeta Date: Mon, 8 Oct 2012 16:31:41 +0200 Subject: Add RPC that supplies user with general information regarding memory advice. Current implementation of vm_get_advice_info returns only maximal possible size of cluster to be asked. This information is used by default pager, because it can't rely on allocating of memory during processing requests from kernel. That's why default pager allocates buffers, where it stores data to be returned to kernel, beforehand for each thread. So, information provided by vm_get_advice_info tells the default pager size of this buffer. * include/mach/mach.defs (vm_get_advice_info): New ipc definition. * vm/vm_user.c (vm_get_advice_info): New function. --- include/mach/mach.defs | 4 +++- vm/vm_user.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/mach/mach.defs b/include/mach/mach.defs index c5ffbc05..8e49d819 100644 --- a/include/mach/mach.defs +++ b/include/mach/mach.defs @@ -713,7 +713,9 @@ routine vm_machine_attribute( attribute : vm_machine_attribute_t; inout value : vm_machine_attribute_val_t); -skip; /* old host_fpa_counters_reset */ +routine vm_get_advice_info( + target_task : vm_task_t; + out max_cluster : vm_size_t); /* * There is no more room in this interface for additional calls. diff --git a/vm/vm_user.c b/vm/vm_user.c index c5530a69..1385b127 100644 --- a/vm/vm_user.c +++ b/vm/vm_user.c @@ -239,6 +239,21 @@ kern_return_t vm_machine_attribute(map, address, size, attribute, value) return vm_map_machine_attribute(map, address, size, attribute, value); } +/* + * Return machine-specific attribute for memory advice, such + * as maximal size of requested cluster. + */ +kern_return_t +vm_get_advice_info(vm_map_t map, vm_size_t* max_cluster /* OUT */) +{ + if (map == VM_MAP_NULL) + return(KERN_INVALID_ARGUMENT); + + *max_cluster = VM_ADVICE_MAX_READAHEAD * PAGE_SIZE; + + return KERN_SUCCESS; +} + kern_return_t vm_read(map, address, size, data, data_size) vm_map_t map; vm_address_t address; -- cgit v1.2.3