linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] mm: always inline _compound_head() with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y
@ 2024-08-20 12:22 David Hildenbrand
  2024-08-21  5:17 ` Yin Fengwei
  0 siblings, 1 reply; 2+ messages in thread
From: David Hildenbrand @ 2024-08-20 12:22 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, David Hildenbrand, kernel test robot, Andrew Morton, Peter Xu

We already force-inline page_fixed_fake_head(), page_is_fake_head()
and PageTail(), however the compiler might decide that _compound_head()
is not worthy to be inlined, because of page_fixed_fake_head().

The result is that, for example, PageAnonExclusive() now might involve
a function call when checking PageHuge(), which performs a
page_folio()->_compound_head() call. This can lead to a slight regression
of the stress-ng.clone benchmark.

This is not super-urgent to fix, but always inlining _compound_head()
seems like the obvious thing to do for this primitive, similar to the
other ones.

This change restores the slight regression and a compilation with
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y shows no relevant bloat [2]:

	add/remove: 15/14 grow/shrink: 79/87 up/down: 12836/-13917 (-1081)
	...
	Total: Before=32786363, After=32785282, chg -0.00%

[1] https://lkml.kernel.org/r/817150f2-abf7-430f-9973-540bd6cdd26f@intel.com
[2] https://lore.kernel.org/all/116e117c-2821-401d-8e62-b85cdec37f4a@redhat.com/

Fixes: c0bff412e67b ("mm: allow anon exclusive check over hugetlb tail pages")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202407301049.5051dc19-oliver.sang@intel.com
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 include/linux/page-flags.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index b753d158762fc..af58b2ad854c3 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -233,7 +233,7 @@ static __always_inline int page_is_fake_head(const struct page *page)
 	return page_fixed_fake_head(page) != page;
 }
 
-static inline unsigned long _compound_head(const struct page *page)
+static __always_inline unsigned long _compound_head(const struct page *page)
 {
 	unsigned long head = READ_ONCE(page->compound_head);
 
-- 
2.46.0



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

* Re: [PATCH v1] mm: always inline _compound_head() with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y
  2024-08-20 12:22 [PATCH v1] mm: always inline _compound_head() with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y David Hildenbrand
@ 2024-08-21  5:17 ` Yin Fengwei
  0 siblings, 0 replies; 2+ messages in thread
From: Yin Fengwei @ 2024-08-21  5:17 UTC (permalink / raw)
  To: David Hildenbrand, linux-kernel
  Cc: linux-mm, kernel test robot, Andrew Morton, Peter Xu

On 8/20/24 08:22, David Hildenbrand wrote:
> We already force-inline page_fixed_fake_head(), page_is_fake_head()
> and PageTail(), however the compiler might decide that _compound_head()
> is not worthy to be inlined, because of page_fixed_fake_head().
> 
> The result is that, for example, PageAnonExclusive() now might involve
> a function call when checking PageHuge(), which performs a
> page_folio()->_compound_head() call. This can lead to a slight regression
> of the stress-ng.clone benchmark.
> 
> This is not super-urgent to fix, but always inlining _compound_head()
> seems like the obvious thing to do for this primitive, similar to the
> other ones.
> 
> This change restores the slight regression and a compilation with
> CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y shows no relevant bloat [2]:
> 
> 	add/remove: 15/14 grow/shrink: 79/87 up/down: 12836/-13917 (-1081)
> 	...
> 	Total: Before=32786363, After=32785282, chg -0.00%
> 
> [1] https://lkml.kernel.org/r/817150f2-abf7-430f-9973-540bd6cdd26f@intel.com
> [2] https://lore.kernel.org/all/116e117c-2821-401d-8e62-b85cdec37f4a@redhat.com/
> 
> Fixes: c0bff412e67b ("mm: allow anon exclusive check over hugetlb tail pages")
> Reported-by: kernel test robot <oliver.sang@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202407301049.5051dc19-oliver.sang@intel.com
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Peter Xu <peterx@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>   include/linux/page-flags.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> index b753d158762fc..af58b2ad854c3 100644
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -233,7 +233,7 @@ static __always_inline int page_is_fake_head(const struct page *page)
>   	return page_fixed_fake_head(page) != page;
>   }
>   
> -static inline unsigned long _compound_head(const struct page *page)
> +static __always_inline unsigned long _compound_head(const struct page *page)
>   {
>   	unsigned long head = READ_ONCE(page->compound_head);
>   
Tested-by: Yin Fengwei <fengwei.yin@intel.com>


Regards
Yin, Fengwei



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

end of thread, other threads:[~2024-08-21  5:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-20 12:22 [PATCH v1] mm: always inline _compound_head() with CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP=y David Hildenbrand
2024-08-21  5:17 ` Yin Fengwei

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