* [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
@ 2025-10-08 21:26 Gregory Price
2025-10-08 21:26 ` [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group Gregory Price
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Gregory Price @ 2025-10-08 21:26 UTC (permalink / raw)
To: linux-mm; +Cc: muchun.song, osalvador, david, linux-kernel
Simplify if-true-return-true-else-false logic.
Signed-off-by: Gregory Price <gourry@gourry.net>
---
include/linux/hugetlb.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 526d27e88b3b..b030850975ef 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -876,12 +876,9 @@ static inline void folio_clear_hugetlb_hwpoison(struct folio *folio)
#ifndef arch_hugetlb_migration_supported
static inline bool arch_hugetlb_migration_supported(struct hstate *h)
{
- if ((huge_page_shift(h) == PMD_SHIFT) ||
+ return ((huge_page_shift(h) == PMD_SHIFT) ||
(huge_page_shift(h) == PUD_SHIFT) ||
- (huge_page_shift(h) == PGDIR_SHIFT))
- return true;
- else
- return false;
+ (huge_page_shift(h) == PGDIR_SHIFT));
}
#endif
#else
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group
2025-10-08 21:26 [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Gregory Price
@ 2025-10-08 21:26 ` Gregory Price
2025-10-13 8:08 ` Oscar Salvador
2025-10-13 8:06 ` [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Oscar Salvador
2025-10-13 8:10 ` David Hildenbrand
2 siblings, 1 reply; 7+ messages in thread
From: Gregory Price @ 2025-10-08 21:26 UTC (permalink / raw)
To: linux-mm; +Cc: muchun.song, osalvador, david, linux-kernel
sysctl bits are mostly-read values.
Signed-off-by: Gregory Price <gourry@gourry.net>
---
include/linux/hugetlb.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index b030850975ef..7ea667d4ad5e 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -172,7 +172,7 @@ bool hugetlbfs_pagecache_present(struct hstate *h,
struct address_space *hugetlb_folio_mapping_lock_write(struct folio *folio);
-extern int sysctl_hugetlb_shm_group;
+extern int sysctl_hugetlb_shm_group __read_mostly;
extern struct list_head huge_boot_pages[MAX_NUMNODES];
void hugetlb_bootmem_alloc(void);
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
2025-10-08 21:26 [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Gregory Price
2025-10-08 21:26 ` [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group Gregory Price
@ 2025-10-13 8:06 ` Oscar Salvador
2025-10-13 8:10 ` David Hildenbrand
2 siblings, 0 replies; 7+ messages in thread
From: Oscar Salvador @ 2025-10-13 8:06 UTC (permalink / raw)
To: Gregory Price; +Cc: linux-mm, muchun.song, david, linux-kernel
On Wed, Oct 08, 2025 at 05:26:13PM -0400, Gregory Price wrote:
> Simplify if-true-return-true-else-false logic.
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group
2025-10-08 21:26 ` [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group Gregory Price
@ 2025-10-13 8:08 ` Oscar Salvador
0 siblings, 0 replies; 7+ messages in thread
From: Oscar Salvador @ 2025-10-13 8:08 UTC (permalink / raw)
To: Gregory Price; +Cc: linux-mm, muchun.song, david, linux-kernel
On Wed, Oct 08, 2025 at 05:26:14PM -0400, Gregory Price wrote:
> sysctl bits are mostly-read values.
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
Acked-by: Oscar Salvador <osalvador@suse.de>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
2025-10-08 21:26 [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Gregory Price
2025-10-08 21:26 ` [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group Gregory Price
2025-10-13 8:06 ` [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Oscar Salvador
@ 2025-10-13 8:10 ` David Hildenbrand
2025-10-20 16:14 ` Gregory Price
2 siblings, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2025-10-13 8:10 UTC (permalink / raw)
To: Gregory Price, linux-mm; +Cc: muchun.song, osalvador, linux-kernel
On 08.10.25 23:26, Gregory Price wrote:
> Simplify if-true-return-true-else-false logic.
>
> Signed-off-by: Gregory Price <gourry@gourry.net>
> ---
> include/linux/hugetlb.h | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 526d27e88b3b..b030850975ef 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -876,12 +876,9 @@ static inline void folio_clear_hugetlb_hwpoison(struct folio *folio)
> #ifndef arch_hugetlb_migration_supported
> static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> {
> - if ((huge_page_shift(h) == PMD_SHIFT) ||
> + return ((huge_page_shift(h) == PMD_SHIFT) ||
> (huge_page_shift(h) == PUD_SHIFT) ||
> - (huge_page_shift(h) == PGDIR_SHIFT))
> - return true;
> - else
> - return false;
> + (huge_page_shift(h) == PGDIR_SHIFT));
switch (huge_page_shift(h)) {
case PMD_SHIFT:
case PUD_SHIFT:
case PGDIR_SHIFT:
return true;
default:
return false;
}
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
2025-10-13 8:10 ` David Hildenbrand
@ 2025-10-20 16:14 ` Gregory Price
2025-10-20 18:15 ` David Hildenbrand
0 siblings, 1 reply; 7+ messages in thread
From: Gregory Price @ 2025-10-20 16:14 UTC (permalink / raw)
To: David Hildenbrand; +Cc: linux-mm, muchun.song, osalvador, linux-kernel
On Mon, Oct 13, 2025 at 10:10:05AM +0200, David Hildenbrand wrote:
> On 08.10.25 23:26, Gregory Price wrote:
> > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> > index 526d27e88b3b..b030850975ef 100644
> > --- a/include/linux/hugetlb.h
> > +++ b/include/linux/hugetlb.h
> > @@ -876,12 +876,9 @@ static inline void folio_clear_hugetlb_hwpoison(struct folio *folio)
> > #ifndef arch_hugetlb_migration_supported
> > static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> > {
> > - if ((huge_page_shift(h) == PMD_SHIFT) ||
> > + return ((huge_page_shift(h) == PMD_SHIFT) ||
> > (huge_page_shift(h) == PUD_SHIFT) ||
> > - (huge_page_shift(h) == PGDIR_SHIFT))
> > - return true;
> > - else
> > - return false;
> > + (huge_page_shift(h) == PGDIR_SHIFT));
>
> switch (huge_page_shift(h)) {
> case PMD_SHIFT:
> case PUD_SHIFT:
> case PGDIR_SHIFT:
PGDIR_SHIFT is not a constant on x86.
~Gregory
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported
2025-10-20 16:14 ` Gregory Price
@ 2025-10-20 18:15 ` David Hildenbrand
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2025-10-20 18:15 UTC (permalink / raw)
To: Gregory Price; +Cc: linux-mm, muchun.song, osalvador, linux-kernel
On 20.10.25 18:14, Gregory Price wrote:
> On Mon, Oct 13, 2025 at 10:10:05AM +0200, David Hildenbrand wrote:
>> On 08.10.25 23:26, Gregory Price wrote:
>>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>>> index 526d27e88b3b..b030850975ef 100644
>>> --- a/include/linux/hugetlb.h
>>> +++ b/include/linux/hugetlb.h
>>> @@ -876,12 +876,9 @@ static inline void folio_clear_hugetlb_hwpoison(struct folio *folio)
>>> #ifndef arch_hugetlb_migration_supported
>>> static inline bool arch_hugetlb_migration_supported(struct hstate *h)
>>> {
>>> - if ((huge_page_shift(h) == PMD_SHIFT) ||
>>> + return ((huge_page_shift(h) == PMD_SHIFT) ||
>>> (huge_page_shift(h) == PUD_SHIFT) ||
>>> - (huge_page_shift(h) == PGDIR_SHIFT))
>>> - return true;
>>> - else
>>> - return false;
>>> + (huge_page_shift(h) == PGDIR_SHIFT));
>>
>> switch (huge_page_shift(h)) {
>> case PMD_SHIFT:
>> case PUD_SHIFT:
>> case PGDIR_SHIFT:
>
> PGDIR_SHIFT is not a constant on x86.
Ah, probably because of 4 vs. 5 level page tables. On x86 the check
doesn't even make any sense as we don't support PGD-sized pages.
If we could rule that out at compile time, it would be nice. But I don't
think we have a way to test that support at compile time.
But anyhow, nothing against what we have in this patch here
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers
David / dhildenb
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-10-20 18:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-08 21:26 [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Gregory Price
2025-10-08 21:26 ` [PATCH 2/2] hugetlb: add __read_mostly to sysctl_hugetlb_shm_group Gregory Price
2025-10-13 8:08 ` Oscar Salvador
2025-10-13 8:06 ` [PATCH 1/2] hugetlb.h: flatten logic in arch_hugetlb_migration_supported Oscar Salvador
2025-10-13 8:10 ` David Hildenbrand
2025-10-20 16:14 ` Gregory Price
2025-10-20 18:15 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox