From: Baoquan He <bhe@redhat.com> To: Dan Williams <dan.j.williams@intel.com> Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, X86 ML <x86@kernel.org>, Kees Cook <keescook@chromium.org>, Thomas Garnier <thgarnie@google.com>, Andrew Morton <akpm@linux-foundation.org>, Yasuaki Ishimatsu <yasu.isimatu@gmail.com>, Jinbum Park <jinb.park7@gmail.com>, Dave Hansen <dave.hansen@linux.intel.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Yinghai Lu <yinghai@kernel.org>, Dave Young <dyoung@redhat.com> Subject: Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Date: Mon, 1 May 2017 22:52:58 +0800 [thread overview] Message-ID: <20170501145258.GI2649@x1> (raw) In-Reply-To: <CAPcyv4jfFK3ZMGtqFRjgtB1__73Ja-94XS3=FB1Wj9SNxn+-JQ@mail.gmail.com> On 05/01/17 at 07:40am, Dan Williams wrote: > On Mon, May 1, 2017 at 4:41 AM, Baoquan He <bhe@redhat.com> 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. 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; + if (pgd_none(*pgd_ref)) continue;
next prev parent reply other threads:[~2017-05-01 14:54 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-01 11:41 Baoquan He 2017-05-01 14:15 ` Thomas Garnier 2017-05-01 14:40 ` Dan Williams 2017-05-01 14:52 ` Baoquan He [this message] 2017-05-01 15:24 ` Dan Williams 2017-05-01 15:31 ` Baoquan He 2017-05-01 22:37 ` Yinghai Lu 2017-05-02 7:18 ` Baoquan He 2017-05-02 7:24 ` Ingo Molnar 2017-05-02 7:40 ` Baoquan He
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=20170501145258.GI2649@x1 \ --to=bhe@redhat.com \ --cc=akpm@linux-foundation.org \ --cc=dan.j.williams@intel.com \ --cc=dave.hansen@linux.intel.com \ --cc=dyoung@redhat.com \ --cc=hpa@zytor.com \ --cc=jinb.park7@gmail.com \ --cc=keescook@chromium.org \ --cc=kirill.shutemov@linux.intel.com \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@redhat.com \ --cc=tglx@linutronix.de \ --cc=thgarnie@google.com \ --cc=x86@kernel.org \ --cc=yasu.isimatu@gmail.com \ --cc=yinghai@kernel.org \ --subject='Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds' \ /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
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).