fs: hugetlbfs: set vma policy only when needed for allocating folio
Calling hugetlb_set_vma_policy() later avoids setting the vma policy and then dropping it on a page cache hit. Link: https://lkml.kernel.org/r/20230502235622.3652586-1-ackerleytng@google.com Signed-off-by: Ackerley Tng <ackerleytng@google.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Vishal Annapurve <vannapurve@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
88537aac0b
commit
adef080382
|
@ -834,9 +834,6 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set numa allocation policy based on index */
|
|
||||||
hugetlb_set_vma_policy(&pseudo_vma, inode, index);
|
|
||||||
|
|
||||||
/* addr is the offset within the file (zero based) */
|
/* addr is the offset within the file (zero based) */
|
||||||
addr = index * hpage_size;
|
addr = index * hpage_size;
|
||||||
|
|
||||||
|
@ -850,7 +847,6 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
if (present) {
|
if (present) {
|
||||||
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
|
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
|
||||||
hugetlb_drop_vma_policy(&pseudo_vma);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,6 +858,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
|
||||||
* folios in these areas, we need to consume the reserves
|
* folios in these areas, we need to consume the reserves
|
||||||
* to keep reservation accounting consistent.
|
* to keep reservation accounting consistent.
|
||||||
*/
|
*/
|
||||||
|
hugetlb_set_vma_policy(&pseudo_vma, inode, index);
|
||||||
folio = alloc_hugetlb_folio(&pseudo_vma, addr, 0);
|
folio = alloc_hugetlb_folio(&pseudo_vma, addr, 0);
|
||||||
hugetlb_drop_vma_policy(&pseudo_vma);
|
hugetlb_drop_vma_policy(&pseudo_vma);
|
||||||
if (IS_ERR(folio)) {
|
if (IS_ERR(folio)) {
|
||||||
|
|
Loading…
Reference in New Issue