Skip to contentSkip to conversation

xen/mm: Remove always true ASSERT() in free_heap_pages()

PATCH In review Julien Grall 3 participants 5 messages Feb 23, 2022 – Feb 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/mm: Remove always true ASSERT() in free_heap_pages()

From: Julien Grall <[email protected]>

free_heap_pages() has an ASSERT() checking that node is >= 0. However node is defined as an unsigned int. So it cannot be negative.

Therefore remove the check as it will always be true.

---

I have looked at the history. AFAICT, node has always be defined as unsigned int. So the ASSERT() may have never been useful (?).

---
 xen/common/page_alloc.c | 1 -
 1 file changed, 1 deletion(-)
xen/common/page_alloc.c +0 -1
index 46357182375a..e971bf91e0be 100644
@@ -1441,7 +1441,6 @@ static void free_heap_pages(
     unsigned int zone = page_to_zone(pg);
 
     ASSERT(order <= MAX_ORDER);
-    ASSERT(node >= 0);
 
     spin_lock(&heap_lock);
 
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw

On 23/02/2022 18:38, Julien Grall wrote:

From: Julien Grall <[email protected]><mailto:[email protected]>

free_heap_pages() has an ASSERT() checking that node is >= 0. However node is defined as an unsigned int. So it cannot be negative.

Therefore remove the check as it will always be true.

Coverity-ID: 1055631

#2 lore raw

Hi Andrew,

Quoted 9 lines · Andrew Cooper
Quoted 6 lines · Julien Grall

From: Julien Grall<[email protected]>

free_heap_pages() has an ASSERT() checking that node is >= 0. However node is defined as an unsigned int. So it cannot be negative.

Therefore remove the check as it will always be true.

Coverity-ID: 1055631

I will add it while committing.

Quoted 4 lines
Quoted 2 lines

Thanks!

Cheers,

Signature · 1 line
Julien Grall
Acked-by on v1 1/1
#3 lore raw
In reply to Julien Grall
Quoted 5 lines · Julien Grall

From: Julien Grall <[email protected]>

free_heap_pages() has an ASSERT() checking that node is >= 0. However node is defined as an unsigned int. So it cannot be negative.

Quoted 8 lines

Therefore remove the check as it will always be true.

---

I have looked at the history. AFAICT, node has always be defined as unsigned int. So the ASSERT() may have never been useful (?).

Commit f0738d2d3f81 introduced "node" as a local variable of type "int". Along with this commit f1c6ac275100 introduced ia64's paddr_to_nid() (backing phys_to_nid()), which was able to return -1. Hence at the time the assertion fulfilled a purpose. I should have dropped it in bd3e1195d694.

Jan

#4 lore raw

Hi Jan,

Quoted 12 lines · Jan Beulich
Quoted 11 lines · Julien Grall

From: Julien Grall <[email protected]>

free_heap_pages() has an ASSERT() checking that node is >= 0. However node is defined as an unsigned int. So it cannot be negative.

Therefore remove the check as it will always be true.

---

Quoted 8 lines
Quoted 2 lines

I have looked at the history. AFAICT, node has always be defined as unsigned int. So the ASSERT() may have never been useful (?).

Commit f0738d2d3f81 introduced "node" as a local variable of type "int". Along with this commit f1c6ac275100 introduced ia64's paddr_to_nid() (backing phys_to_nid()), which was able to return -1. Hence at the time the assertion fulfilled a purpose. I should have dropped it in bd3e1195d694.

Thanks for the information. It looks like I need to brush my git-blame skill :).

Quoted 2 lines

Thanks!

Cheers,

Signature · 1 line
Julien Grall