mirror of https://github.com/torvalds/linux.git
mm: update resctl to use mmap_prepare
Make use of the ability to specify a remap action within mmap_prepare to update the resctl pseudo-lock to use mmap_prepare in favour of the deprecated mmap hook. Link: https://lkml.kernel.org/r/95b28b066f37ca25f56fa9460a9367f1a866f88b.1760959442.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andreas Larsson <andreas@gaisler.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Baoquan He <bhe@redhat.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Dave Martin <dave.martin@arm.com> Cc: Dave Young <dyoung@redhat.com> Cc: David Hildenbrand <david@redhat.com> Cc: David S. Miller <davem@davemloft.net> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guo Ren <guoren@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Hugh Dickins <hughd@google.com> Cc: James Morse <james.morse@arm.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Kevin Tian <kevin.tian@intel.com> Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nicolas Pitre <nico@fluxnic.net> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Robin Murohy <robin.murphy@arm.com> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
ab04945f91
commit
8247e2600e
|
|
@ -995,10 +995,11 @@ static const struct vm_operations_struct pseudo_mmap_ops = {
|
||||||
.mremap = pseudo_lock_dev_mremap,
|
.mremap = pseudo_lock_dev_mremap,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pseudo_lock_dev_mmap(struct file *filp, struct vm_area_struct *vma)
|
static int pseudo_lock_dev_mmap_prepare(struct vm_area_desc *desc)
|
||||||
{
|
{
|
||||||
unsigned long vsize = vma->vm_end - vma->vm_start;
|
unsigned long off = desc->pgoff << PAGE_SHIFT;
|
||||||
unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
|
unsigned long vsize = vma_desc_size(desc);
|
||||||
|
struct file *filp = desc->file;
|
||||||
struct pseudo_lock_region *plr;
|
struct pseudo_lock_region *plr;
|
||||||
struct rdtgroup *rdtgrp;
|
struct rdtgroup *rdtgrp;
|
||||||
unsigned long physical;
|
unsigned long physical;
|
||||||
|
|
@ -1043,7 +1044,7 @@ static int pseudo_lock_dev_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||||
* Ensure changes are carried directly to the memory being mapped,
|
* Ensure changes are carried directly to the memory being mapped,
|
||||||
* do not allow copy-on-write mapping.
|
* do not allow copy-on-write mapping.
|
||||||
*/
|
*/
|
||||||
if (!(vma->vm_flags & VM_SHARED)) {
|
if (!(desc->vm_flags & VM_SHARED)) {
|
||||||
mutex_unlock(&rdtgroup_mutex);
|
mutex_unlock(&rdtgroup_mutex);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
@ -1055,12 +1056,9 @@ static int pseudo_lock_dev_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||||
|
|
||||||
memset(plr->kmem + off, 0, vsize);
|
memset(plr->kmem + off, 0, vsize);
|
||||||
|
|
||||||
if (remap_pfn_range(vma, vma->vm_start, physical + vma->vm_pgoff,
|
desc->vm_ops = &pseudo_mmap_ops;
|
||||||
vsize, vma->vm_page_prot)) {
|
mmap_action_remap_full(desc, physical + desc->pgoff);
|
||||||
mutex_unlock(&rdtgroup_mutex);
|
|
||||||
return -EAGAIN;
|
|
||||||
}
|
|
||||||
vma->vm_ops = &pseudo_mmap_ops;
|
|
||||||
mutex_unlock(&rdtgroup_mutex);
|
mutex_unlock(&rdtgroup_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1071,7 +1069,7 @@ static const struct file_operations pseudo_lock_dev_fops = {
|
||||||
.write = NULL,
|
.write = NULL,
|
||||||
.open = pseudo_lock_dev_open,
|
.open = pseudo_lock_dev_open,
|
||||||
.release = pseudo_lock_dev_release,
|
.release = pseudo_lock_dev_release,
|
||||||
.mmap = pseudo_lock_dev_mmap,
|
.mmap_prepare = pseudo_lock_dev_mmap_prepare,
|
||||||
};
|
};
|
||||||
|
|
||||||
int rdt_pseudo_lock_init(void)
|
int rdt_pseudo_lock_init(void)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue