linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation)
@ 2016-01-18 10:09 Geert Uytterhoeven
  2016-01-18 11:40 ` Kirill A. Shutemov
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2016-01-18 10:09 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Andrea Arcangeli, Hugh Dickins, Dave Hansen,
	Mel Gorman, Rik van Riel, Vlastimil Babka, Christoph Lameter,
	Naoya Horiguchi, Steve Capper, Aneesh Kumar K.V, Johannes Weiner,
	Michal Hocko, Jerome Marchand, Sasha Levin, linux-kernel,
	Linux MM

Hi Kirill,

On Tue, Oct 6, 2015 at 5:23 PM, Kirill A. Shutemov
<kirill.shutemov@linux.intel.com> wrote:
> With new refcounting all subpages of the compound page are not necessary
> have the same mapcount. We need to take into account mapcount of every
> sub-page.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Tested-by: Sasha Levin <sasha.levin@oracle.com>
> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> Acked-by: Jerome Marchand <jmarchan@redhat.com>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  fs/proc/task_mmu.c | 47 +++++++++++++++++++++++++++++++----------------
>  1 file changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index bd167675a06f..ace02a4a07db 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -454,9 +454,10 @@ struct mem_size_stats {
>  };
>
>  static void smaps_account(struct mem_size_stats *mss, struct page *page,
> -               unsigned long size, bool young, bool dirty)
> +               bool compound, bool young, bool dirty)
>  {
> -       int mapcount;
> +       int i, nr = compound ? HPAGE_PMD_NR : 1;

If CONFIG_TRANSPARENT_HUGEPAGE is not set, we have:

    #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
    #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
    #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })

Depending on compiler version and optimization level, the BUILD_BUG() may be
optimized away (smaps_account() is always called with compound = false if
CONFIG_TRANSPARENT_HUGEPAGE=n), or lead to a build failure:

    fs/built-in.o: In function `smaps_account':
    task_mmu.c:(.text+0x4f8fa): undefined reference to
`__compiletime_assert_471'

Seen with m68k/allmodconfig or allyesconfig and gcc version 4.1.2 20061115
(prerelease) (Ubuntu 4.1.1-21).
Not seen when compiling the affected file with gcc 4.6.3 or 4.9.0, or with the
m68k defconfigs.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation)
  2016-01-18 10:09 BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation) Geert Uytterhoeven
@ 2016-01-18 11:40 ` Kirill A. Shutemov
  2016-01-18 14:56   ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Kirill A. Shutemov @ 2016-01-18 11:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kirill A. Shutemov, Andrew Morton, Andrea Arcangeli,
	Hugh Dickins, Dave Hansen, Mel Gorman, Rik van Riel,
	Vlastimil Babka, Christoph Lameter, Naoya Horiguchi,
	Steve Capper, Aneesh Kumar K.V, Johannes Weiner, Michal Hocko,
	Jerome Marchand, Sasha Levin, linux-kernel, Linux MM

On Mon, Jan 18, 2016 at 11:09:00AM +0100, Geert Uytterhoeven wrote:
> Hi Kirill,
> 
> On Tue, Oct 6, 2015 at 5:23 PM, Kirill A. Shutemov
> <kirill.shutemov@linux.intel.com> wrote:
> > With new refcounting all subpages of the compound page are not necessary
> > have the same mapcount. We need to take into account mapcount of every
> > sub-page.
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > Tested-by: Sasha Levin <sasha.levin@oracle.com>
> > Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> > Acked-by: Jerome Marchand <jmarchan@redhat.com>
> > Acked-by: Vlastimil Babka <vbabka@suse.cz>
> > ---
> >  fs/proc/task_mmu.c | 47 +++++++++++++++++++++++++++++++----------------
> >  1 file changed, 31 insertions(+), 16 deletions(-)
> >
> > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> > index bd167675a06f..ace02a4a07db 100644
> > --- a/fs/proc/task_mmu.c
> > +++ b/fs/proc/task_mmu.c
> > @@ -454,9 +454,10 @@ struct mem_size_stats {
> >  };
> >
> >  static void smaps_account(struct mem_size_stats *mss, struct page *page,
> > -               unsigned long size, bool young, bool dirty)
> > +               bool compound, bool young, bool dirty)
> >  {
> > -       int mapcount;
> > +       int i, nr = compound ? HPAGE_PMD_NR : 1;
> 
> If CONFIG_TRANSPARENT_HUGEPAGE is not set, we have:
> 
>     #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
>     #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
>     #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
> 
> Depending on compiler version and optimization level, the BUILD_BUG() may be
> optimized away (smaps_account() is always called with compound = false if
> CONFIG_TRANSPARENT_HUGEPAGE=n), or lead to a build failure:
> 
>     fs/built-in.o: In function `smaps_account':
>     task_mmu.c:(.text+0x4f8fa): undefined reference to
> `__compiletime_assert_471'
> 
> Seen with m68k/allmodconfig or allyesconfig and gcc version 4.1.2 20061115
> (prerelease) (Ubuntu 4.1.1-21).
> Not seen when compiling the affected file with gcc 4.6.3 or 4.9.0, or with the
> m68k defconfigs.

Ughh.

Please, test this:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation)
  2016-01-18 11:40 ` Kirill A. Shutemov
@ 2016-01-18 14:56   ` Geert Uytterhoeven
  2016-01-21 19:31     ` Tony Luck
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2016-01-18 14:56 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Kirill A. Shutemov, Andrew Morton, Andrea Arcangeli,
	Hugh Dickins, Dave Hansen, Mel Gorman, Rik van Riel,
	Vlastimil Babka, Christoph Lameter, Naoya Horiguchi,
	Steve Capper, Aneesh Kumar K.V, Johannes Weiner, Michal Hocko,
	Jerome Marchand, Sasha Levin, linux-kernel, Linux MM

Hi Kirill,

On Mon, Jan 18, 2016 at 12:40 PM, Kirill A. Shutemov
<kirill@shutemov.name> wrote:
> On Mon, Jan 18, 2016 at 11:09:00AM +0100, Geert Uytterhoeven wrote:
>>     fs/built-in.o: In function `smaps_account':
>>     task_mmu.c:(.text+0x4f8fa): undefined reference to
>> `__compiletime_assert_471'
>>
>> Seen with m68k/allmodconfig or allyesconfig and gcc version 4.1.2 20061115
>> (prerelease) (Ubuntu 4.1.1-21).
>> Not seen when compiling the affected file with gcc 4.6.3 or 4.9.0, or with the
>> m68k defconfigs.
>
> Ughh.
>
> Please, test this:
>
> From 5ac27019f886eef033e84c9579e09099469ccbf9 Mon Sep 17 00:00:00 2001
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Date: Mon, 18 Jan 2016 14:32:49 +0300
> Subject: [PATCH] mm, proc: add workaround for old compilers
>
> For THP=n, HPAGE_PMD_NR in smaps_account() expands to BUILD_BUG().
> That's fine since this codepath is eliminated by modern compilers.
>
> But older compilers have not that efficient dead code elimination.
> It causes problem at least with gcc 4.1.2 on m68k.
>
> Let's replace HPAGE_PMD_NR with 1 << compound_order(page).
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks, that fixes it!

Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation)
  2016-01-18 14:56   ` Geert Uytterhoeven
@ 2016-01-21 19:31     ` Tony Luck
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Luck @ 2016-01-21 19:31 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Kirill A. Shutemov, Kirill A. Shutemov, Andrew Morton,
	Andrea Arcangeli, Hugh Dickins, Dave Hansen, Mel Gorman,
	Rik van Riel, Vlastimil Babka, Christoph Lameter,
	Naoya Horiguchi, Steve Capper, Aneesh Kumar K.V, Johannes Weiner,
	Michal Hocko, Jerome Marchand, Sasha Levin, linux-kernel,
	Linux MM

On Mon, Jan 18, 2016 at 6:56 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Hi Kirill,
>
> On Mon, Jan 18, 2016 at 12:40 PM, Kirill A. Shutemov
> <kirill@shutemov.name> wrote:
>> On Mon, Jan 18, 2016 at 11:09:00AM +0100, Geert Uytterhoeven wrote:
>>>     fs/built-in.o: In function `smaps_account':
>>>     task_mmu.c:(.text+0x4f8fa): undefined reference to
>>> `__compiletime_assert_471'
>>>
>>> Seen with m68k/allmodconfig or allyesconfig and gcc version 4.1.2 20061115
>>> (prerelease) (Ubuntu 4.1.1-21).
>>> Not seen when compiling the affected file with gcc 4.6.3 or 4.9.0, or with the
>>> m68k defconfigs.
>>
>> Ughh.
>>
>> Please, test this:
>>
>> From 5ac27019f886eef033e84c9579e09099469ccbf9 Mon Sep 17 00:00:00 2001
>> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>> Date: Mon, 18 Jan 2016 14:32:49 +0300
>> Subject: [PATCH] mm, proc: add workaround for old compilers
>>
>> For THP=n, HPAGE_PMD_NR in smaps_account() expands to BUILD_BUG().
>> That's fine since this codepath is eliminated by modern compilers.
>>
>> But older compilers have not that efficient dead code elimination.
>> It causes problem at least with gcc 4.1.2 on m68k.
>>
>> Let's replace HPAGE_PMD_NR with 1 << compound_order(page).
>>
>> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
>
> Thanks, that fixes it!
>
> Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>

Same breakage on ia64 (with gcc 4.3.4).  Same fix works for me.

Tested-by: Tony Luck <tony.luck@intel.com>

--
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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-21 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 10:09 BUILD_BUG() in smaps_account() (was: Re: [PATCHv12 01/37] mm, proc: adjust PSS calculation) Geert Uytterhoeven
2016-01-18 11:40 ` Kirill A. Shutemov
2016-01-18 14:56   ` Geert Uytterhoeven
2016-01-21 19:31     ` Tony Luck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox