[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 7/9] hvf: use GTree to store memory slots instead of fixed
From: |
Peter Maydell |
Subject: |
Re: [PATCH v3 7/9] hvf: use GTree to store memory slots instead of fixed-size array |
Date: |
Fri, 18 Mar 2022 12:58:30 +0000 |
On Wed, 2 Mar 2022 at 13:04, Yan-Jie Wang <ubzeme@gmail.com> wrote:
>
> Currently, there are only 32 memory slots in the fixed size array.
> It is not scalable. Instead of using fixed size array, use GTree
> (from glib library) and dynamically-allocated structures to store
> memory slots.
>
> Signed-off-by: Yan-Jie Wang <ubzeme@gmail.com>
> ---
> accel/hvf/hvf-mem.c | 63 +++++++++++++++++++++++----------------------
> 1 file changed, 32 insertions(+), 31 deletions(-)
>
> diff --git a/accel/hvf/hvf-mem.c b/accel/hvf/hvf-mem.c
> index 081029ba98..2f70ceb307 100644
> --- a/accel/hvf/hvf-mem.c
> +++ b/accel/hvf/hvf-mem.c
> @@ -28,8 +28,6 @@
>
> /* Memory slots */
>
> -#define HVF_NUM_SLOTS 32
> -
> /* HVFSlot flags */
> #define HVF_SLOT_LOG (1 << 0)
> #define HVF_SLOT_READONLY (1 << 1)
> @@ -42,35 +40,24 @@ typedef struct HVFSlot {
> MemoryRegion *region;
> } HVFSlot;
>
> -static HVFSlot memslots[HVF_NUM_SLOTS];
> +static GTree *memslots;
> static QemuMutex memlock;
>
> static HVFSlot *hvf_find_overlap_slot(hwaddr start, hwaddr size)
> {
> - HVFSlot *slot;
> - int x;
> - for (x = 0; x < HVF_NUM_SLOTS; ++x) {
> - slot = &memslots[x];
> - if (slot->size && start < (slot->start + slot->size) &&
> - (start + size) > slot->start) {
> - return slot;
> - }
> - }
> - return NULL;
> + HVFSlot key = {.start = start, .size = 1};
Doesn't using a size of 1 mean that this function no longer
finds an overlapping slot which starts somewhere above
our 'start' address ?
> + return g_tree_lookup(memslots, &key);
> }
>
-- PMM
- [PATCH v3 0/9] Many improvements to HVF memory-related codes, Yan-Jie Wang, 2022/03/02
- [PATCH v3 1/9] hvf: move memory related functions from hvf-accel-ops.c to hvf-mem.c, Yan-Jie Wang, 2022/03/02
- [PATCH v3 2/9] hvf: simplify data structures and codes of memory related functions, Yan-Jie Wang, 2022/03/02
- [PATCH v3 3/9] hvf: use correct data types for addresses in memory related functions, Yan-Jie Wang, 2022/03/02
- [PATCH v3 6/9] hvf: add a lock for memory related functions, Yan-Jie Wang, 2022/03/02
- [PATCH v3 7/9] hvf: use GTree to store memory slots instead of fixed-size array, Yan-Jie Wang, 2022/03/02
- Re: [PATCH v3 7/9] hvf: use GTree to store memory slots instead of fixed-size array,
Peter Maydell <=
- [PATCH v3 5/9] hvf: fix memory dirty-tracking, Yan-Jie Wang, 2022/03/02
- [PATCH v3 9/9] hvf: remove the need to lookup memory slots when clearing dirty-bits, Yan-Jie Wang, 2022/03/02
- [PATCH v3 4/9] hvf: rename struct hvf_slot to HVFSlot, Yan-Jie Wang, 2022/03/02
- [PATCH v3 8/9] hvf: only consider directly writeable memory regions for dirty-tracking, Yan-Jie Wang, 2022/03/02