lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240323010528.10959-1-sj@kernel.org>
Date: Fri, 22 Mar 2024 18:05:28 -0700
From: SeongJae Park <sj@...nel.org>
To: Peter Xu <peterx@...hat.com>
Cc: SeongJae Park <sj@...nel.org>,
	linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	linuxppc-dev@...ts.ozlabs.org,
	Michael Ellerman <mpe@...erman.id.au>,
	Christophe Leroy <christophe.leroy@...roup.eu>,
	Matthew Wilcox <willy@...radead.org>,
	Rik van Riel <riel@...riel.com>,
	Lorenzo Stoakes <lstoakes@...il.com>,
	Axel Rasmussen <axelrasmussen@...gle.com>,
	Yang Shi <shy828301@...il.com>,
	John Hubbard <jhubbard@...dia.com>,
	linux-arm-kernel@...ts.infradead.org,
	"Kirill A . Shutemov" <kirill@...temov.name>,
	Andrew Jones <andrew.jones@...ux.dev>,
	Vlastimil Babka <vbabka@...e.cz>,
	Mike Rapoport <rppt@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Muchun Song <muchun.song@...ux.dev>,
	Christoph Hellwig <hch@...radead.org>,
	linux-riscv@...ts.infradead.org,
	James Houghton <jthoughton@...gle.com>,
	David Hildenbrand <david@...hat.com>,
	Jason Gunthorpe <jgg@...dia.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	"Aneesh Kumar K . V" <aneesh.kumar@...nel.org>,
	Mike Kravetz <mike.kravetz@...cle.com>
Subject: Re: [PATCH v3 03/12] mm: Make HPAGE_PXD_* macros even if !THP

Hi Peter,

On Fri, 22 Mar 2024 20:30:24 -0400 Peter Xu <peterx@...hat.com> wrote:

> On Fri, Mar 22, 2024 at 10:14:56AM -0700, SeongJae Park wrote:
> > Hi Peter,
> 
> Hi, SeongJae,
> 
> > 
> > On Thu, 21 Mar 2024 18:07:53 -0400 peterx@...hat.com wrote:
> > 
> > > From: Peter Xu <peterx@...hat.com>
> > > 
> > > These macros can be helpful when we plan to merge hugetlb code into generic
> > > code.  Move them out and define them even if !THP.
> > > 
> > > We actually already defined HPAGE_PMD_NR for other reasons even if !THP.
> > > Reorganize these macros.
> > > 
> > > Reviewed-by: Christoph Hellwig <hch@...radead.org>
> > > Reviewed-by: Jason Gunthorpe <jgg@...dia.com>
> > > Signed-off-by: Peter Xu <peterx@...hat.com>
> > > ---
> > >  include/linux/huge_mm.h | 17 ++++++-----------
> > >  1 file changed, 6 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> > > index de0c89105076..3bcdfc7e5d57 100644
> > > --- a/include/linux/huge_mm.h
> > > +++ b/include/linux/huge_mm.h
> > > @@ -64,9 +64,6 @@ ssize_t single_hugepage_flag_show(struct kobject *kobj,
> > >  				  enum transparent_hugepage_flag flag);
> > >  extern struct kobj_attribute shmem_enabled_attr;
> > >  
> > > -#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
> > > -#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
> > > -
> > >  /*
> > >   * Mask of all large folio orders supported for anonymous THP; all orders up to
> > >   * and including PMD_ORDER, except order-0 (which is not "huge") and order-1
> > > @@ -87,14 +84,19 @@ extern struct kobj_attribute shmem_enabled_attr;
> > >  #define thp_vma_allowable_order(vma, vm_flags, smaps, in_pf, enforce_sysfs, order) \
> > >  	(!!thp_vma_allowable_orders(vma, vm_flags, smaps, in_pf, enforce_sysfs, BIT(order)))
> > >  
> > > -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> > >  #define HPAGE_PMD_SHIFT PMD_SHIFT
> > >  #define HPAGE_PMD_SIZE	((1UL) << HPAGE_PMD_SHIFT)
> > >  #define HPAGE_PMD_MASK	(~(HPAGE_PMD_SIZE - 1))
> > > +#define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
> > > +#define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
> > >  
> > >  #define HPAGE_PUD_SHIFT PUD_SHIFT
> > >  #define HPAGE_PUD_SIZE	((1UL) << HPAGE_PUD_SHIFT)
> > >  #define HPAGE_PUD_MASK	(~(HPAGE_PUD_SIZE - 1))
> > > +#define HPAGE_PUD_ORDER (HPAGE_PUD_SHIFT-PAGE_SHIFT)
> > > +#define HPAGE_PUD_NR (1<<HPAGE_PUD_ORDER)
> > 
> > I just found latest mm-unstable fails one of my build configurations[1] with
> > below error.  'git bisect' says this is the first patch set started the
> > failure.  I haven't looked in deep, but just reporting first.
> > 
> >     In file included from .../include/linux/mm.h:1115,
> >                      from .../mm/vmstat.c:14:
> >     .../mm/vmstat.c: In function 'zoneinfo_show_print':
> >     .../include/linux/huge_mm.h:87:25: error: 'PMD_SHIFT' undeclared (first use in this function); did you mean 'PUD_SHIFT'?
> >        87 | #define HPAGE_PMD_SHIFT PMD_SHIFT
> >           |                         ^~~~~~~~~
> > 
> > [1] https://github.com/awslabs/damon-tests/blob/next/corr/tests/build_m68k.sh
> 
> Apologies for the issue.

No problem at all, this blocks nothing in real :)

> This is caused by !CONFIG_MMU, I think.
> 
> I thought this would be fairly easy to fix by putting these macros under
> CONFIG_PGTABLE_HAS_HUGE_LEAVES, however when doing this I could have found
> some other issue that violates this rule.. mm/vmstat.c has referenced
> HPAGE_PMD_NR even if vmstat_item_print_in_thp() wanted to guard it only
> with CONFIG_THP.
> 
> /home/peterx/git/linux/mm/vmstat.c: In function 'zoneinfo_show_print':
> /home/peterx/git/linux/mm/vmstat.c:1689:42: error: 'HPAGE_PMD_NR' undeclared (first use in this function)
>  1689 |                                 pages /= HPAGE_PMD_NR;
>       |                                          ^~~~~~~~~~~~
> /home/peterx/git/linux/mm/vmstat.c:1689:42: note: each undeclared identifier is reported only once for each function it appears in
>   CC      drivers/tty/tty_port.o
> /home/peterx/git/linux/mm/vmstat.c: In function 'vmstat_start':
> /home/peterx/git/linux/mm/vmstat.c:1822:33: error: 'HPAGE_PMD_NR' undeclared (first use in this function)
>  1822 |                         v[i] /= HPAGE_PMD_NR;
>       |                                 ^~~~~~~~~~~~
> make[4]: *** [/home/peterx/git/linux/scripts/Makefile.build:243: mm/vmstat.o] Error 1
> 
> static __always_inline bool vmstat_item_print_in_thp(enum node_stat_item item)
> {
>         if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
>                 return false;
>         ...
> }
> 
> I think the problem is vmstat_item_print_in_thp() uses IS_ENABLED() however
> that won't stop compiler from looking into the "if".. so it'll still try to
> find the HPAGE_PMD_NR macro.
> 
> It means, I may need to further change vmstat_item_print_in_thp() to make
> this work in the clean way.. by properly switching to a #ifdef.
> 
> For that I'll need to post a formal patch and add people to review.  I'll
> keep you posted.

Thank you for this kind explanation, all makes sense to me.  Looking forward to
the patch.

> 
> Side note: thank you for your script, just to mention make.cross has been
> moved to kbuild/, and it'll also need kbuild.sh now to work.  So you may
> want to fix your test script (and it worked for you because you kept the
> old make.cross around), like:
> 
>   wget https://raw.githubusercontent.com/intel/lkp-tests/master/kbuild/make.cross -O ./bin/make.cross
>   wget https://raw.githubusercontent.com/intel/lkp-tests/master/kbuild/kbuild.sh -O ./bin/kbuild.sh

And thank you so much for this nice suggestion.  I'll revisit the script soon.


Thanks,
SJ

> 
> Thanks,
> 
> -- 
> Peter Xu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ