Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1214583ybx; Tue, 5 Nov 2019 12:16:26 -0800 (PST) X-Google-Smtp-Source: APXvYqycmZde9WVeylY9QHeMTvCdYfgOBDnYruOUvrftvwhK9aEHm+vH+JNKhaigwzTAo6KRH0gu X-Received: by 2002:a05:6402:7cd:: with SMTP id u13mr6222049edy.246.1572984986394; Tue, 05 Nov 2019 12:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572984986; cv=none; d=google.com; s=arc-20160816; b=vWMfdVwX23ATCYiIEgG10jnlPj2oJqKBor9nk6ufZsZuKmBMEMAbixeP7Nl+WRDR6t 3cGdCXnAb3jT2qMk0oDsFUKAa5/txyo19zCreq6IrL8O6+y62QETV86jfBJl8ZdeXpLh eTCMEiiCfS+KEIW3QWmXfkacvI3FBdHoUmg4EsbanOV347I1fWBO/5yOx60qY+paInjC BUGh8kLy9VXngM0dMUFKOkK7y08z33BkP2Lowz4dnP+ufS9fL2LcKnRDSWY/fsxgndT1 Mrk6AwivyX+s95HkYtJqDFTaedZaC5M/8q5RYKHIARRcUBUgC+bCWJIjSXcuxOKV/DoX na3w== 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; bh=Cx6AAY+UTIKOfKcJH5Y268e2t0xzW9yNB7aXlrSADGg=; b=xToNsvBVQB9HlohqdeDfV3YBSK+9WaFivrAYIkhcOKwkDdVaXW1WsbEaMOA52ffyKl eotlqd/aFa1j7dGFDDiBnKzAD2WzBvmy2XsOesLWh6Y2tgkVH4KEt3DtS/3SSEJCU1cA XkRAIcswNpkshEtdGdJgCpSWC3HfxHXggiPd66VVktc8WV+mAu0ExacfHOL1dEAG1Qh3 AcUNBg8QIW+5dDF23HDdviDWshUILrBkD9QRWasN4XZDhMxmSi7zyq+bJmVyd8uqX27p Fhru+bGD7F46Gv6BezBBp5b3L3ISDhpkFDWa+6/KBvmOTpEC1QlCOSLgCCh6o95u1Zq2 JJaw== ARC-Authentication-Results: i=1; mx.google.com; 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 k18si11284187edj.94.2019.11.05.12.16.02; Tue, 05 Nov 2019 12:16:26 -0800 (PST) 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; 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 S1728810AbfKEUO5 (ORCPT + 99 others); Tue, 5 Nov 2019 15:14:57 -0500 Received: from foss.arm.com ([217.140.110.172]:59202 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727401AbfKEUO4 (ORCPT ); Tue, 5 Nov 2019 15:14:56 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A5727B9; Tue, 5 Nov 2019 12:14:56 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0BC003FBF5; Tue, 5 Nov 2019 01:37:10 -0800 (PST) Date: Tue, 5 Nov 2019 09:37:08 +0000 From: Mark Rutland To: Masahiro Yamada Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Andrew Morton , Anshuman Khandual , Ard Biesheuvel , David Hildenbrand , Hsin-Yi Wang , Robin Murphy , Steve Capper , Thomas Gleixner , Yu Zhao , linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64: mm: simplify the page end calculation in __create_pgd_mapping() Message-ID: <20191105093708.GE4743@lakrids.cambridge.arm.com> References: <20191103123559.8866-1-yamada.masahiro@socionext.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191103123559.8866-1-yamada.masahiro@socionext.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 03, 2019 at 09:35:58PM +0900, Masahiro Yamada wrote: > Calculate the page-aligned end address more simply. > > The local variable, "length" is unneeded. > > Signed-off-by: Masahiro Yamada > --- > > arch/arm64/mm/mmu.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 60c929f3683b..a9f541912289 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -338,7 +338,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, > phys_addr_t (*pgtable_alloc)(int), > int flags) > { > - unsigned long addr, length, end, next; > + unsigned long addr, end, next; > pgd_t *pgdp = pgd_offset_raw(pgdir, virt); > > /* > @@ -350,9 +350,8 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, > > phys &= PAGE_MASK; > addr = virt & PAGE_MASK; > - length = PAGE_ALIGN(size + (virt & ~PAGE_MASK)); > + end = PAGE_ALIGN(virt + size); > > - end = addr + length; While looking at this, I got confused by the old code and thought that there was an existing bug, but I now see that's not the case, and the old and new code are equivalent. The new code looks cleaner, and leaves less room for confusion, so I think that's preferable: Reviewed-by: Mark Rutland Mark. > do { > next = pgd_addr_end(addr, end); > alloc_init_pud(pgdp, addr, next, phys, prot, pgtable_alloc, > -- > 2.17.1 >