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


Groups > linux.kernel > #1267731

Re: [PATCH] x86/mm: fix regression with huge pages on PAE

From "Kirill A. Shutemov" <kirill@shutemov.name>
Newsgroups linux.kernel
Subject Re: [PATCH] x86/mm: fix regression with huge pages on PAE
Date 2015-11-12 10:10 +0100
Message-ID <qtW3f-6XW-1@gated-at.bofh.it> (permalink)
References (5 earlier) <qtUNQ-5ZA-3@gated-at.bofh.it> <qtUXw-62X-17@gated-at.bofh.it> <qtV7c-6m2-17@gated-at.bofh.it> <qtVJU-6BR-11@gated-at.bofh.it> <qtVTB-6Fg-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Nov 12, 2015 at 09:54:18AM +0100, Ingo Molnar wrote:
> 
> * Kirill A. Shutemov <kirill.shutemov@linux.intel.com> wrote:
> 
> > diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h
> > index c5b7fb2774d0..cc071c6f7d4d 100644
> > --- a/arch/x86/include/asm/page_types.h
> > +++ b/arch/x86/include/asm/page_types.h
> > @@ -9,19 +9,21 @@
> >  #define PAGE_SIZE	(_AC(1,UL) << PAGE_SHIFT)
> >  #define PAGE_MASK	(~(PAGE_SIZE-1))
> >  
> > +#define PMD_PAGE_SIZE		(_AC(1, UL) << PMD_SHIFT)
> > +#define PMD_PAGE_MASK		(~(PMD_PAGE_SIZE-1))
> > +
> > +#define PUD_PAGE_SIZE		(_AC(1, UL) << PUD_SHIFT)
> > +#define PUD_PAGE_MASK		(~(PUD_PAGE_SIZE-1))
> > +
> >  #define __PHYSICAL_MASK		((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
> >  #define __VIRTUAL_MASK		((1UL << __VIRTUAL_MASK_SHIFT) - 1)
> >  
> > -/* Cast PAGE_MASK to a signed type so that it is sign-extended if
> > +/* Cast *PAGE_MASK to a signed type so that it is sign-extended if
> >     virtual addresses are 32-bits but physical addresses are larger
> >     (ie, 32-bit PAE). */
> >  #define PHYSICAL_PAGE_MASK	(((signed long)PAGE_MASK) & __PHYSICAL_MASK)
> > -
> > -#define PMD_PAGE_SIZE		(_AC(1, UL) << PMD_SHIFT)
> > -#define PMD_PAGE_MASK		(~(PMD_PAGE_SIZE-1))
> > -
> > -#define PUD_PAGE_SIZE		(_AC(1, UL) << PUD_SHIFT)
> > -#define PUD_PAGE_MASK		(~(PUD_PAGE_SIZE-1))
> > +#define PHYSICAL_PMD_PAGE_MASK	(((signed long)PMD_PAGE_MASK) & __PHYSICAL_MASK)
> > +#define PHYSICAL_PUD_PAGE_MASK	(((signed long)PUD_PAGE_MASK) & __PHYSICAL_MASK)
> 
> that's a really odd way of writing it, 'long' is signed by default ...

See the comment above (it was there before the patch). 'signed' can be
considered as documentation -- we want sign-extension here.

> There seems to be 150+ such cases in the kernel source though - weird.
> 
> More importantly, how does this improve things on 32-bit PAE kernels? If I follow 
> the values correctly then PMD_PAGE_MASK is 'UL' i.e. 32-bit:
> 
> > +#define PMD_PAGE_SIZE                (_AC(1, UL) << PMD_SHIFT)
> > +#define PMD_PAGE_MASK                (~(PMD_PAGE_SIZE-1))
> 
> thus PHYSICAL_PMD_PAGE_MASK is 32-bit too:
> 
> > +#define PHYSICAL_PMD_PAGE_MASK       (((signed long)PMD_PAGE_MASK) & __PHYSICAL_MASK)
> 
> so how is the bug fixed?

Again, see the comment.
I've checked that it generates correct value (using kernel/bounds.c).

-- 
 Kirill A. Shutemov
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-10 00:20 +0100
  Re: [PATCH] x86/mm: fix regression with huge pages on PAE Toshi Kani <toshi.kani@hpe.com> - 2015-11-10 00:50 +0100
    Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-10 01:00 +0100
      Re: [PATCH] x86/mm: fix regression with huge pages on PAE Toshi Kani <toshi.kani@hpe.com> - 2015-11-10 01:20 +0100
  Re: [PATCH] x86/mm: fix regression with huge pages on PAE Borislav Petkov <bp@alien8.de> - 2015-11-10 13:50 +0100
    Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-10 15:00 +0100
      Re: [PATCH] x86/mm: fix regression with huge pages on PAE Borislav Petkov <bp@alien8.de> - 2015-11-10 15:50 +0100
        Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-10 16:10 +0100
          Re: [PATCH] x86/mm: fix regression with huge pages on PAE Borislav Petkov <bp@alien8.de> - 2015-11-10 18:10 +0100
            Re: [PATCH] x86/mm: fix regression with huge pages on PAE Borislav Petkov <bp@alien8.de> - 2015-11-11 11:00 +0100
              Re: [PATCH] x86/mm: fix regression with huge pages on PAE Ingo Molnar <mingo@kernel.org> - 2015-11-12 08:50 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-12 09:00 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Ingo Molnar <mingo@kernel.org> - 2015-11-12 09:10 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-11-12 09:50 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Ingo Molnar <mingo@kernel.org> - 2015-11-12 10:00 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-12 10:10 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Ingo Molnar <mingo@kernel.org> - 2015-11-12 14:40 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Ingo Molnar <mingo@kernel.org> - 2015-11-12 10:00 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Linus Torvalds <torvalds@linux-foundation.org> - 2015-11-12 20:30 +0100
                Re: [PATCH] x86/mm: fix regression with huge pages on PAE Dan Williams <dan.j.williams@gmail.com> - 2015-11-13 10:10 +0100

csiph-web