From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940308AbdEAPj4 (ORCPT ); Mon, 1 May 2017 11:39:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28446 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939165AbdEAPiN (ORCPT ); Mon, 1 May 2017 11:38:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 93CBA8AE65 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=bhe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 93CBA8AE65 Date: Mon, 1 May 2017 23:31:10 +0800 From: Baoquan He To: Dan Williams Cc: "linux-kernel@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , Kees Cook , Thomas Garnier , Andrew Morton , Yasuaki Ishimatsu , Jinbum Park , Dave Hansen , "Kirill A. Shutemov" , Yinghai Lu , Dave Young Subject: Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Message-ID: <20170501153110.GJ2649@x1> References: <1493638874-4014-1-git-send-email-bhe@redhat.com> <20170501145258.GI2649@x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 01 May 2017 15:31:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/17 at 08:24am, Dan Williams wrote: > On Mon, May 1, 2017 at 7:52 AM, Baoquan He wrote: > > On 05/01/17 at 07:40am, Dan Williams wrote: > >> On Mon, May 1, 2017 at 4:41 AM, Baoquan He wrote: > >> > arch/x86/mm/init_64.c | 6 ++++-- > >> > 1 file changed, 4 insertions(+), 2 deletions(-) > >> > > >> > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c > >> > index 15173d3..dbf4f00 100644 > >> > --- a/arch/x86/mm/init_64.c > >> > +++ b/arch/x86/mm/init_64.c > >> > @@ -94,12 +94,14 @@ __setup("noexec32=", nonx32_setup); > >> > */ > >> > void sync_global_pgds(unsigned long start, unsigned long end) > >> > { > >> > - unsigned long address; > >> > + unsigned long address, address_next; > >> > > >> > - for (address = start; address <= end; address += PGDIR_SIZE) { > >> > + for (address = start; address <= end; address = address_next) { > >> > const pgd_t *pgd_ref = pgd_offset_k(address); > >> > struct page *page; > >> > > >> > + address_next = (address & PGDIR_MASK) + PGDIR_SIZE; > >> > + > >> > >> Let's change this to put the next address calculation in the for loop > >> directly and use the ALIGN macro. Something like: > >> > >> for (address = start; address <= end; address = ALIGN(address + 1, PGDIR_SIZE)) > > > > Hi Dan, > > > > Good idea! > > > > Do you think below change is OK for you? Taking out the initialization > > can make the for loop line be shorter than 80 char. > > > > I would just wrap the "address = ALIGN(address + 1, PGDIR_SIZE)" if it > doesn't fit. OK, it's fine, will do wrapping. > > > > > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c > > index 15173d3..0840311 100644 > > --- a/arch/x86/mm/init_64.c > > +++ b/arch/x86/mm/init_64.c > > @@ -94,12 +94,14 @@ __setup("noexec32=", nonx32_setup); > > */ > > void sync_global_pgds(unsigned long start, unsigned long end) > > { > > - unsigned long address; > > + unsigned long address = start; > > > > - for (address = start; address <= end; address += PGDIR_SIZE) { > > + for (; address <= end; address = ALIGN(address + 1, PGDIR_SIZE)) > > { > > const pgd_t *pgd_ref = pgd_offset_k(address); > > struct page *page; > > > > + address_next = (address & PGDIR_MASK) + PGDIR_SIZE; > > + > > This gets deleted of course. Sure, forget deleting it. while I am also testing on Jeff's system, that code is right, otherwise compiling won't pass. Will repost after the pgd crossing case seen and passed. Thanks Baoquan