Skip to contentSkip to conversation

mm: madvise allow remove operation for hugetlbfs

RFC PATCH Hillf Danton 2 participants 3 messages Apr 17, 2015 – Apr 18, 2015 1 message not in the archive Memory management

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 24 lines

Now that we have hole punching support for hugetlbfs, we can also support the MADV_REMOVE interface to it.

---
 mm/madvise.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -2
index d551475..c4a1027 100644
@@ -299,7 +299,7 @@ static long madvise_remove(struct vm_area_struct *vma,
 
 	*prev = NULL;	/* tell sys_madvise we drop mmap_sem */
 
-	if (vma->vm_flags & (VM_LOCKED | VM_HUGETLB))
+	if (vma->vm_flags & VM_LOCKED)
 		return -EINVAL;
 
 	f = vma->vm_file;
--
Quoted 1 line

2.1.0

After the above change offset is computed,

	offset = (loff_t)(start - vma->vm_start)
		+ ((loff_t)vma->vm_pgoff << PAGE_SHIFT);

and I wonder if it is correct for huge page mapping.

Hillf

#2 lore raw
Quoted 28 lines · Hillf Danton
Quoted 24 lines

Now that we have hole punching support for hugetlbfs, we can also support the MADV_REMOVE interface to it.

---
  mm/madvise.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -2
index d551475..c4a1027 100644
@@ -299,7 +299,7 @@ static long madvise_remove(struct vm_area_struct *vma,
 
  	*prev = NULL;	/* tell sys_madvise we drop mmap_sem */
 
-	if (vma->vm_flags & (VM_LOCKED | VM_HUGETLB))
+	if (vma->vm_flags & VM_LOCKED)
  		return -EINVAL;
 
  	f = vma->vm_file;
--
Quoted 1 line

2.1.0

After the above change offset is computed,

Quoted 4 lines
	offset = (loff_t)(start - vma->vm_start)
		+ ((loff_t)vma->vm_pgoff << PAGE_SHIFT);

and I wonder if it is correct for huge page mapping.

I think it will be correct.

The above will be a (base) page size aligned offset into the file. This offset will be huge page aligned in the fallocate hole punch code.

	/*
	 * For hole punch round up the beginning offset of the hole and
	 * round down the end.
	 */
	hole_start = (offset + hpage_size - 1) & ~huge_page_mask(h);
	hole_end = (offset + len - (hpage_size - 1)) * ~huge_page_mask(h);

Was the alignment your concern, or something else?

Signature · 7 lines
Mike Kravetz

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 41 lines · Mike Kravetz
Quoted 29 lines · Hillf Danton
Quoted 24 lines

Now that we have hole punching support for hugetlbfs, we can also support the MADV_REMOVE interface to it.

---
  mm/madvise.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/madvise.c +1 -1
index d551475..c4a1027 100644
@@ -299,7 +299,7 @@ static long madvise_remove(struct vm_area_struct
 *vma,
 
      *prev = NULL;    /* tell sys_madvise we drop mmap_sem */
 
-    if (vma->vm_flags & (VM_LOCKED | VM_HUGETLB))
+    if (vma->vm_flags & VM_LOCKED)
          return -EINVAL;
 
      f = vma->vm_file;
Quoted 2 lines

--
2.1.0

After the above change offset is computed,

Quoted 4 lines

offset = (loff_t)(start - vma->vm_start)
+ ((loff_t)vma->vm_pgoff << PAGE_SHIFT);

and I wonder if it is correct for huge page mapping.

I think it will be correct.

The above will be a (base) page size aligned offset into the file. This offset will be huge page aligned in the fallocate hole punch code.

Quoted 8 lines
     /*
      * For hole punch round up the beginning offset of the hole and
      * round down the end.
      */
     hole_start = (offset + hpage_size - 1) & ~huge_page_mask(h);
     hole_end = (offset + len - (hpage_size - 1)) * ~huge_page_mask(h);

Was the alignment your concern, or something else?

Well, that alignment code in fallocate hole punch obviously wrong. :( Sorry about that. I'll send out an updated RFC with working hole punch.

Signature · 7 lines
Mike Kravetz

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>