All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Ingo Molnar <mingo@kernel.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>,
	hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, x86@kernel.org, jgross@suse.com,
	konrad.wilk@oracle.com, elliott@hpe.com,
	boris.ostrovsky@oracle.com, Toshi Kani <toshi.kani@hpe.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] x86/mm: fix regression with huge pages on PAE
Date: Thu, 12 Nov 2015 11:00:19 +0200	[thread overview]
Message-ID: <20151112090018.GA22481@node.shutemov.name> (raw)
In-Reply-To: <20151112085418.GA18963@gmail.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Ingo Molnar <mingo@kernel.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>,
	hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, x86@kernel.org, jgross@suse.com,
	konrad.wilk@oracle.com, elliott@hpe.com,
	boris.ostrovsky@oracle.com, Toshi Kani <toshi.kani@hpe.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] x86/mm: fix regression with huge pages on PAE
Date: Thu, 12 Nov 2015 11:00:19 +0200	[thread overview]
Message-ID: <20151112090018.GA22481@node.shutemov.name> (raw)
In-Reply-To: <20151112085418.GA18963@gmail.com>

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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2015-11-12  9:00 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09 23:18 [PATCH] x86/mm: fix regression with huge pages on PAE Kirill A. Shutemov
2015-11-09 23:18 ` Kirill A. Shutemov
2015-11-09 23:43 ` Toshi Kani
2015-11-09 23:43   ` Toshi Kani
2015-11-09 23:57   ` Kirill A. Shutemov
2015-11-09 23:57     ` Kirill A. Shutemov
2015-11-10  0:12     ` Toshi Kani
2015-11-10  0:12       ` Toshi Kani
2015-11-10 12:34 ` Borislav Petkov
2015-11-10 12:34   ` Borislav Petkov
2015-11-10 13:53   ` Kirill A. Shutemov
2015-11-10 13:53     ` Kirill A. Shutemov
2015-11-10 14:46     ` Borislav Petkov
2015-11-10 14:46       ` Borislav Petkov
2015-11-10 15:07       ` Kirill A. Shutemov
2015-11-10 15:07         ` Kirill A. Shutemov
2015-11-10 17:04         ` Borislav Petkov
2015-11-10 17:04           ` Borislav Petkov
2015-11-11  9:51           ` Borislav Petkov
2015-11-11  9:51             ` Borislav Petkov
2015-11-12  7:48             ` Ingo Molnar
2015-11-12  7:48               ` Ingo Molnar
2015-11-12  7:57               ` Kirill A. Shutemov
2015-11-12  7:57                 ` Kirill A. Shutemov
2015-11-12  8:00                 ` Ingo Molnar
2015-11-12  8:00                   ` Ingo Molnar
2015-11-12  8:46                   ` Kirill A. Shutemov
2015-11-12  8:46                     ` Kirill A. Shutemov
2015-11-12  8:54                     ` Ingo Molnar
2015-11-12  8:54                       ` Ingo Molnar
2015-11-12  9:00                       ` Kirill A. Shutemov [this message]
2015-11-12  9:00                         ` Kirill A. Shutemov
2015-11-12 13:29                         ` Ingo Molnar
2015-11-12 13:29                           ` Ingo Molnar
2015-11-24 14:59                         ` Boris Ostrovsky
2015-11-24 14:59                           ` Boris Ostrovsky
2015-11-24 20:14                           ` Kirill A. Shutemov
2015-11-24 20:14                             ` Kirill A. Shutemov
2015-11-25 10:27                             ` Borislav Petkov
2015-11-25 10:27                               ` Borislav Petkov
2015-11-27 10:14                             ` Ingo Molnar
2015-11-27 10:14                               ` Ingo Molnar
2015-11-12  8:55                     ` Ingo Molnar
2015-11-12  8:55                       ` Ingo Molnar
2015-11-12 19:29                   ` Linus Torvalds
2015-11-12 19:29                     ` Linus Torvalds
2015-11-13  9:01                     ` Dan Williams
2015-11-13  9:01                       ` Dan Williams
2015-11-30 10:10 [PATCH] tip-queue 2015-11-30 Borislav Petkov
2015-11-30 10:10 ` [PATCH] x86/mm: Fix regression with huge pages on PAE Borislav Petkov

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=20151112090018.GA22481@node.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=elliott@hpe.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=toshi.kani@hpe.com \
    --cc=x86@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.