Skip to contentSkip to conversation

exec.c: Use tb1->phys_hash_next directly in tb_remove

PATCH Superseded 陳韋任 (Wei-Ren Chen) 3 participants 5 messages Nov 20, 2012 – Dec 20, 2012

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 exec.c: Use tb1->phys_hash_next directly in tb_remove

When tb_remove was first commited at fd6ce8f6, there were three different
calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly.

---

v2: Address Peter's comment.
- place comment used belong tb_remove above tb_phys_invalidate.
- remove unnecessary bracket.

 exec.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
exec.c +5 -7
index 8435de0..6343838 100644
@@ -862,18 +862,16 @@ static void tb_page_check(void)
 
 #endif
 
-/* invalidate one TB */
-static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb,
-                             int next_offset)
+static inline void tb_hash_remove(TranslationBlock **ptb, TranslationBlock *tb)
 {
     TranslationBlock *tb1;
     for(;;) {
         tb1 = *ptb;
         if (tb1 == tb) {
-            *ptb = *(TranslationBlock **)((char *)tb1 + next_offset);
+            *ptb = tb1->phys_hash_next;
             break;
         }
-        ptb = (TranslationBlock **)((char *)tb1 + next_offset);
+        ptb = &tb1->phys_hash_next;
     }
 }
 
@@ -929,6 +927,7 @@ static inline void tb_reset_jump(TranslationBlock *tb, int n)
     tb_set_jmp_target(tb, n, (uintptr_t)(tb->tc_ptr + tb->tb_next_offset[n]));
 }
 
+/* invalidate one TB */
 void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
 {
     CPUArchState *env;
@@ -940,8 +939,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
     /* remove the TB from the hash list */
     phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
     h = tb_phys_hash_func(phys_pc);
-    tb_remove(&tb_phys_hash[h], tb,
-              offsetof(TranslationBlock, phys_hash_next));
+    tb_hash_remove(&tb_phys_hash[h], tb);
 
     /* remove the TB from the page list */
     if (tb->page_addr[0] != page_addr) {
Signature · 9 lines
1.7.3.4


-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · 陳韋任 (Wei-Ren Chen)

When tb_remove was first commited at fd6ce8f6, there were three different
calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly.

-- PMM

#2 lore raw
In reply to 陳韋任 (Wei-Ren Chen)

[CC'ed qemu-trivial]

ping?

Quoted 70 lines · 陳韋任 (Wei-Ren Chen)

When tb_remove was first commited at fd6ce8f6, there were three different
calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly.

---

v2: Address Peter's comment.
- place comment used belong tb_remove above tb_phys_invalidate.
- remove unnecessary bracket.

 exec.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
exec.c +5 -7
index 8435de0..6343838 100644
@@ -862,18 +862,16 @@ static void tb_page_check(void)
 
 #endif
 
-/* invalidate one TB */
-static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb,
-                             int next_offset)
+static inline void tb_hash_remove(TranslationBlock **ptb, TranslationBlock *tb)
 {
     TranslationBlock *tb1;
     for(;;) {
         tb1 = *ptb;
         if (tb1 == tb) {
-            *ptb = *(TranslationBlock **)((char *)tb1 + next_offset);
+            *ptb = tb1->phys_hash_next;
             break;
         }
-        ptb = (TranslationBlock **)((char *)tb1 + next_offset);
+        ptb = &tb1->phys_hash_next;
     }
 }
 
@@ -929,6 +927,7 @@ static inline void tb_reset_jump(TranslationBlock *tb, int n)
     tb_set_jmp_target(tb, n, (uintptr_t)(tb->tc_ptr + tb->tb_next_offset[n]));
 }
 
+/* invalidate one TB */
 void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
 {
     CPUArchState *env;
@@ -940,8 +939,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
     /* remove the TB from the hash list */
     phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
     h = tb_phys_hash_func(phys_pc);
-    tb_remove(&tb_phys_hash[h], tb,
-              offsetof(TranslationBlock, phys_hash_next));
+    tb_hash_remove(&tb_phys_hash[h], tb);
 
     /* remove the TB from the page list */
     if (tb->page_addr[0] != page_addr) {
Signature · 9 lines
1.7.3.4


-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#3 lore raw
In reply to 陳韋任 (Wei-Ren Chen)
Quoted 7 lines · 陳韋任 (Wei-Ren Chen)

When tb_remove was first commited at fd6ce8f6, there were three different
calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly.

Quoted 8 lines

---

v2: Address Peter's comment.
- place comment used belong tb_remove above tb_phys_invalidate.
- remove unnecessary bracket.

 exec.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

Please rebase onto qemu.git/master.

Stefan

#4 lore raw
Quoted 10 lines · Stefan Hajnoczi
Quoted 9 lines · 陳韋任 (Wei-Ren Chen)

When tb_remove was first commited at fd6ce8f6, there were three different
calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly.

---

Quoted 8 lines
Quoted 6 lines

v2: Address Peter's comment.
- place comment used belong tb_remove above tb_phys_invalidate.
- remove unnecessary bracket.

 exec.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

Please rebase onto qemu.git/master.

done. I sent to qemu-trivial this time. :)

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj