Skip to content

Commit 10969b5

Browse files
Hugh Dickinsakpm00
authored andcommitted
hugetlbfs: drop shared NUMA mempolicy pretence
Patch series "mempolicy: cleanups leading to NUMA mpol without vma", v2. Mostly cleanups in mm/mempolicy.c, but finally removing the pseudo-vma from shmem folio allocation, and removing the mmap_lock around folio migration for mbind and migrate_pages syscalls. This patch (of 12): hugetlbfs_fallocate() goes through the motions of pasting a shared NUMA mempolicy onto its pseudo-vma, but how could there ever be a shared NUMA mempolicy for this file? hugetlb_vm_ops has never offered a set_policy method, and hugetlbfs_parse_param() has never supported any mpol options for a mount-wide default policy. It's just an illusion: clean it away so as not to confuse others, giving us more freedom to adjust shmem's set_policy/get_policy implementation. But hugetlbfs_inode_info is still required, just to accommodate seals. Yes, shared NUMA mempolicy support could be added to hugetlbfs, with a set_policy method and/or mpol mount option (Andi's first posting did include an admitted-unsatisfactory hugetlb_set_policy()); but it seems that nobody has bothered to add that in the nineteen years since v2.6.7 made it possible, and there is at least one company that has invested enough into hugetlbfs, that I guess they have learnt well enough how to manage its NUMA, without needing shared mempolicy. Remove linux/mempolicy.h from linux/hugetlb.h: include linux/pagemap.h in its place, because hugetlb.h's recently added use of filemap_lock_folio() requires that (although most .configs and .c's get it in some other way). Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "Huang, Ying" <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Sidhartha Kumar <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Tejun heo <[email protected]> Cc: Vishal Moola (Oracle) <[email protected]> Cc: Yang Shi <[email protected]> Cc: Nhat Pham <[email protected]> Cc: Yosry Ahmed <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b8ee557 commit 10969b5

File tree

2 files changed

+2
-42
lines changed

2 files changed

+2
-42
lines changed

fs/hugetlbfs/inode.c

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,6 @@ static const struct fs_parameter_spec hugetlb_fs_parameters[] = {
8383
{}
8484
};
8585

86-
#ifdef CONFIG_NUMA
87-
static inline void hugetlb_set_vma_policy(struct vm_area_struct *vma,
88-
struct inode *inode, pgoff_t index)
89-
{
90-
vma->vm_policy = mpol_shared_policy_lookup(&HUGETLBFS_I(inode)->policy,
91-
index);
92-
}
93-
94-
static inline void hugetlb_drop_vma_policy(struct vm_area_struct *vma)
95-
{
96-
mpol_cond_put(vma->vm_policy);
97-
}
98-
#else
99-
static inline void hugetlb_set_vma_policy(struct vm_area_struct *vma,
100-
struct inode *inode, pgoff_t index)
101-
{
102-
}
103-
104-
static inline void hugetlb_drop_vma_policy(struct vm_area_struct *vma)
105-
{
106-
}
107-
#endif
108-
10986
/*
11087
* Mask used when checking the page offset value passed in via system
11188
* calls. This value will be converted to a loff_t which is signed.
@@ -853,8 +830,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
853830

854831
/*
855832
* Initialize a pseudo vma as this is required by the huge page
856-
* allocation routines. If NUMA is configured, use page index
857-
* as input to create an allocation policy.
833+
* allocation routines.
858834
*/
859835
vma_init(&pseudo_vma, mm);
860836
vm_flags_init(&pseudo_vma, VM_HUGETLB | VM_MAYSHARE | VM_SHARED);
@@ -902,9 +878,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
902878
* folios in these areas, we need to consume the reserves
903879
* to keep reservation accounting consistent.
904880
*/
905-
hugetlb_set_vma_policy(&pseudo_vma, inode, index);
906881
folio = alloc_hugetlb_folio(&pseudo_vma, addr, 0);
907-
hugetlb_drop_vma_policy(&pseudo_vma);
908882
if (IS_ERR(folio)) {
909883
mutex_unlock(&hugetlb_fault_mutex_table[hash]);
910884
error = PTR_ERR(folio);
@@ -1283,18 +1257,6 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
12831257
hugetlbfs_inc_free_inodes(sbinfo);
12841258
return NULL;
12851259
}
1286-
1287-
/*
1288-
* Any time after allocation, hugetlbfs_destroy_inode can be called
1289-
* for the inode. mpol_free_shared_policy is unconditionally called
1290-
* as part of hugetlbfs_destroy_inode. So, initialize policy here
1291-
* in case of a quick call to destroy.
1292-
*
1293-
* Note that the policy is initialized even if we are creating a
1294-
* private inode. This simplifies hugetlbfs_destroy_inode.
1295-
*/
1296-
mpol_shared_policy_init(&p->policy, NULL);
1297-
12981260
return &p->vfs_inode;
12991261
}
13001262

@@ -1306,7 +1268,6 @@ static void hugetlbfs_free_inode(struct inode *inode)
13061268
static void hugetlbfs_destroy_inode(struct inode *inode)
13071269
{
13081270
hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb));
1309-
mpol_free_shared_policy(&HUGETLBFS_I(inode)->policy);
13101271
}
13111272

13121273
static const struct address_space_operations hugetlbfs_aops = {

include/linux/hugetlb.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void free_huge_folio(struct folio *folio);
3030

3131
#ifdef CONFIG_HUGETLB_PAGE
3232

33-
#include <linux/mempolicy.h>
33+
#include <linux/pagemap.h>
3434
#include <linux/shm.h>
3535
#include <asm/tlbflush.h>
3636

@@ -545,7 +545,6 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
545545
}
546546

547547
struct hugetlbfs_inode_info {
548-
struct shared_policy policy;
549548
struct inode vfs_inode;
550549
unsigned int seals;
551550
};

0 commit comments

Comments
 (0)