mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Wei Yang <richardw.yang@linux.intel.com>
Cc: dave.hansen@linux.intel.com, luto@kernel.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] x86/mm: replace a goto by merging two if clause
Date: Mon, 23 Sep 2019 11:22:31 +0200	[thread overview]
Message-ID: <20190923092231.GJ2349@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190919020844.27461-2-richardw.yang@linux.intel.com>

On Thu, Sep 19, 2019 at 10:08:44AM +0800, Wei Yang wrote:
> There is only one place to use good_area jump, which could be reduced by
> merging the following two if clause.
> 
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> ---
>  arch/x86/mm/fault.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index 9d18b73b5f77..72ce6c69e195 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1390,18 +1390,17 @@ void do_user_addr_fault(struct pt_regs *regs,
>  	vma = find_vma(mm, address);
>  	if (unlikely(!vma))
>  		goto bad_area;
> -	if (likely(vma->vm_start <= address))
> -		goto good_area;
> -	if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)))
> -		goto bad_area;
> -	if (unlikely(expand_stack(vma, address)))
> +	if (likely(vma->vm_start <= address)) {
> +		/* good area, do nothing */
> +	} else if (unlikely(!(vma->vm_flags & VM_GROWSDOWN)) ||
> +		   unlikely(expand_stack(vma, address))) {
>  		goto bad_area;
> +	}
>  
>  	/*
>  	 * Ok, we have a good vm_area for this memory access, so
>  	 * we can handle it..
>  	 */
> -good_area:
>  	if (unlikely(access_error(hw_error_code, vma))) {
>  		bad_area_access_error(regs, hw_error_code, address, vma);
>  		return;

I find the old code far easier to read... is there any actual reason to
do this?

  reply	other threads:[~2019-09-23  9:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19  2:08 [PATCH 1/2] x86/mm: consolidate bad_area handling to the end Wei Yang
2019-09-19  2:08 ` [PATCH 2/2] x86/mm: replace a goto by merging two if clause Wei Yang
2019-09-23  9:22   ` Peter Zijlstra [this message]
2019-09-24  0:29     ` Wei Yang
2019-10-01 11:47     ` Wei Yang

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=20190923092231.GJ2349@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=richardw.yang@linux.intel.com \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®