Refine exec
A message that is not in the archive (sent off-list or not yet received): [email protected]
Ping for this trivial series.
Quoted 16 lines · Wei Yang
This serial refine exec a little.
Wei Yang (6):
exec.c: replace hwaddr withuint64_tfor better understandingexec.c: remove an unnecessary assert onPHYS_MAP_NODE_NILin
phys_map_node_alloc()
exec.c: getnodes_nb_allocwith one MAX calculationexec.c:subpage->sub_sectionis already initialized to 0exec.c: correct the maximum skip value during compactexec.c: add a check between constants to see whether we could skip
exec.c| 21 ++++++++++-----------1 file changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.19.1
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 2 lines · Wei Yang
This serial refine exec a little.
Ping again.
Quoted 14 lines
Wei Yang (6):
exec.c: replace hwaddr withuint64_tfor better understandingexec.c: remove an unnecessary assert onPHYS_MAP_NODE_NILin
phys_map_node_alloc()
exec.c: getnodes_nb_allocwith one MAX calculationexec.c:subpage->sub_sectionis already initialized to 0exec.c: correct the maximum skip value during compactexec.c: add a check between constants to see whether we could skip
exec.c| 21 ++++++++++-----------1 file changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.19.1
Signature · 2 lines
Wei Yang Help you, Help me
Paolo Bonzini
AppliedQuoted 5 lines · Wei Yang
Quoted 2 lines · Wei Yang
This serial refine exec a little.
Ping again.
Queued all except 2, thanks!
Paolo
Quoted 15 lines
Quoted 14 lines
Wei Yang (6):
exec.c: replace hwaddr withuint64_tfor better understandingexec.c: remove an unnecessary assert onPHYS_MAP_NODE_NILin
phys_map_node_alloc()
exec.c: getnodes_nb_allocwith one MAX calculationexec.c:subpage->sub_sectionis already initialized to 0exec.c: correct the maximum skip value during compactexec.c: add a check between constants to see whether we could skip
exec.c| 21 ++++++++++-----------1 file changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.19.1
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Wei Yang
Quoted 2 lines · Wei Yang
This serial refine exec a little.
Ping again.
Queued all except 2, thanks!
Thanks~
Quoted 18 lines
Paolo
Quoted 15 lines
Quoted 14 lines
Wei Yang (6):
exec.c: replace hwaddr withuint64_tfor better understandingexec.c: remove an unnecessary assert onPHYS_MAP_NODE_NILin
phys_map_node_alloc()
exec.c: getnodes_nb_allocwith one MAX calculationexec.c:subpage->sub_sectionis already initialized to 0exec.c: correct the maximum skip value during compactexec.c: add a check between constants to see whether we could skip
exec.c| 21 ++++++++++-----------1 file changed, 10 insertions(+), 11 deletions(-)Signature · 1 line
2.19.1
Signature · 2 lines
Wei Yang Help you, Help me
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 4 lines · Wei Yang
PHYS_MAP_NODE_NILis assigned to PhysPageEntry.ptr in case this is not a leaf entry, whilemap->nodes_nbrange in [0,nodes_nb_alloc).Seems we are asserting on two different things, just remove it.
The assertion checks that this "if" is not entered incorrectly:
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) {
lp->ptr = phys_map_node_alloc(map, level == 0);
}Paolo
Quoted 18 lines
Signed-off-by Wei Yang <[email protected]>--- exec.c | 1 - 1 file changed, 1 deletion(-)exec.c +0
-1@@ -242,7 +242,6 @@ static uint32_t phys_map_node_alloc(PhysPageMap *map, bool leaf) ret = map->nodes_nb++; p = map->nodes[ret]; -assert (ret !=PHYS_MAP_NODE_NIL );assert (ret != map->nodes_nb_alloc); e.skip = leaf ?0 :1 ;
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Wei Yang
PHYS_MAP_NODE_NILis assigned to PhysPageEntry.ptr in case this is not a leaf entry, whilemap->nodes_nbrange in [0,nodes_nb_alloc).
Quoted 8 lines
Quoted 1 line
Seems we are asserting on two different things, just remove it.
The assertion checks that this "if" is not entered incorrectly:
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) { lp->ptr = phys_map_node_alloc(map, level == 0); }
Hmm... I may not get your point.
phys_map_node_alloc() will get an available PhysPageEntry and return its index, which will be assigned to its parent's ptr.
The "if" checks on the parent's ptr, while the assertion asserts the index for the new child. I may miss something?
Quoted 20 lines
Paolo
Quoted 18 lines
Signed-off-by Wei Yang <[email protected]>--- exec.c | 1 - 1 file changed, 1 deletion(-)exec.c +0
-1@@ -242,7 +242,6 @@ static uint32_t phys_map_node_alloc(PhysPageMap *map, bool leaf) ret = map->nodes_nb++; p = map->nodes[ret]; -assert (ret !=PHYS_MAP_NODE_NIL );assert (ret != map->nodes_nb_alloc); e.skip = leaf ?0 :1 ;
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 14 lines · Wei Yang
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Wei Yang
PHYS_MAP_NODE_NILis assigned to PhysPageEntry.ptr in case this is not a leaf entry, whilemap->nodes_nbrange in [0,nodes_nb_alloc).Quoted 8 lines
Quoted 1 line
Seems we are asserting on two different things, just remove it.
The assertion checks that this "if" is not entered incorrectly:
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) { lp->ptr = phys_map_node_alloc(map, level == 0); }
Quoted 8 lines
Hmm... I may not get your point.
phys_map_node_alloc()will get an available PhysPageEntry and return its index, which will be assigned to its parent's ptr.The "if" checks on the parent's ptr, while the assertion asserts the index for the new child. I may miss something?
Hi, Paolo,
Do I miss something?
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 20 lines · Wei Yang
Quoted 19 lines · Wei Yang
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Wei Yang
PHYS_MAP_NODE_NILis assigned to PhysPageEntry.ptr in case this is not a leaf entry, whilemap->nodes_nbrange in [0,nodes_nb_alloc).Quoted 8 lines
Quoted 1 line
Seems we are asserting on two different things, just remove it.
The assertion checks that this "if" is not entered incorrectly:
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) { lp->ptr = phys_map_node_alloc(map, level == 0); }Hmm... I may not get your point.
phys_map_node_alloc()will get an available PhysPageEntry and return its index, which will be assigned to its parent's ptr.
Quoted 7 lines
Quoted 3 lines
The "if" checks on the parent's ptr, while the assertion asserts the index for the new child. I may miss something?
Hi, Paolo,
Do I miss something?
Sorry, I was on vacation. phys_page_set_level can be called multiple times, with the same lp. The assertion checks that only the first call will reach phys_map_node_alloc.
Paolo
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 25 lines · Paolo Bonzini
Quoted 24 lines · Wei Yang
Quoted 22 lines · Wei Yang
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · Wei Yang
PHYS_MAP_NODE_NILis assigned to PhysPageEntry.ptr in case this is not a leaf entry, whilemap->nodes_nbrange in [0,nodes_nb_alloc).Quoted 8 lines
Quoted 1 line
Seems we are asserting on two different things, just remove it.
The assertion checks that this "if" is not entered incorrectly:
if (lp->skip && lp->ptr == PHYS_MAP_NODE_NIL) { lp->ptr = phys_map_node_alloc(map, level == 0); }Hmm... I may not get your point.
phys_map_node_alloc()will get an available PhysPageEntry and return its index, which will be assigned to its parent's ptr.The "if" checks on the parent's ptr, while the assertion asserts the index for the new child. I may miss something?
Quoted 8 lines
Quoted 3 lines
Hi, Paolo,
Do I miss something?
Sorry, I was on vacation.
phys_page_set_levelcan be called multiple times, with the same lp. The assertion checks that only the first call will reachphys_map_node_alloc.
Ah, I am just back from vacation too. The mountain makes me painful. :-)
So I guess you are talking about the situation of wrap around. PHYS_MAP_NODE_NIL is an indicator that this lp is not used yet. And we are not expecting any valid lp has its ptr with value equal or bigger than PHYS_MAP_NODE_NIL.
If this is the case, I am thinking this won't happen in current implementation. Because if my understanding is correct, the total number of PhysPageEntry would be less than PHYS_MAP_NODE_NIL.
First let's look at the PHYS_MAP_NODE_NIL's value
PHYS_MAP_NODE_NIL = 2^26 = 6710 8864.
So we could represent 6710 8864 PhysPageEntry at most.
Then let's look how many PhysPageEntry would be. The PhysPageEntry structure forms a tree with 9 nodes on each level with P_L2_LEVELS levels. This means the tree could have 9^P_L2_LEVELS nodes at most.
Since
#define ADDR_SPACE_BITS 64
#define P_L2_BITS 9
#define P_L2_LEVELS (((ADDR_SPACE_BITS - TARGET_PAGE_BITS - 1) / P_L2_BITS) + 1)
And TARGET_PAGE_BITS >= 12, so P_L2_LEVELS is smaller than
7 = (64 - 12 - 1) / 9 + 1.
This leads to
9^P_L2_LEVELS <= 9^7 = 478 2969
It shows PHYS_MAP_NODE_NIL may represents more node the tree could hold.
The assert here is not harmful, while maybe we can have a better way to handle it?
Quoted 1 line
Paolo
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 1 line · Wei Yang
It shows
PHYS_MAP_NODE_NILmay represents more node the tree could hold.
Which is good, it means the assert can trigger.
Quoted 2 lines
The assert here is not harmful, while maybe we can have a better way to handle it?
I don't know... The assert just says "careful, someone treats PHYS_MAP_NODE_NIL specially!". It's documentation too.
Paolo
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Wei Yang
It shows
PHYS_MAP_NODE_NILmay represents more node the tree could hold.Which is good, it means the assert can trigger.
Per my understanding, it means the assert can't trigger.
Quoted 7 lines
Quoted 2 lines
The assert here is not harmful, while maybe we can have a better way to handle it?
I don't know... The assert just says "careful, someone treats
PHYS_MAP_NODE_NILspecially!". It's documentation too.Paolo
Signature · 2 lines
Wei Yang Help you, Help me
Re: [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc()
Quoted 8 lines · Wei Yang
Quoted 5 lines · Paolo Bonzini
Quoted 1 line · Wei Yang
It shows
PHYS_MAP_NODE_NILmay represents more node the tree could hold.Which is good, it means the assert can trigger.
Per my understanding, it means the assert can't trigger.
You're right, sorry. That's what I meant.
Paolo
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
The assert here is not harmful, while maybe we can have a better way to handle it?
I don't know... The assert just says "careful, someone treats
PHYS_MAP_NODE_NILspecially!". It's documentation too.Paolo