Skip to contentSkip to conversation

mm: change tlb_finish_mmu() to be more simple

PATCH In review yalin wang 3 participants 4 messages Nov 4, 2015

Subsystems (2)
lore
Share & tools
lore

yalin wang

author
#0 lore raw

PATCH 1/1 mm: change tlb_finish_mmu() to be more simple

This patch remove unneeded *next temp variable,
make this function more simple to read.

---
 mm/memory.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/memory.c +3 -4
index 7f3b9f2..f0040ed 100644
@@ -270,17 +270,16 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
  */
 void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
 {
-	struct mmu_gather_batch *batch, *next;
+	struct mmu_gather_batch *batch;
 
 	tlb_flush_mmu(tlb);
 
 	/* keep the page table cache within bounds */
 	check_pgt_cache();
 
-	for (batch = tlb->local.next; batch; batch = next) {
-		next = batch->next;
+	for (batch = tlb->local.next; batch; batch = batch->next)
 		free_pages((unsigned long)batch, 0);
-	}
+
 	tlb->local.next = NULL;
 }
 
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 17 lines · yalin wang

This patch remove unneeded *next temp variable,
make this function more simple to read.

---
 mm/memory.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/memory.c +0 -1
index 7f3b9f2..f0040ed 100644
@@ -270,17 +270,16 @@ void tlb_flush_mmu(struct mmu_gather *tlb)
  */
 void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
 {
-	struct mmu_gather_batch *batch, *next;

mm/memory.c void tlb_flush_mmu(struct mmu_gather *tlb) · line 280

Quoted 10 lines
mm/memory.c +2 -2
+	struct mmu_gather_batch *batch;
 
 	tlb_flush_mmu(tlb);
 
 	/* keep the page table cache within bounds */
 	check_pgt_cache();
 
-	for (batch = tlb->local.next; batch; batch = next) {
-		next = batch->next;
+	for (batch = tlb->local.next; batch; batch = batch->next)

Use after free? No, thanks.

Quoted 14 lines
mm/memory.c +1 -1
 		free_pages((unsigned long)batch, 0);
-	}
+
 	tlb->local.next = NULL;
 }
 
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Signature · 7 lines
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
In reply to yalin wang

On (11/04/15 15:35), yalin wang wrote:
[..]

mm/memory.c void tlb_flush_mmu(struct mmu_gather *tlb) · line 281

Quoted 5 lines
mm/memory.c +1 -2
-	for (batch = tlb->local.next; batch; batch = next) {
-		next = batch->next;
+	for (batch = tlb->local.next; batch; batch = batch->next)
 		free_pages((unsigned long)batch, 0);

accessing batch->next' after calling free_pages() on batch'?

		-ss

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#3 lore raw
Quoted 6 lines · Sergey Senozhatsky

On (11/04/15 15:35), yalin wang wrote:
[..]

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
mm/memory.c +1 -2
-	for (batch = tlb->local.next; batch; batch = next) {
-		next = batch->next;
+	for (batch = tlb->local.next; batch; batch = batch->next)
		free_pages((unsigned long)batch, 0);

accessing batch->next' after calling free_pages() on batch'?

		-ss

oh, my mistake, my code is buggy here .

Thanks
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>