Skip to content

Commit 4b981bc

Browse files
Hugh Dickinsakpm00
authored andcommitted
kernfs: drop shared NUMA mempolicy hooks
It seems strange that kernfs should be an outlier with a set_policy and get_policy in its kernfs_vm_ops. Ah, it dates back to v2.6.30's commit 095160a ("sysfs: fix some bin_vm_ops errors"), when I had crashed on powerpc's pci_mmap_legacy_page_range() fallback to shmem_zero_setup(). Well, that was commendably thorough, to give sysfs-bin a set_policy and get_policy, just to avoid the way it was coded resulting in EINVAL from mmap when CONFIG_NUMA; but somehow feels a bit over-the-top to me now. It's easier to say that nobody should expect to manage a shmem object's shared NUMA mempolicy via some kernfs backdoor to that object: delete that code (and there's no longer an EINVAL from mmap in the NUMA case). This then leaves set_policy/get_policy as implemented only by shmem - though importantly also by SysV SHM, which has to interface with shmem which implements them, and with SHM_HUGETLB which does not. 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: Nhat Pham <[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: Yosry Ahmed <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 10969b5 commit 4b981bc

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

fs/kernfs/file.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -429,60 +429,11 @@ static int kernfs_vma_access(struct vm_area_struct *vma, unsigned long addr,
429429
return ret;
430430
}
431431

432-
#ifdef CONFIG_NUMA
433-
static int kernfs_vma_set_policy(struct vm_area_struct *vma,
434-
struct mempolicy *new)
435-
{
436-
struct file *file = vma->vm_file;
437-
struct kernfs_open_file *of = kernfs_of(file);
438-
int ret;
439-
440-
if (!of->vm_ops)
441-
return 0;
442-
443-
if (!kernfs_get_active(of->kn))
444-
return -EINVAL;
445-
446-
ret = 0;
447-
if (of->vm_ops->set_policy)
448-
ret = of->vm_ops->set_policy(vma, new);
449-
450-
kernfs_put_active(of->kn);
451-
return ret;
452-
}
453-
454-
static struct mempolicy *kernfs_vma_get_policy(struct vm_area_struct *vma,
455-
unsigned long addr)
456-
{
457-
struct file *file = vma->vm_file;
458-
struct kernfs_open_file *of = kernfs_of(file);
459-
struct mempolicy *pol;
460-
461-
if (!of->vm_ops)
462-
return vma->vm_policy;
463-
464-
if (!kernfs_get_active(of->kn))
465-
return vma->vm_policy;
466-
467-
pol = vma->vm_policy;
468-
if (of->vm_ops->get_policy)
469-
pol = of->vm_ops->get_policy(vma, addr);
470-
471-
kernfs_put_active(of->kn);
472-
return pol;
473-
}
474-
475-
#endif
476-
477432
static const struct vm_operations_struct kernfs_vm_ops = {
478433
.open = kernfs_vma_open,
479434
.fault = kernfs_vma_fault,
480435
.page_mkwrite = kernfs_vma_page_mkwrite,
481436
.access = kernfs_vma_access,
482-
#ifdef CONFIG_NUMA
483-
.set_policy = kernfs_vma_set_policy,
484-
.get_policy = kernfs_vma_get_policy,
485-
#endif
486437
};
487438

488439
static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)

0 commit comments

Comments
 (0)