[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 2/7] vm: Allow coalescing a VM object with itself
From: |
Samuel Thibault |
Subject: |
Re: [RFC PATCH 2/7] vm: Allow coalescing a VM object with itself |
Date: |
Mon, 3 Jul 2023 02:08:44 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Sergey Bugaev, le lun. 26 juin 2023 14:26:51 +0300, a ecrit:
> If a mapping of an object is made right next to another mapping of the
> same object have the same properties (protection, inheritance, etc.),
> Mach will now expand the previous VM map entry to cover the new address
> range instead of creating a new entry.
> ---
> vm/vm_map.c | 12 ++++++------
> vm/vm_object.c | 22 +++++++++++++++++-----
> 2 files changed, 23 insertions(+), 11 deletions(-)
>
> diff --git a/vm/vm_map.c b/vm/vm_map.c
> index 186589a4..a41e6434 100644
> --- a/vm/vm_map.c
> +++ b/vm/vm_map.c
> @@ -1073,8 +1073,7 @@ kern_return_t vm_map_enter(
> * extend from below.]
> */
>
> - if ((object == VM_OBJECT_NULL) &&
> - (entry != vm_map_to_entry(map)) &&
> + if ((entry != vm_map_to_entry(map)) &&
> (entry->vme_end == start) &&
> (!entry->is_shared) &&
> (!entry->is_sub_map) &&
> @@ -1084,20 +1083,21 @@ kern_return_t vm_map_enter(
> (entry->wired_count == 0) &&
> (entry->projected_on == 0)) {
> if (vm_object_coalesce(entry->object.vm_object,
> - VM_OBJECT_NULL,
> + object,
> entry->offset,
> - (vm_offset_t) 0,
> + offset,
> (vm_size_t)(entry->vme_end - entry->vme_start),
> - (vm_size_t)(end - entry->vme_end))) {
> + size)) {
>
> /*
> * Coalesced the two objects - can extend
> * the previous map entry to include the
> * new range.
> */
> - map->size += (end - entry->vme_end);
> + map->size += size;
> entry->vme_end = end;
> vm_map_gap_update(&map->hdr, entry);
> + vm_object_deallocate(object);
> RETURN(KERN_SUCCESS);
> }
> }
> diff --git a/vm/vm_object.c b/vm/vm_object.c
> index b5be3f81..b00e90d2 100644
> --- a/vm/vm_object.c
> +++ b/vm/vm_object.c
> @@ -2693,7 +2693,8 @@ void vm_object_page_remove(
> * returns TRUE if objects were combined.
> *
> * NOTE: Only works at the moment if the second object is NULL -
> - * if it's not, which object do we lock first?
> + * or if the objects are the same - otherwise, which
> + * object do we lock first?
> *
> * Parameters:
> * prev_object First object to coalesce
> @@ -2718,12 +2719,23 @@ boolean_t vm_object_coalesce(
> {
> vm_size_t newsize;
>
> - if (next_object != VM_OBJECT_NULL) {
> - return FALSE;
> + if (prev_object == next_object) {
> + /*
> + * If neither object actually exists,
> + * the offsets don't matter.
> + */
> + if (prev_object == VM_OBJECT_NULL)
> + return TRUE;
> +
> + return prev_offset + prev_size == next_offset;
> }
>
> - if (prev_object == VM_OBJECT_NULL) {
> - return TRUE;
> + if (next_object != VM_OBJECT_NULL) {
> + /*
> + * Don't know how to merge two different
> + * objects yet.
> + */
> + return FALSE;
> }
>
> vm_object_lock(prev_object);
> --
> 2.41.0
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [RFC PATCH 2/7] vm: Allow coalescing a VM object with itself,
Samuel Thibault <=