linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Young <dyoung@redhat.com>
To: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: bhe@redhat.com, vgoyal@redhat.com, bauerman@linux.vnet.ibm.com,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kexec: allocate buffer in top-down, if specified, correctly
Date: Fri, 28 Apr 2017 12:46:19 +0800	[thread overview]
Message-ID: <20170428044619.GA3600@dhcp-128-65.nay.redhat.com> (raw)
In-Reply-To: <20170426082209.12127-1-takahiro.akashi@linaro.org>

Hi AKASHI
On 04/26/17 at 05:22pm, AKASHI Takahiro wrote:
> The current kexec_locate_mem_hole(kbuf.top_down == 1) stops searching at
> the first memory region that has enough space for requested size even if
> some of higher regions may also have.
> This behavior is not consistent with locate_hole(hole_end == -1) function
> of kexec-tools.

Have you seen actual bug happened or just observing this during code
review?

Till now seems we do not see any reports about this.

> 
> This patch fixes the bug, going though all the memory regions anyway.
> 
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  kernel/kexec_file.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
> index b118735fea9d..2f131c0d9017 100644
> --- a/kernel/kexec_file.c
> +++ b/kernel/kexec_file.c
> @@ -373,8 +373,8 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
>  	/* If we are here, we found a suitable memory range */
>  	kbuf->mem = temp_start;
>  
> -	/* Success, stop navigating through remaining System RAM ranges */
> -	return 1;
> +	/* always return zero, going through all the System RAM ranges */
> +	return 0;
>  }
>  
>  static int locate_mem_hole_bottom_up(unsigned long start, unsigned long end,
> @@ -439,18 +439,27 @@ static int locate_mem_hole_callback(u64 start, u64 end, void *arg)
>   *
>   * Return: The memory walk will stop when func returns a non-zero value
>   * and that value will be returned. If all free regions are visited without
> - * func returning non-zero, then zero will be returned.
> + * func returning non-zero, then kbuf->mem will be additionally checked
> + * for top-down search.
> + * After all, zero will be returned if none of regions fits.
>   */
>  int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf,
>  			       int (*func)(u64, u64, void *))
>  {
> +	int ret;
> +
> +	kbuf->mem = 0;
>  	if (kbuf->image->type == KEXEC_TYPE_CRASH)
> -		return walk_iomem_res_desc(crashk_res.desc,
> +		ret = walk_iomem_res_desc(crashk_res.desc,
>  					   IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY,
>  					   crashk_res.start, crashk_res.end,
>  					   kbuf, func);
>  	else
> -		return walk_system_ram_res(0, ULONG_MAX, kbuf, func);
> +		ret = walk_system_ram_res(0, ULONG_MAX, kbuf, func);
> +
> +	if (!ret && kbuf->mem)
> +		ret = 1; /* found for top-down search */
> +	return ret;
>  }
>  
>  /**
> -- 
> 2.11.1
> 

      parent reply	other threads:[~2017-04-28  4:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26  8:22 [PATCH] kexec: allocate buffer in top-down, if specified, correctly AKASHI Takahiro
2017-04-27 22:00 ` Thiago Jung Bauermann
2017-04-28  0:51   ` AKASHI Takahiro
2017-04-28  5:19     ` Dave Young
2017-04-28  5:23       ` Dave Young
2017-04-28 19:33     ` Thiago Jung Bauermann
2017-04-28  4:46 ` Dave Young [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170428044619.GA3600@dhcp-128-65.nay.redhat.com \
    --to=dyoung@redhat.com \
    --cc=bauerman@linux.vnet.ibm.com \
    --cc=bhe@redhat.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).