Skip to contentSkip to conversation

kexec: Remove the unnecessary conditional judgement to simplify the code logic

PATCH In review Minfei Huang 5 participants 6 messages Jun 6, 2015 – Jul 28, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kexec: Remove the unnecessary conditional judgement to simplify the code logic

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

---
 kernel/kexec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kexec.c +1 -2
index 7a36fdc..4589899 100644
@@ -796,11 +796,10 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 		/* If I don't overlap any segments I have found my hole! */
 		if (i == image->nr_segments) {
 			pages = pfn_to_page(hole_start >> PAGE_SHIFT);
+			image->control_page = hole_end;
 			break;
 		}
 	}
-	if (pages)
-		image->control_page = hole_end;
 
 	return pages;
 }
Signature · 1 line
2.2.2
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines · Minfei Huang

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

---
 kernel/kexec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kexec.c +0 -0
index 7a36fdc..4589899 100644
@@ -796,11 +796,10 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 		/* If I don't overlap any segments I have found my hole! */
 		if (i == image->nr_segments) {

kernel/kexec.c static struct page *kimage_alloc_crash_control_pages(struct kimage *image, · line 805

Quoted 10 lines
kernel/kexec.c +1 -2
 			pages = pfn_to_page(hole_start >> PAGE_SHIFT);
+			image->control_page = hole_end;
 			break;
 		}
 	}
-	if (pages)
-		image->control_page = hole_end;
 
 	return pages;
 }

Thanks
Dave

#2 lore raw

Hi, Vivek.

Since Dave acked this patch, Could you help to merge it?

Thanks
Minfei

Quoted 34 lines · Dave Young
Quoted 18 lines · Minfei Huang

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

---
 kernel/kexec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kexec.c +0 -0
index 7a36fdc..4589899 100644
@@ -796,11 +796,10 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 		/* If I don't overlap any segments I have found my hole! */
 		if (i == image->nr_segments) {

kernel/kexec.c static struct page *kimage_alloc_crash_control_pages(struct kimage *image, · line 805

Quoted 10 lines
kernel/kexec.c +1 -2
 			pages = pfn_to_page(hole_start >> PAGE_SHIFT);
+			image->control_page = hole_end;
 			break;
 		}
 	}
-	if (pages)
-		image->control_page = hole_end;
 
 	return pages;
 }

Thanks
Dave

Acked-by on v1 1/1
#3 lore raw
In reply to Minfei Huang
Quoted 7 lines · Minfei Huang

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

Looks good to me.

Thanks
Vivek

Quoted 23 lines
---
 kernel/kexec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/kexec.c +1 -2
index 7a36fdc..4589899 100644
@@ -796,11 +796,10 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 		/* If I don't overlap any segments I have found my hole! */
 		if (i == image->nr_segments) {
 			pages = pfn_to_page(hole_start >> PAGE_SHIFT);
+			image->control_page = hole_end;
 			break;
 		}
 	}
-	if (pages)
-		image->control_page = hole_end;
 
 	return pages;
 }
Signature · 1 line
2.2.2
#4 lore raw
Quoted 7 lines · Vivek Goyal
Quoted 6 lines · Minfei Huang

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

Quoted 5 lines
Quoted 1 line

Looks good to me.

FWIW, this probably needs to be reposted to Andrew Morton with appropriate Acks and CCs in order to proceed into his tree and then Linus's.

#5 lore raw
Quoted 8 lines · Simon Horman
Quoted 7 lines · Vivek Goyal
Quoted 6 lines · Minfei Huang

From: Minfei Huang <[email protected]>

Transforming PFN(Page Frame Number) to struct page is never failure, so we can simplify the code logic to do the image->control_page assignment directly in the loop, and remove the unnecessary conditional judgement.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Looks good to me.

FWIW, this probably needs to be reposted to Andrew Morton with appropriate Acks and CCs in order to proceed into his tree and then Linus's.

Thanks.

I will repost it to Andrew Morton.

Thanks
Minfei