Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-18449

Handling kernel mmap read-ahead triggering by advise(MADV_HUGEPAGE)

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      kernel:LustreError: 126979:0:(rw.c:2162:ll_readpage()) ASSERTION( !ra_assert ) failed: 
      

      Found a possible bug in kernel to trigger readahead in Linux kernel:

      static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
      {
      	struct file *file = vmf->vma->vm_file;
      	struct file_ra_state *ra = &file->f_ra;
      	struct address_space *mapping = file->f_mapping;
      	DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff);
      	struct file *fpin = NULL;
      	unsigned long vm_flags = vmf->vma->vm_flags;
      	unsigned int mmap_miss;
      
      #ifdef CONFIG_TRANSPARENT_HUGEPAGE
      	/* Use the readahead code, even if readahead is disabled */
      	if (vm_flags & VM_HUGEPAGE) {
      		fpin = maybe_unlock_mmap_for_io(vmf, fpin);
      		ractl._index &= ~((unsigned long)HPAGE_PMD_NR - 1);
      		ra->size = HPAGE_PMD_NR;
      		/*
      		 * Fetch two PMD folios, so we get the chance to actually
      		 * readahead, unless we've been told not to.
      		 */
      		if (!(vm_flags & VM_RAND_READ))
      			ra->size *= 2;
      		ra->async_size = HPAGE_PMD_NR;
      		page_cache_ra_order(&ractl, ra, HPAGE_PMD_ORDER);
      		return fpin;
      	}
      #endif
      
      	/* If we don't want any read-ahead, don't bother */
      	if (vm_flags & VM_RAND_READ)
      		return fpin;
      	if (!ra->ra_pages)
      		return fpin;
              ...
      }
      

      Usually the kernel readahead will disabled by setting ra_pages with 0.
      However,
      when CONFIG_TRANSPARENT_HUGEPAGE is enabled and vm flagged with VM_HUGEPAGE, it will trigger the kernel readahead.
      When the kernel is configed with CONFIG_TRANSPARENT_HUGEPAGE and the application is set VM_HUGEPAGE via MADV_HUGEPAGE via madvise() system call, it is possible to trigger these kind of read-ahead from Linux kernel and out the control of Lustre.

      Attachments

        Activity

          People

            qian_wc Qian Yingjin
            qian_wc Qian Yingjin
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: