* [PATCH] hugetlb: Add guard support
@ 2025-11-28 11:02 Fushuai Wang
2025-11-28 11:06 ` David Hildenbrand (Red Hat)
0 siblings, 1 reply; 4+ messages in thread
From: Fushuai Wang @ 2025-11-28 11:02 UTC (permalink / raw)
To: muchun.song, osalvador, david
Cc: linux-mm, linux-kernel, wangfushuai, Fushuai Wang
Introduce guard support to simplify the usage of the
hugetlb_vma_{lock,unlock}_{read,write}.
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
include/linux/hugetlb.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 8e63e46b8e1f..f97cb2f123a3 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -15,6 +15,7 @@
#include <linux/gfp.h>
#include <linux/userfaultfd_k.h>
#include <linux/nodemask.h>
+#include <linux/cleanup.h>
struct ctl_table;
struct user_struct;
@@ -468,6 +469,13 @@ static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr)
#endif /* !CONFIG_HUGETLB_PAGE */
+DEFINE_GUARD(hugetlb_vma_read, struct vm_area_struct *,
+ hugetlb_vma_lock_read(_T), hugetlb_vma_unlock_read(_T))
+
+DEFINE_GUARD(hugetlb_vma_write, struct vm_area_struct *,
+ hugetlb_vma_lock_write(_T), hugetlb_vma_unlock_write(_T))
+DEFINE_GUARD_COND(hugetlb_vma_write, _try, hugetlb_vma_trylock_write(_T))
+
#ifndef pgd_write
static inline int pgd_write(pgd_t pgd)
{
--
2.36.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] hugetlb: Add guard support
2025-11-28 11:02 [PATCH] hugetlb: Add guard support Fushuai Wang
@ 2025-11-28 11:06 ` David Hildenbrand (Red Hat)
2025-11-28 11:23 ` Fushuai Wang
0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-28 11:06 UTC (permalink / raw)
To: Fushuai Wang, muchun.song, osalvador; +Cc: linux-mm, linux-kernel, wangfushuai
On 11/28/25 12:02, Fushuai Wang wrote:
> Introduce guard support to simplify the usage of the
> hugetlb_vma_{lock,unlock}_{read,write}.
>
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> include/linux/hugetlb.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 8e63e46b8e1f..f97cb2f123a3 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -15,6 +15,7 @@
> #include <linux/gfp.h>
> #include <linux/userfaultfd_k.h>
> #include <linux/nodemask.h>
> +#include <linux/cleanup.h>
>
> struct ctl_table;
> struct user_struct;
> @@ -468,6 +469,13 @@ static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr)
>
> #endif /* !CONFIG_HUGETLB_PAGE */
>
> +DEFINE_GUARD(hugetlb_vma_read, struct vm_area_struct *,
> + hugetlb_vma_lock_read(_T), hugetlb_vma_unlock_read(_T))
> +
> +DEFINE_GUARD(hugetlb_vma_write, struct vm_area_struct *,
> + hugetlb_vma_lock_write(_T), hugetlb_vma_unlock_write(_T))
> +DEFINE_GUARD_COND(hugetlb_vma_write, _try, hugetlb_vma_trylock_write(_T))
Do I understand correctly that the code you are introducing does not
have any users?
--
Cheers
David
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] hugetlb: Add guard support
2025-11-28 11:06 ` David Hildenbrand (Red Hat)
@ 2025-11-28 11:23 ` Fushuai Wang
2025-11-28 11:26 ` David Hildenbrand (Red Hat)
0 siblings, 1 reply; 4+ messages in thread
From: Fushuai Wang @ 2025-11-28 11:23 UTC (permalink / raw)
To: david
Cc: fushuai.wang, linux-kernel, linux-mm, muchun.song, osalvador,
wangfushuai
>> include/linux/hugetlb.h | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>> index 8e63e46b8e1f..f97cb2f123a3 100644
>> --- a/include/linux/hugetlb.h
>> +++ b/include/linux/hugetlb.h
>> @@ -15,6 +15,7 @@
>> #include <linux/gfp.h>
>> #include <linux/userfaultfd_k.h>
>> #include <linux/nodemask.h>
>> +#include <linux/cleanup.h>
>>
>> struct ctl_table;
>> struct user_struct;
>> @@ -468,6 +469,13 @@ static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr)
>>
>> #endif /* !CONFIG_HUGETLB_PAGE */
>>
>> +DEFINE_GUARD(hugetlb_vma_read, struct vm_area_struct *,
>> + hugetlb_vma_lock_read(_T), hugetlb_vma_unlock_read(_T))
>> +
>> +DEFINE_GUARD(hugetlb_vma_write, struct vm_area_struct *,
>> + hugetlb_vma_lock_write(_T), hugetlb_vma_unlock_write(_T))
>> +DEFINE_GUARD_COND(hugetlb_vma_write, _try, hugetlb_vma_trylock_write(_T))
>
> Do I understand correctly that the code you are introducing does not
> have any users?
Yes, it is not used now, but it can be used in future development to simplify
the code. If there are complex hugetlb_vma locks in the current code, this can
also be used later to optimize them.
---
Regards,
Wang.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hugetlb: Add guard support
2025-11-28 11:23 ` Fushuai Wang
@ 2025-11-28 11:26 ` David Hildenbrand (Red Hat)
0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Red Hat) @ 2025-11-28 11:26 UTC (permalink / raw)
To: Fushuai Wang; +Cc: linux-kernel, linux-mm, muchun.song, osalvador, wangfushuai
On 11/28/25 12:23, Fushuai Wang wrote:
>>> include/linux/hugetlb.h | 8 ++++++++
>>> 1 file changed, 8 insertions(+)
>>>
>>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
>>> index 8e63e46b8e1f..f97cb2f123a3 100644
>>> --- a/include/linux/hugetlb.h
>>> +++ b/include/linux/hugetlb.h
>>> @@ -15,6 +15,7 @@
>>> #include <linux/gfp.h>
>>> #include <linux/userfaultfd_k.h>
>>> #include <linux/nodemask.h>
>>> +#include <linux/cleanup.h>
>>>
>>> struct ctl_table;
>>> struct user_struct;
>>> @@ -468,6 +469,13 @@ static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr)
>>>
>>> #endif /* !CONFIG_HUGETLB_PAGE */
>>>
>>> +DEFINE_GUARD(hugetlb_vma_read, struct vm_area_struct *,
>>> + hugetlb_vma_lock_read(_T), hugetlb_vma_unlock_read(_T))
>>> +
>>> +DEFINE_GUARD(hugetlb_vma_write, struct vm_area_struct *,
>>> + hugetlb_vma_lock_write(_T), hugetlb_vma_unlock_write(_T))
>>> +DEFINE_GUARD_COND(hugetlb_vma_write, _try, hugetlb_vma_trylock_write(_T))
>>
>> Do I understand correctly that the code you are introducing does not
>> have any users?
>
> Yes, it is not used now, but it can be used in future development to simplify
> the code. If there are complex hugetlb_vma locks in the current code, this can
> also be used later to optimize them.
Right, but we usually don't add dead code. So it should ideally be
introduced with actual users.
--
Cheers
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-28 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 11:02 [PATCH] hugetlb: Add guard support Fushuai Wang
2025-11-28 11:06 ` David Hildenbrand (Red Hat)
2025-11-28 11:23 ` Fushuai Wang
2025-11-28 11:26 ` David Hildenbrand (Red Hat)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.