Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp816561ybn; Tue, 24 Sep 2019 09:57:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH3vayzF2RvB/bCrFAkMkeXoeJUt0TiHSMIns84vEdIWoiwp3ST/LEuVc2c6wb+jtGGhWe X-Received: by 2002:a17:906:2cc8:: with SMTP id r8mr3410134ejr.197.1569344267724; Tue, 24 Sep 2019 09:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344267; cv=none; d=google.com; s=arc-20160816; b=IJTDvdjliqkgGs8XCBUNyPz2XaKxTgOeHEzjHToQe178Y5ZHtk/Wssbu1nO5opEP2P b0VTqfp5yNcaM0HX1M+xdv04gR/9SrfPMb6iTXXtaNc96baVH+QLdUXxzAzSp8hcdgBi I5ftU40SK/XxHVjv6aEpK0E8s6mr0zlb6avxyVYJAAqBxirHtIRPAg9ItamUHC/OhgHV p4BXUsYv3NJDK5aclGyIU5rBEhovu+RM0NnJuwcWaUgCxOzYdA3v6jyRTt6G+140GrVq u6tjQdDMBVos2ISnETPgRgwotP+00WVt+/alThp1zbzXLH9XSwD458+edIZubPTJO/Yq p/GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dnzMY/Kge/UqptUtdwz/i11aQpS5XjfF6hS+xZmxJYs=; b=ASNa0ii/ZhkLxpeUu7MVJ9MPU+NBpG9MlZkESpekeo6rNrLfyAvCOZebzu+k1yNXfc 1fMSuGKR4rvtuKBVDKGosI+9cMSCdz0Zx1weS2hvfT8AIytwYPAptyMscbWqU85zyzhV icP+5Bu7WgtuwF8Ehx4zPVL2Fo7Fj0oChYYVD19Y+Syuy38mQ5BM23YPgtd04LLM+jiS CnemPkGIIBI8MOXnAzsWlcvthnHRi+NEG6MgP4Z1Tf4EDvfV5vr+ruKfGgrEvlvl/Ozq s4RZHYwaqRIb2Z8ozsnXtGyCIeUZykAJbkUXFgTVqnhwKTDJqePgWfG/ZSe4bbmGka8b EYjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=upNinS9k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si1231782ejq.45.2019.09.24.09.57.24; Tue, 24 Sep 2019 09:57:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=upNinS9k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406991AbfIWJWe (ORCPT + 99 others); Mon, 23 Sep 2019 05:22:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58952 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbfIWJWe (ORCPT ); Mon, 23 Sep 2019 05:22:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dnzMY/Kge/UqptUtdwz/i11aQpS5XjfF6hS+xZmxJYs=; b=upNinS9kGBDN5G+UzVvaq1JQx Qb3+aczpeSOMsOcMyy9el/f/5/oWOCAoXZc1VWfeDA5+wvAFeSXiZOb2BKFJTD5ppwjC52sNPwJAW +EJlMyoHbtYOFMHJzFIGwD39XpiP1BLyHp6QCueEi3eo0otFsh/J7gL+Kfmhgr7G3X9ZuKpox376q v1t2ymVjU5CRlTrKwIIlhLaGlk3hC+lM03n+LbVbcEjb7ZZEelAQQ6rFhBbA5zz24ZwxmE60hl34m CZZag9EV5zz3ZEaAOcMOK7c3r05nyu8NmIM1WT+fRj38mZe7SHXiNBiK1ErxpWeMe+0Ts65uqjo7n +p6aAzIlQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.2 #3 (Red Hat Linux)) id 1iCKYD-0004q1-IQ; Mon, 23 Sep 2019 09:22:33 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 91418301A7A; Mon, 23 Sep 2019 11:21:46 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A333F20C3E177; Mon, 23 Sep 2019 11:22:31 +0200 (CEST) Date: Mon, 23 Sep 2019 11:22:31 +0200 From: Peter Zijlstra To: Wei Yang 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 Message-ID: <20190923092231.GJ2349@hirez.programming.kicks-ass.net> References: <20190919020844.27461-1-richardw.yang@linux.intel.com> <20190919020844.27461-2-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190919020844.27461-2-richardw.yang@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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?