hugetlb: Add guard support
Subsystems (2)
PATCH 1/1 hugetlb: Add guard support
Introduce guard support to simplify the usage of the hugetlb_vma_{lock,unlock}_{read,write}.
--- include/linux/hugetlb.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/linux/hugetlb.h +8 -0
@@ -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_writestatic inline int pgd_write (pgd_t pgd) {
Signature · 1 line
2.36.1
David Hildenbrand (Red Hat)
reviewerQuoted 21 lines · Fushuai Wang
Introduce guard support to simplify the usage of the hugetlb_vma_{lock,unlock}_{read,write}.
Signed-off-by Fushuai Wang <[email protected]>--- include/linux/hugetlb.h | 8 ++++++++ 1 file changed, 8 insertions(+)include/linux/hugetlb.h +1
-0@@ -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 ;
include/linux/hugetlb.h static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr) · line 477
Quoted 9 lines
include/linux/hugetlb.h +6
-0@@ -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?
Signature · 3 lines
Cheers David
Quoted 19 lines
Quoted 19 lines
include/linux/hugetlb.h | 8 ++++++++ 1 file changed, 8 insertions(+)include/linux/hugetlb.h +1
-0@@ -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 */
Quoted 9 lines
include/linux/hugetlb.h static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr) · line 477
Quoted 6 lines
include/linux/hugetlb.h +6
-0+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.
David Hildenbrand (Red Hat)
reviewerQuoted 29 lines · Fushuai Wang
Quoted 19 lines
Quoted 19 lines
include/linux/hugetlb.h | 8 ++++++++ 1 file changed, 8 insertions(+)include/linux/hugetlb.h +1
-0@@ -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 */ Quoted 9 lines
include/linux/hugetlb.h static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr) · line 477
Quoted 6 lines
include/linux/hugetlb.h +6
-0+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?
Quoted 3 lines
Yes, it is not used now, but it can be used in future development to simplify the code. If there are complex
hugetlb_vmalocks 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.
Signature · 3 lines
Cheers David