Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633693

Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds

From Baoquan He <bhe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds
Date 2017-05-01 17:00 +0200
Message-ID <tCkXT-1YA-5@gated-at.bofh.it> (permalink)
References <tCi02-bT-9@gated-at.bofh.it> <tCkOe-1Vi-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Baoquan He <bhe@redhat.com> - 2017-05-01 13:50 +0200
  Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Thomas Garnier <thgarnie@google.com> - 2017-05-01 16:20 +0200
  Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Dan Williams <dan.j.williams@intel.com> - 2017-05-01 16:50 +0200
    Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in  sync_global_pgds Baoquan He <bhe@redhat.com> - 2017-05-01 17:00 +0200
      Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Dan Williams <dan.j.williams@intel.com> - 2017-05-01 17:50 +0200
        Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in  sync_global_pgds Baoquan He <bhe@redhat.com> - 2017-05-01 17:50 +0200
  Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds Yinghai Lu <yinghai@kernel.org> - 2017-05-02 00:40 +0200
    Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in  sync_global_pgds Baoquan He <bhe@redhat.com> - 2017-05-02 09:20 +0200
      Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in  sync_global_pgds Ingo Molnar <mingo@kernel.org> - 2017-05-02 09:30 +0200
        Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in  sync_global_pgds Baoquan He <bhe@redhat.com> - 2017-05-02 09:50 +0200

csiph-web