[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4469c40b-81fd-46ce-8599-0bc6c2d3160e@redhat.com>
Date: Wed, 18 Jun 2025 12:02:50 +0200
From: David Hildenbrand <david@...hat.com>
To: Vlastimil Babka <vbabka@...e.cz>, Yunshui Jiang
<jiangyunshui@...inos.cn>, linux-kernel@...r.kernel.org, linux-mm@...k.org
Cc: akpm@...ux-foundation.org, lorenzo.stoakes@...cle.com,
Liam.Howlett@...cle.com
Subject: Re: [PATCH] mm: Inline vma_needs_copy
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.
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists