hugetlbfs: close race between MADV_DONTNEED and page fault
Subsystems (6)
v2 cover hugetlbfs: close race between MADV_DONTNEED and page fault
v2: fix the locking bug found with the libhugetlbfs tests.
Malloc libraries, like jemalloc and tcalloc, take decisions on when to call madvise independently from the code in the main application.
This sometimes results in the application page faulting on an address, right after the malloc library has shot down the backing memory with MADV_DONTNEED.
Usually this is harmless, because we always have some 4kB pages sitting around to satisfy a page fault. However, with hugetlbfs systems often allocate only the exact number of huge pages that the application wants.
Due to TLB batching, hugetlbfs MADV_DONTNEED will free pages outside of any lock taken on the page fault path, which can open up the following race condition:
CPU 1 CPU 2
MADV_DONTNEED
unmap page
shoot down TLB entry
page fault
fail to allocate a huge page killed with SIGBUS
free page
Fix that race by extending the hugetlb_vma_lock locking scheme to also cover private hugetlb mappings (with resv_map), and pulling the locking from __unmap_hugepage_final_range into helper functions called from zap_page_range_single. This ensures page faults stay locked out of the MADV_DONTNEED VMA until the huge pages have actually been freed.
The third patch in the series is more of an RFC. Using the invalidate_lock instead of the hugetlb_vma_lock greatly simplifies the code, but at the cost of turning a per-VMA lock into a lock per backing hugetlbfs file, which could slow things down when multiple processes are mapping the same hugetlbfs file.
PATCH v2 1/3 hugetlbfs: extend hugetlb_vma_lock to private VMAs
From: Rik van Riel <[email protected]>
Extend the locking scheme used to protect shared hugetlb mappings from truncate vs page fault races, in order to protect private hugetlb mappings (with resv_map) against MADV_DONTNEED.
Add a read-write semaphore to the resv_map data structure, and use that from the hugetlb_vma_(un)lock_* functions, in preparation for closing the race between MADV_DONTNEED and page faults.
--- include/linux/hugetlb.h | 6 ++++++ mm/hugetlb.c | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 4 deletions(-)
include/linux/hugetlb.h +6 -0
@@ -60,6 +60,7 @@ struct resv_map {long adds_in_progress;struct list_head region_cache;long region_cache_count; +struct rw_semaphore rw_sema;#ifdef CONFIG_CGROUP_HUGETLB /* * On private mappings, the counter to uncharge reservations is stored
@@ -1231,6 +1232,11 @@ static inline bool __vma_shareable_lock(struct vm_area_struct *vma)return (vma->vm_flags &VM_MAYSHARE ) && vma->vm_private_data; } +static inline bool __vma_private_lock (struct vm_area_struct *vma) +{ +return (!(vma->vm_flags &VM_MAYSHARE )) && vma->vm_private_data; +} +/* * Safe version of huge_pte_offset() to check the locks. See comments * above huge_pte_offset().
mm/hugetlb.c +37 -4
96 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH v2 2/3 hugetlbfs: close race between MADV_DONTNEED and page fault
In reply to [email protected]From: Rik van Riel <[email protected]>
Malloc libraries, like jemalloc and tcalloc, take decisions on when to call madvise independently from the code in the main application.
This sometimes results in the application page faulting on an address, right after the malloc library has shot down the backing memory with MADV_DONTNEED.
Usually this is harmless, because we always have some 4kB pages sitting around to satisfy a page fault. However, with hugetlbfs systems often allocate only the exact number of huge pages that the application wants.
Due to TLB batching, hugetlbfs MADV_DONTNEED will free pages outside of any lock taken on the page fault path, which can open up the following race condition:
CPU 1 CPU 2
MADV_DONTNEED
unmap page
shoot down TLB entry
page fault
fail to allocate a huge page killed with SIGBUS
free page
Fix that race by pulling the locking from __unmap_hugepage_final_range into helper functions called from zap_page_range_single. This ensures page faults stay locked out of the MADV_DONTNEED VMA until the huge pages have actually been freed.
--- include/linux/hugetlb.h | 35 +++++++++++++++++++++++++++++++++-- mm/hugetlb.c | 20 +++++++++++--------- mm/memory.c | 7 +++---- 3 files changed, 47 insertions(+), 15 deletions(-)
include/linux/hugetlb.h +33 -2
@@ -139,7 +139,7 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma,void unmap_hugepage_range (struct vm_area_struct *,unsigned long ,unsigned long ,struct page *,zap_flags_t ); -void __unmap_hugepage_range_final (struct mmu_gather *tlb, +void __unmap_hugepage_range (struct mmu_gather *tlb,struct vm_area_struct *vma,unsigned long start,unsigned long end,struct page *ref_page,zap_flags_t zap_flags);
@@ -246,6 +246,25 @@ int huge_pmd_unshare(struct mm_struct *mm, struct vm_area_struct *vma,void adjust_range_if_pmd_sharing_possible (struct vm_area_struct *vma,unsigned long *start,unsigned long *end); +extern void __hugetlb_zap_begin (struct vm_area_struct *vma, +unsigned long *begin,unsigned long *end); +extern void __hugetlb_zap_end (struct vm_area_struct *vma, +struct zap_details *details); + +static inline void hugetlb_zap_begin (struct vm_area_struct *vma, +unsigned long *start,unsigned long *end) +{ +if (is_vm_hugetlb_page (vma)) +__hugetlb_zap_begin (vma, start, end); +} + +static inline void hugetlb_zap_end (struct vm_area_struct *vma, +struct zap_details *details) +{ +if (is_vm_hugetlb_page (vma)) +__hugetlb_zap_end (vma, details); +} +void hugetlb_vma_lock_read (struct vm_area_struct *vma);void hugetlb_vma_unlock_read (struct vm_area_struct *vma);void hugetlb_vma_lock_write (struct vm_area_struct *vma);
@@ -297,6 +316,18 @@ static inline void adjust_range_if_pmd_sharing_possible( { } +static inline void hugetlb_zap_begin ( +struct vm_area_struct *vma, +unsigned long *start,unsigned long *end) +{ +} + +static inline void hugetlb_zap_end ( +struct vm_area_struct *vma, +struct zap_details *details) +{ +} +static inline struct page *hugetlb_follow_page_mask (struct vm_area_struct *vma,unsigned long address,unsigned int flags,unsigned int *page_mask)
@@ -442,7 +473,7 @@ static inline long hugetlb_change_protection(return 0 ; } -static inline void __unmap_hugepage_range_final (struct mmu_gather *tlb, +static inline void __unmap_hugepage_range (struct mmu_gather *tlb,struct vm_area_struct *vma,unsigned long start,unsigned long end,struct page *ref_page,zap_flags_t zap_flags)
mm/hugetlb.c +11 -9
@@ -5306,9 +5306,9 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma,return len + old_addr - old_end; } -static void __unmap_hugepage_range (struct mmu_gather *tlb,struct vm_area_struct *vma, -unsigned long start,unsigned long end, -struct page *ref_page,zap_flags_t zap_flags) +void __unmap_hugepage_range (struct mmu_gather *tlb,struct vm_area_struct *vma, +unsigned long start,unsigned long end, +struct page *ref_page,zap_flags_t zap_flags) {struct mm_struct *mm = vma->vm_mm;unsigned long address;
@@ -5435,16 +5435,18 @@ static void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_structtlb_flush_mmu_tlbonly (tlb); } -void __unmap_hugepage_range_final (struct mmu_gather *tlb, -struct vm_area_struct *vma,unsigned long start, -unsigned long end,struct page *ref_page, -zap_flags_t zap_flags) +void __hugetlb_zap_begin (struct vm_area_struct *vma, +unsigned long *start,unsigned long *end) { +adjust_range_if_pmd_sharing_possible (vma, start, end);hugetlb_vma_lock_write (vma);i_mmap_lock_write (vma->vm_file->f_mapping); +} -/* mmu notification performed in caller */ -__unmap_hugepage_range (tlb, vma, start, end, ref_page, zap_flags); +void __hugetlb_zap_end (struct vm_area_struct *vma, +struct zap_details *details) +{ +zap_flags_t zap_flags = details ? details->zap_flags :0 ;if (zap_flags &ZAP_FLAG_UNMAP ) {/* final unmap */ /*
mm/memory.c +3 -4
@@ -1683,7 +1683,7 @@ static void unmap_single_vma(struct mmu_gather *tlb,if (vma->vm_file) {zap_flags_t zap_flags = details ? details->zap_flags :0 ; -__unmap_hugepage_range_final (tlb, vma, start, end, +__unmap_hugepage_range (tlb, vma, start, end,NULL , zap_flags); } }else
@@ -1753,9 +1753,7 @@ void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,lru_add_drain ();mmu_notifier_range_init (&range,MMU_NOTIFY_CLEAR ,0 , vma->vm_mm, address, end); -if (is_vm_hugetlb_page (vma)) -adjust_range_if_pmd_sharing_possible (vma, &range.start, - &range.end); +hugetlb_zap_begin (vma, &range.start, &range.end);tlb_gather_mmu (&tlb, vma->vm_mm);update_hiwater_rss (vma->vm_mm);mmu_notifier_invalidate_range_start (&range);
@@ -1766,6 +1764,7 @@ void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,unmap_single_vma (&tlb, vma, address, end, details, false);mmu_notifier_invalidate_range_end (&range);tlb_finish_mmu (&tlb); +hugetlb_zap_end (vma, details); }/**
Signature · 1 line
2.41.0
PATCH v2 3/3 hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
In reply to [email protected]From: Rik van Riel <[email protected]>
Replace the custom hugetlbfs VMA locking code with the recently introduced invalidate_lock. This greatly simplifies things.
However, this is a large enough change that it should probably go in separately from the other changes.
--- fs/hugetlbfs/inode.c | 68 +----------- include/linux/fs.h | 6 + include/linux/hugetlb.h | 7 -- kernel/fork.c | 6 - mm/hugetlb.c | 238 +++------------------------------------- 5 files changed, 26 insertions(+), 299 deletions(-)
fs/hugetlbfs/inode.c +5 -63
@@ -485,7 +485,6 @@ static void hugetlb_unmap_file_folio(struct hstate *h, struct folio *folio, pgoff_t index) {struct rb_root_cached *root = &mapping->i_mmap; -struct hugetlb_vma_lock *vma_lock;struct page *page = &folio->page;struct vm_area_struct *vma;unsigned long v_start;
@@ -496,8 +495,8 @@ static void hugetlb_unmap_file_folio(struct hstate *h, end = (index +1 ) *pages_per_huge_page (h);i_mmap_lock_write (mapping); -retry: - vma_lock =NULL ; +filemap_invalidate_lock (mapping); + vma_interval_tree_foreach(vma, root, start, end - 1) { v_start =vma_offset_start (vma, start); v_end =vma_offset_end (vma, end);
@@ -505,62 +504,13 @@ static void hugetlb_unmap_file_folio(struct hstate *h,if (!hugetlb_vma_maps_page (vma, v_start, page))continue ; -if (!hugetlb_vma_trylock_write (vma)) { - vma_lock = vma->vm_private_data; -/* -* If we can not get vma lock, we need to drop -* immap_sema and take locks in order. First, -* take a ref on the vma_lock structure so that -* we can be guaranteed it will not go away when -* dropping immap_sema. -*/ -kref_get (&vma_lock->refs); -break ; - } -unmap_hugepage_range (vma, v_start, v_end,NULL ,ZAP_FLAG_DROP_MARKER );hugetlb_vma_unlock_write (vma); } +filemap_invalidate_unlock (mapping);i_mmap_unlock_write (mapping); - -if (vma_lock) { -/* -* Wait on vma_lock. We know it is still valid as we have -* a reference. We must 'open code' vma locking as we do -* not know if vma_lock is still attached to vma. -*/ -down_write (&vma_lock->rw_sema); -i_mmap_lock_write (mapping); - - vma = vma_lock->vma; -if (!vma) { -/* -* If lock is no longer attached to vma, then just -* unlock, drop our reference and retry looking for -* other vmas. -*/ -up_write (&vma_lock->rw_sema); -kref_put (&vma_lock->refs, hugetlb_vma_lock_release); - goto retry; - } - -/* -* vma_lock is still attached to vma. Check to see if vma -* still maps page and if so, unmap. -*/ - v_start =vma_offset_start (vma, start); - v_end =vma_offset_end (vma, end); -if (hugetlb_vma_maps_page (vma, v_start, page)) -unmap_hugepage_range (vma, v_start, v_end,NULL , -ZAP_FLAG_DROP_MARKER ); - -kref_put (&vma_lock->refs, hugetlb_vma_lock_release); -hugetlb_vma_unlock_write (vma); - - goto retry; - } } static void
@@ -578,20 +528,10 @@ hugetlb_vmdelete_list(struct rb_root_cached *root, pgoff_t start, pgoff_t end,unsigned long v_start;unsigned long v_end; -if (!hugetlb_vma_trylock_write (vma)) -continue ; - v_start =vma_offset_start (vma, start); v_end =vma_offset_end (vma, end);unmap_hugepage_range (vma, v_start, v_end,NULL , zap_flags); - -/* -* Note that vma lock only exists for shared/non-private -* vmas. Therefore, lock is not held when calling -* unmap_hugepage_range for private vmas. -*/ -hugetlb_vma_unlock_write (vma); } }
@@ -726,9 +666,11 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)i_size_write (inode, offset);i_mmap_lock_write (mapping); +filemap_invalidate_lock (mapping);if (!RB_EMPTY_ROOT (&mapping->i_mmap.rb_root))hugetlb_vmdelete_list (&mapping->i_mmap, pgoff,0 ,ZAP_FLAG_DROP_MARKER ); +filemap_invalidate_unlock (mapping);i_mmap_unlock_write (mapping);remove_inode_hugepages (inode, offset,LLONG_MAX ); }
include/linux/fs.h +6 -0
@@ -847,6 +847,12 @@ static inline void filemap_invalidate_lock(struct address_space *mapping)down_write (&mapping->invalidate_lock); } +static inline int filemap_invalidate_trylock ( +struct address_space *mapping) +{ +return down_write_trylock (&mapping->invalidate_lock); +} +static inline void filemap_invalidate_unlock (struct address_space *mapping) {up_write (&mapping->invalidate_lock);
include/linux/hugetlb.h +0 -7
@@ -60,7 +60,6 @@ struct resv_map {long adds_in_progress;struct list_head region_cache;long region_cache_count; -struct rw_semaphore rw_sema;#ifdef CONFIG_CGROUP_HUGETLB /* * On private mappings, the counter to uncharge reservations is stored
@@ -107,12 +106,6 @@ struct file_region {#endif }; -struct hugetlb_vma_lock { -struct kref refs; -struct rw_semaphore rw_sema; -struct vm_area_struct *vma; -}; -extern struct resv_map *resv_map_alloc (void );void resv_map_release (struct kref *ref);
kernel/fork.c +0 -6
@@ -743,12 +743,6 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,i_mmap_unlock_write (mapping); } -/* -* Copy/update hugetlb private vma information. -*/ -if (is_vm_hugetlb_page (tmp)) -hugetlb_dup_vma_private (tmp); -/* Link the vma into the MT */ if (vma_iter_bulk_store (&vmi, tmp)) goto fail_nomem_vmi_store;
mm/hugetlb.c +15 -223
336 lines not on this page · raw message
Signature · 1 line
2.41.0
kernel test robot
build botRe: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
kernel test robot noticed the following build errors:
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.6-rc2 next-20230921] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/riel-surriel-com/hugetlbfs-extend-hugetlb_vma_lock-to-private-VMAs/20230923-030756 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230922190552.3963067-4-riel%40surriel.com patch subject: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock config: i386-buildonly-randconfig-004-20230924 (https://download.01.org/0day-ci/archive/20230924/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230924/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/x86/include/asm/bug.h:87,
from include/linux/bug.h:5,
from include/linux/jump_label.h:256,
from include/linux/static_key.h:1,
from arch/x86/include/asm/nospec-branch.h:6,
from arch/x86/include/asm/irqflags.h:9,
from include/linux/irqflags.h:17,
from include/linux/rcupdate.h:26,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/audit.h:12,
from security/commoncap.c:6:
include/linux/hugetlb.h: In function 'hugetlb_walk':
>> include/linux/hugetlb.h:1285:56: error: invalid use of undefined type 'struct hugetlb_vma_lock'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~
include/asm-generic/bug.h:168:32: note: in definition of macro 'WARN_ON'
168 | int __ret_warn_on = !!(condition); \
| ^~~~~~~~~
include/linux/hugetlb.h:1285:17: note: in expansion of macro 'WARN_ON_ONCE'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~~~~~~~~~~~
include/linux/hugetlb.h:1285:31: note: in expansion of macro 'lockdep_is_held'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~~~~~~~~~~~~~~
--
In file included from arch/x86/include/asm/bug.h:87,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/mm.h:6,
from mm/rmap.c:56:
include/linux/hugetlb.h: In function 'hugetlb_walk':
>> include/linux/hugetlb.h:1285:56: error: invalid use of undefined type 'struct hugetlb_vma_lock'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~
include/asm-generic/bug.h:168:32: note: in definition of macro 'WARN_ON'
168 | int __ret_warn_on = !!(condition); \
| ^~~~~~~~~
include/linux/hugetlb.h:1285:17: note: in expansion of macro 'WARN_ON_ONCE'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~~~~~~~~~~~
include/linux/hugetlb.h:1285:31: note: in expansion of macro 'lockdep_is_held'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~~~~~~~~~~~~~~
In file included from mm/rmap.c:85:
mm/internal.h: In function 'shrinker_debugfs_name_alloc':
mm/internal.h:1223:9: warning: function 'shrinker_debugfs_name_alloc' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1223 | shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
| ^~~~~~~~vim +1285 include/linux/hugetlb.h
185d8dcce62020 Rik van Riel 2023-09-22 1265
9c67a20704e763 Peter Xu 2022-12-16 1266 /*
9c67a20704e763 Peter Xu 2022-12-16 1267 * Safe version of huge_pte_offset() to check the locks. See comments
9c67a20704e763 Peter Xu 2022-12-16 1268 * above huge_pte_offset().
9c67a20704e763 Peter Xu 2022-12-16 1269 */
9c67a20704e763 Peter Xu 2022-12-16 1270 static inline pte_t *
9c67a20704e763 Peter Xu 2022-12-16 1271 hugetlb_walk(struct vm_area_struct *vma, unsigned long addr, unsigned long sz)
9c67a20704e763 Peter Xu 2022-12-16 1272 {
9c67a20704e763 Peter Xu 2022-12-16 1273 #if defined(CONFIG_HUGETLB_PAGE) && \
9c67a20704e763 Peter Xu 2022-12-16 1274 defined(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && defined(CONFIG_LOCKDEP)
9c67a20704e763 Peter Xu 2022-12-16 1275 struct hugetlb_vma_lock *vma_lock = vma->vm_private_data;
9c67a20704e763 Peter Xu 2022-12-16 1276
9c67a20704e763 Peter Xu 2022-12-16 1277 /*
9c67a20704e763 Peter Xu 2022-12-16 1278 * If pmd sharing possible, locking needed to safely walk the
9c67a20704e763 Peter Xu 2022-12-16 1279 * hugetlb pgtables. More information can be found at the comment
9c67a20704e763 Peter Xu 2022-12-16 1280 * above huge_pte_offset() in the same file.
9c67a20704e763 Peter Xu 2022-12-16 1281 *
9c67a20704e763 Peter Xu 2022-12-16 1282 * NOTE: lockdep_is_held() is only defined with CONFIG_LOCKDEP.
9c67a20704e763 Peter Xu 2022-12-16 1283 */
9c67a20704e763 Peter Xu 2022-12-16 1284 if (__vma_shareable_lock(vma))
9c67a20704e763 Peter Xu 2022-12-16 @1285 WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
9c67a20704e763 Peter Xu 2022-12-16 1286 !lockdep_is_held(
9c67a20704e763 Peter Xu 2022-12-16 1287 &vma->vm_file->f_mapping->i_mmap_rwsem));
9c67a20704e763 Peter Xu 2022-12-16 1288 #endif
9c67a20704e763 Peter Xu 2022-12-16 1289 return huge_pte_offset(vma->vm_mm, addr, sz);
9c67a20704e763 Peter Xu 2022-12-16 1290 }
9c67a20704e763 Peter Xu 2022-12-16 1291 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
In reply to [email protected]kernel test robot noticed the following build errors:
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.6-rc3 next-20230921] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/riel-surriel-com/hugetlbfs-extend-hugetlb_vma_lock-to-private-VMAs/20230923-030756 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20230922190552.3963067-4-riel%40surriel.com patch subject: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock config: x86_64-randconfig-013-20230925 (https://download.01.org/0day-ci/archive/20230925/[email protected]/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230925/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/x86/include/asm/bug.h:87,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from arch/x86/include/asm/preempt.h:9,
from include/linux/preempt.h:79,
from include/linux/spinlock.h:56,
from include/linux/mmzone.h:8,
from include/linux/gfp.h:7,
from include/linux/slab.h:16,
from fs/nfs/write.c:11:
include/linux/hugetlb.h: In function 'hugetlb_walk':
>> include/linux/hugetlb.h:1285:42: error: dereferencing pointer to incomplete type 'struct hugetlb_vma_lock'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~
include/asm-generic/bug.h:111:25: note: in definition of macro 'WARN_ON_ONCE'
111 | int __ret_warn_on = !!(condition); \
| ^~~~~~~~~
include/linux/hugetlb.h:1285:17: note: in expansion of macro 'lockdep_is_held'
1285 | WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
| ^~~~~~~~~~~~~~~vim +1285 include/linux/hugetlb.h
185d8dcce62020 Rik van Riel 2023-09-22 1265
9c67a20704e763 Peter Xu 2022-12-16 1266 /*
9c67a20704e763 Peter Xu 2022-12-16 1267 * Safe version of huge_pte_offset() to check the locks. See comments
9c67a20704e763 Peter Xu 2022-12-16 1268 * above huge_pte_offset().
9c67a20704e763 Peter Xu 2022-12-16 1269 */
9c67a20704e763 Peter Xu 2022-12-16 1270 static inline pte_t *
9c67a20704e763 Peter Xu 2022-12-16 1271 hugetlb_walk(struct vm_area_struct *vma, unsigned long addr, unsigned long sz)
9c67a20704e763 Peter Xu 2022-12-16 1272 {
9c67a20704e763 Peter Xu 2022-12-16 1273 #if defined(CONFIG_HUGETLB_PAGE) && \
9c67a20704e763 Peter Xu 2022-12-16 1274 defined(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && defined(CONFIG_LOCKDEP)
9c67a20704e763 Peter Xu 2022-12-16 1275 struct hugetlb_vma_lock *vma_lock = vma->vm_private_data;
9c67a20704e763 Peter Xu 2022-12-16 1276
9c67a20704e763 Peter Xu 2022-12-16 1277 /*
9c67a20704e763 Peter Xu 2022-12-16 1278 * If pmd sharing possible, locking needed to safely walk the
9c67a20704e763 Peter Xu 2022-12-16 1279 * hugetlb pgtables. More information can be found at the comment
9c67a20704e763 Peter Xu 2022-12-16 1280 * above huge_pte_offset() in the same file.
9c67a20704e763 Peter Xu 2022-12-16 1281 *
9c67a20704e763 Peter Xu 2022-12-16 1282 * NOTE: lockdep_is_held() is only defined with CONFIG_LOCKDEP.
9c67a20704e763 Peter Xu 2022-12-16 1283 */
9c67a20704e763 Peter Xu 2022-12-16 1284 if (__vma_shareable_lock(vma))
9c67a20704e763 Peter Xu 2022-12-16 @1285 WARN_ON_ONCE(!lockdep_is_held(&vma_lock->rw_sema) &&
9c67a20704e763 Peter Xu 2022-12-16 1286 !lockdep_is_held(
9c67a20704e763 Peter Xu 2022-12-16 1287 &vma->vm_file->f_mapping->i_mmap_rwsem));
9c67a20704e763 Peter Xu 2022-12-16 1288 #endif
9c67a20704e763 Peter Xu 2022-12-16 1289 return huge_pte_offset(vma->vm_mm, addr, sz);
9c67a20704e763 Peter Xu 2022-12-16 1290 }
9c67a20704e763 Peter Xu 2022-12-16 1291 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
Quoted 11 lines · kernel test robot
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.6-rc3 next-20230921] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
OK, so I have a fix for patch 3/3 that gets rid of the compile error, but the libhugetlbfs test cases show that patch 3/3 opens up a condition where resv_hugepages underflows.
I have not figured out the cause of that yet, but patches 1 & 2 seem to survive all tests fine.
Signature · 1 line
All Rights Reversed.
Re: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
Quoted 13 lines · Rik van Riel
Quoted 11 lines · kernel test robot
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.6-rc3 next-20230921] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
Quoted 7 lines
OK, so I have a fix for patch 3/3 that gets rid of the compile error, but the libhugetlbfs test cases show that patch 3/3 opens up a condition where
resv_hugepagesunderflows.I have not figured out the cause of that yet, but patches 1 & 2 seem to survive all tests fine.
In addition, I suspect patch 3 is going to cause a performance regression. It is taking me a little while to resurrect the test environment used when the hugetlb vma lock was introduced. My plan is to exercise the series in that environment.
I should be able to review patches 1 & 2 later (my) today.
Signature · 1 line
Mike Kravetz
Re: [PATCH 3/3] hugetlbfs: replace hugetlb_vma_lock with invalidate_lock
Quoted 23 lines · Mike Kravetz
Quoted 14 lines · Rik van Riel
Quoted 4 lines · kernel test robot
Hi,
kernel test robot noticed the following build errors:
Quoted 8 lines
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.6-rc3 next-20230921] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented
in
https://git-scm.com/docs/git-format-patch#_base_tree_information]Quoted 7 lines
OK, so I have a fix for patch 3/3 that gets rid of the compile error, but the libhugetlbfs test cases show that patch 3/3 opens up a condition where
resv_hugepagesunderflows.I have not figured out the cause of that yet, but patches 1 & 2 seem to survive all tests fine.
Quoted 8 lines
In addition, I suspect patch 3 is going to cause a performance regression.
It is taking me a little while to resurrect the test environment used when
the hugetlb vma lock was introduced. My plan is to exercise the series in
that environment.
I am planning to send a v3 of the series soon, once I have confirmed that the bugs in patch 3 have all been fixed.
I have no strong opinion on whether or not patch 3 gets merged at all. Patches 1 & 2 fix the actual bug that I am trying to fix, and I am perfectly fine if patch 3 ends up getting dropped in the end.
It seemed worth trying to get that cleanup though ;)
Quoted 1 line
I should be able to review patches 1 & 2 later (my) today.
Thank you!
Signature · 1 line
All Rights Reversed.