2015-06-06 06:11:06

by Minfei Huang

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Minfei Huang <[email protected]>
---
kernel/kexec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/kexec.c b/kernel/kexec.c
index 7a36fdc..4589899 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -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;
}
--
2.2.2


2015-06-15 09:29:09

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH] kexec: Remove the unnecessary conditional judgement to simplify the code logic

On 06/06/15 at 02:14pm, Minfei Huang wrote:
> 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.
>
> Signed-off-by: Minfei Huang <[email protected]>
> ---
> kernel/kexec.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index 7a36fdc..4589899 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -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;
> }

Acked-by: Dave Young <[email protected]>

Thanks
Dave

2015-07-25 09:07:00

by Minfei Huang

[permalink] [raw]
Subject: Re: [PATCH] kexec: Remove the unnecessary conditional judgement to simplify the code logic

Hi, Vivek.

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

Thanks
Minfei

On 06/15/15 at 05:28pm, Dave Young wrote:
> On 06/06/15 at 02:14pm, Minfei Huang wrote:
> > 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.
> >
> > Signed-off-by: Minfei Huang <[email protected]>
> > ---
> > kernel/kexec.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/kernel/kexec.c b/kernel/kexec.c
> > index 7a36fdc..4589899 100644
> > --- a/kernel/kexec.c
> > +++ b/kernel/kexec.c
> > @@ -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;
> > }
>
> Acked-by: Dave Young <[email protected]>
>
> Thanks
> Dave

2015-07-27 13:44:56

by Vivek Goyal

[permalink] [raw]
Subject: Re: [PATCH] kexec: Remove the unnecessary conditional judgement to simplify the code logic

On Sat, Jun 06, 2015 at 02:14:12PM +0800, Minfei Huang wrote:
> 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.
>
> Signed-off-by: Minfei Huang <[email protected]>

Looks good to me.

Acked-by: Vivek Goyal <[email protected]>

Thanks
Vivek

> ---
> kernel/kexec.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index 7a36fdc..4589899 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -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;
> }
> --
> 2.2.2

2015-07-28 04:30:25

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH] kexec: Remove the unnecessary conditional judgement to simplify the code logic

On Mon, Jul 27, 2015 at 09:44:53AM -0400, Vivek Goyal wrote:
> On Sat, Jun 06, 2015 at 02:14:12PM +0800, Minfei Huang wrote:
> > 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.
> >
> > Signed-off-by: Minfei Huang <[email protected]>
>
> Looks good to me.
>
> Acked-by: Vivek Goyal <[email protected]>

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.

2015-07-28 04:42:29

by Minfei Huang

[permalink] [raw]
Subject: Re: [PATCH] kexec: Remove the unnecessary conditional judgement to simplify the code logic

On 07/28/15 at 01:30pm, Simon Horman wrote:
> On Mon, Jul 27, 2015 at 09:44:53AM -0400, Vivek Goyal wrote:
> > On Sat, Jun 06, 2015 at 02:14:12PM +0800, Minfei Huang wrote:
> > > 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.
> > >
> > > Signed-off-by: Minfei Huang <[email protected]>
> >
> > Looks good to me.
> >
> > Acked-by: Vivek Goyal <[email protected]>
>
> 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