public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org, hughd@google.com,
	hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
	iii@linux.ibm.com, linux-s390@vger.kernel.org,
	linux-kernel@vger.kernel.org, Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH] mm/shmem: Inline shmem_is_huge() for disabled transparent hugepages
Date: Wed, 10 Apr 2024 12:51:47 -0400	[thread overview]
Message-ID: <ZhbDoxxFAe0QQYz_@x1n> (raw)
In-Reply-To: <61a3bd6b-a352-4e02-8357-81ac7b9f2848@redhat.com>

On Wed, Apr 10, 2024 at 06:40:55PM +0200, David Hildenbrand wrote:
> On 10.04.24 18:33, Peter Xu wrote:
> > On Wed, Apr 10, 2024 at 06:12:34PM +0200, David Hildenbrand wrote:
> > > On 10.04.24 18:07, Sumanth Korikkar wrote:
> > > > On Wed, Apr 10, 2024 at 05:51:28PM +0200, David Hildenbrand wrote:
> > > > > On 10.04.24 17:26, Sumanth Korikkar wrote:
> > > > > > On Wed, Apr 10, 2024 at 02:34:35PM +0200, David Hildenbrand wrote:
> > > > > > > On 09.04.24 17:54, Sumanth Korikkar wrote:
> > > > > > > > In order to  minimize code size (CONFIG_CC_OPTIMIZE_FOR_SIZE=y),
> > > > > > > > compiler might choose to make a regular function call (out-of-line) for
> > > > > > > > shmem_is_huge() instead of inlining it. When transparent hugepages are
> > > > > > > > disabled (CONFIG_TRANSPARENT_HUGEPAGE=n), it can cause compilation
> > > > > > > > error.
> > > > > > > > 
> > > > > > > > mm/shmem.c: In function ‘shmem_getattr’:
> > > > > > > > ./include/linux/huge_mm.h:383:27: note: in expansion of macro ‘BUILD_BUG’
> > > > > > > >       383 | #define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })
> > > > > > > >           |                           ^~~~~~~~~
> > > > > > > > mm/shmem.c:1148:33: note: in expansion of macro ‘HPAGE_PMD_SIZE’
> > > > > > > >      1148 |                 stat->blksize = HPAGE_PMD_SIZE;
> > > > > > > > 
> > > > > > > > To prevent the possible error, always inline shmem_is_huge() when
> > > > > > > > transparent hugepages are disabled.
> > > > > > > > 
> > > > > > > 
> > > > > > > Do you know which commit introduced that?
> > > > > > Hi David,
> > > > > > 
> > > > > > Currently with CONFIG_CC_OPTIMIZE_FOR_SIZE=y and expirementing with
> > > > > > -fPIC kernel compiler option, I could see this error on s390.
> > > > > 
> > > > > Got it. I assume on Linus' tree, not mm/unstable?
> > > > 
> > > > It's not yet upstream.
> > > > > 
> > > > > > 
> > > > > > However, default kernel compiler options doesnt end up with the above
> > > > > > pattern right now.
> > > > > 
> > > > > Okay, just asking if this is related to recent HPAGE_PMD_SIZE changes:
> > > > > 
> > > > > commit c1a1e497a3d5711dbf8fa6d7432d6b83ec18c26f
> > > > > Author: Peter Xu <peterx@redhat.com>
> > > > > Date:   Wed Mar 27 11:23:22 2024 -0400
> > > > > 
> > > > >       mm: make HPAGE_PXD_* macros even if !THP
> > > > > 
> > > > > Which is still in mm-unstable and not upstream.
> > > > 
> > > > Not related to this commit. I tried on master branch.
> > > 
> > > Thanks! Can you try with Peters patch? (ccing Peter)
> > > 
> > > If I am not wrong, that should also resolve the issue you are seeing.
> > 
> > David,
> > 
> > Do you mean this one?
> > 
> > https://lore.kernel.org/all/20240403013249.1418299-4-peterx@redhat.com/
> > 
> 
> No, I meant:
> 
> https://lore.kernel.org/all/20240327152332.950956-4-peterx@redhat.com/
> 
> which removes the "#define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })" that we
> seem to trigger here.
> 
> 
> ... but it's been a long day, so maybe I'm all wrong :)

Ah..  So I thought it was one step further. :)

Then that shouldn't be the case; it didn't remove it but defined properly
with HPAGE_PMD_SHIFT:

+#define HPAGE_PMD_SIZE	((1UL) << HPAGE_PMD_SHIFT)

Now we even have that properly defined for HUGETLB_PAGE, while prior to
that we should hit this issue easier (even with !THP+HUGETLB_PAGE).

> 
> > That's indeed similar but that was for pud_pfn() not HPAGE_* stuff.
> > 
> > I just had a quick look, Sumanth's fix looks valid, and IIUC the goal is
> > also that we should keep these build checks around for the long term goal
> > (Jason definitely preferred that [1] too, which I agree).
> > 
> > I removed that build check there for pud_pfn just to avoid other build
> > fallouts for other archs as a temporary measure.  For this one if it's in
> > common code for a long time and if it's the single spot maybe it's nice to
> > have this patch as proposed, as it means it optimizes the if check too
> > besides fixing the build error.  After all referencing HPAGE_* with
> > !THP+!HUGETLB shouldn't happen logically.
> > 
> > [1] https://lore.kernel.org/r/20240404112404.GG1723999@nvidia.com
> > 
> > Thanks,
> > 
> 
> -- 
> Cheers,
> 
> David / dhildenb
> 

-- 
Peter Xu


  reply	other threads:[~2024-04-10 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 15:54 [PATCH] mm/shmem: Inline shmem_is_huge() for disabled transparent hugepages Sumanth Korikkar
2024-04-10 12:34 ` David Hildenbrand
2024-04-10 15:26   ` Sumanth Korikkar
2024-04-10 15:51     ` David Hildenbrand
2024-04-10 16:07       ` Sumanth Korikkar
2024-04-10 16:12         ` David Hildenbrand
2024-04-10 16:33           ` Peter Xu
2024-04-10 16:40             ` David Hildenbrand
2024-04-10 16:51               ` Peter Xu [this message]
2024-04-10 17:03                 ` David Hildenbrand

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=ZhbDoxxFAe0QQYz_@x1n \
    --to=peterx@redhat.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hughd@google.com \
    --cc=iii@linux.ibm.com \
    --cc=jgg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sumanthk@linux.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox