require_ip_active(port);
assert(IKOT_TASK == ip_kotype(port));
- task = (task_t) port->ip_kobject;
+ task = (task_t) ip_get_kobject(port);
assert(task_is_a_corpse(task));
pmap_set_process(task->map->pmap, pid, procname);
#endif /* MACH_ASSERT */
- vm_map_remove(task->map,
- task->map->min_offset,
- task->map->max_offset,
- /*
- * Final cleanup:
- * + no unnesting
- * + remove immutable mappings
- * + allow gaps in range
- */
- (VM_MAP_REMOVE_NO_UNNESTING |
- VM_MAP_REMOVE_IMMUTABLE |
- VM_MAP_REMOVE_GAPS_OK));
+ vm_map_terminate(task->map);
/* release our shared region */
vm_shared_region_set(task, NULL);
task_unlock(task);
if (VM_CONFIG_COMPRESSOR_IS_PRESENT &&
+ (kr == KERN_SUCCESS) &&
(eval_only == FALSE)) {
vm_wake_compactor_swapper();
/*
int64_t io_delta = 0;
int64_t * global_counter_to_update;
boolean_t needs_telemetry = FALSE;
+ boolean_t is_external_device = FALSE;
int ledger_to_update = 0;
struct task_writes_counters * writes_counters_to_update;
global_counter_to_update = &global_logical_writes_count;
ledger_to_update = task_ledgers.logical_writes;
writes_counters_to_update = &task->task_writes_counters_internal;
+ is_external_device = FALSE;
} else {
global_counter_to_update = &global_logical_writes_to_external_count;
ledger_to_update = task_ledgers.logical_writes_to_external;
writes_counters_to_update = &task->task_writes_counters_external;
+ is_external_device = TRUE;
}
switch (flags) {
case TASK_WRITE_IMMEDIATE:
OSAddAtomic64(io_size, (SInt64 *)&(writes_counters_to_update->task_immediate_writes));
ledger_credit(task->ledger, ledger_to_update, io_size);
- coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ if (!is_external_device) {
+ coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ }
break;
case TASK_WRITE_DEFERRED:
OSAddAtomic64(io_size, (SInt64 *)&(writes_counters_to_update->task_deferred_writes));
ledger_credit(task->ledger, ledger_to_update, io_size);
- coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ if (!is_external_device) {
+ coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ }
break;
case TASK_WRITE_INVALIDATED:
OSAddAtomic64(io_size, (SInt64 *)&(writes_counters_to_update->task_invalidated_writes));
ledger_debit(task->ledger, ledger_to_update, io_size);
- coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, FALSE, io_size);
+ if (!is_external_device) {
+ coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, FALSE, io_size);
+ }
break;
case TASK_WRITE_METADATA:
OSAddAtomic64(io_size, (SInt64 *)&(writes_counters_to_update->task_metadata_writes));
ledger_credit(task->ledger, ledger_to_update, io_size);
- coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ if (!is_external_device) {
+ coalition_io_ledger_update(task, FLAVOR_IO_LOGICAL_WRITES, TRUE, io_size);
+ }
break;
}
if (io_telemetry_limit != 0) {
/* If io_telemetry_limit is 0, disable global updates and I/O telemetry */
needs_telemetry = global_update_logical_writes(io_delta, global_counter_to_update);
- if (needs_telemetry) {
+ if (needs_telemetry && !is_external_device) {
act_set_io_telemetry_ast(current_thread());
}
}
task_copy_vmobjects(task_t task, vm_object_query_t query, int len, int64_t* num)
{
vm_object_t find_vmo;
- int64_t size = 0;
+ unsigned int i = 0;
+ unsigned int vmobj_limit = len / sizeof(vm_object_query_data_t);
task_objq_lock(task);
if (query != NULL) {
queue_iterate(&task->task_objq, find_vmo, vm_object_t, task_objq)
{
- int byte_size;
- vm_object_query_t p = &query[size++];
+ vm_object_query_t p = &query[i];
+
+ /*
+ * Clear the entire vm_object_query_t struct as we are using
+ * only the first 6 bits in the uint64_t bitfield for this
+ * anonymous struct member.
+ */
+ bzero(p, sizeof(*p));
p->object_id = (vm_object_id_t) VM_KERNEL_ADDRPERM(find_vmo);
p->virtual_size = find_vmo->internal ? find_vmo->vo_size : 0;
p->compressed_size = 0;
}
- /* make sure to not overrun */
- byte_size = (int) size * sizeof(vm_object_query_data_t);
- if ((int)(byte_size + sizeof(vm_object_query_data_t)) > len) {
+ i++;
+
+ /* Make sure to not overrun */
+ if (i == vmobj_limit) {
break;
}
}
} else {
- size = task->task_owned_objects;
+ i = task->task_owned_objects;
}
task_objq_unlock(task);
- *num = size;
+ *num = i;
}