On Mon, 27 Jul 2020 at 18:46, Philippe Mathieu-Daudé <f4...@amsat.org> wrote: > > When different regions have the same address, we currently > sort them by the priority. Also sort them by the region > size. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> > --- > softmmu/memory.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/softmmu/memory.c b/softmmu/memory.c > index af25987518..c28dcaf4d6 100644 > --- a/softmmu/memory.c > +++ b/softmmu/memory.c > @@ -2960,7 +2960,8 @@ static void mtree_print_mr(const MemoryRegion *mr, > unsigned int level, > QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { > if (new_ml->mr->addr < ml->mr->addr || > (new_ml->mr->addr == ml->mr->addr && > - new_ml->mr->priority > ml->mr->priority)) { > + (MR_SIZE(new_ml->mr->size) > MR_SIZE(ml->mr->size) || > + new_ml->mr->priority > ml->mr->priority))) { > QTAILQ_INSERT_BEFORE(ml, new_ml, mrqueue); > new_ml = NULL; > break;
I think this is the point where you want to factor out the comparison-of-two-MRs function. Which then makes it easier to implement the required logic, which as Peter Xu says should be "address compare first; if those are equal look at the priority; if those are also equal look at the size", ie the usual comparison-with-multiple-fields. thanks -- PMM