[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6otznlgh567keer6aj2jcfbzgvf2hmfxd2nhfp6qnv53yh3upf@iq73dot6ec5o>
Date: Wed, 18 Jun 2025 10:54:28 -0400
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: David Hildenbrand <david@...hat.com>
Cc: Vlastimil Babka <vbabka@...e.cz>, Yunshui Jiang <jiangyunshui@...inos.cn>,
linux-kernel@...r.kernel.org, linux-mm@...k.org,
akpm@...ux-foundation.org, lorenzo.stoakes@...cle.com
Subject: Re: [PATCH] mm: Inline vma_needs_copy
* David Hildenbrand <david@...hat.com> [250618 06:03]:
> On 18.06.25 11:39, Vlastimil Babka wrote:
> > On 6/18/25 3:42 AM, Yunshui Jiang wrote:
> > > From: jiangyunshui <jiangyunshui@...inos.cn>
> > >
> > > Since commit bcd51a3c679d ("hugetlb: lazy page table copies
> > > in fork()"), the logic about judging whether to copy
> > > page table inside func copy_page_range has been extracted
> > > into a separate func vma_needs_copy. While this change
> > > improves code readability, it also incurs more function call
> > > overhead, especially where fork() were frequently called.
> > >
> > > Inline func vma_needs_copy to optimize the copy_page_range
> > > performance. Given that func vma_needs_copy is only called
> > > by copy_page_range, inlining it would not cause unacceptable
> > > code bloat.
> >
> > I'm surprised the compiler doesn't inline it already, if there's a
> > single caller. In fact, mine (gcc-14.3 on x86) already does.
>
> Same here
>
> gcc (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2)
> >
> > So I wonder to which extent should we force override wrong compiler
> > heuristics?
>
> I think only where we (a) really know better (b) it's crucial for
> performance and (c) modern compilers don't do the right thing.
>
> > Maybe just inline instead of __always_inline would be OK? Is
> > that enough of a hint for your compiler?
>
> I would do the same thing (inline as a hint), but some people apparently
> recently argued that newer compiler mostly ignore it either way. At least
> that's what I recall.
I have seen inline ignored, but not with a single caller. Perhaps
godbolt could find a reason this is necessary, otherwise we should just
leave it, IMO.
Cheers,
Liam
Powered by blists - more mailing lists