Re: [RFC 12/18] limits: track RLIMIT_MEMLOCK actual max
From: Topi Miettinen <hidden>
Date: 2016-06-13 21:17:49
Also in:
kvm, linux-mm, linux-rdma, netdev
On 06/13/16 20:43, Alex Williamson wrote:
On Mon, 13 Jun 2016 22:44:19 +0300 Topi Miettinen [off-list ref] wrote:quoted
Track maximum size of locked memory, presented in /proc/self/limits. Signed-off-by: Topi Miettinen <redacted> --- arch/ia64/kernel/perfmon.c | 1 + arch/powerpc/kvm/book3s_64_vio.c | 1 + arch/powerpc/mm/mmu_context_iommu.c | 1 + drivers/infiniband/core/umem.c | 1 + drivers/infiniband/hw/hfi1/user_pages.c | 1 + drivers/infiniband/hw/qib/qib_user_pages.c | 1 + drivers/infiniband/hw/usnic/usnic_uiom.c | 2 ++ drivers/misc/mic/scif/scif_rma.c | 1 + drivers/vfio/vfio_iommu_spapr_tce.c | 2 ++ drivers/vfio/vfio_iommu_type1.c | 2 ++ include/linux/sched.h | 10 ++++++++-- kernel/bpf/syscall.c | 6 ++++++ kernel/events/core.c | 1 + mm/mlock.c | 7 +++++++ mm/mmap.c | 3 +++ mm/mremap.c | 3 +++ 16 files changed, 41 insertions(+), 2 deletions(-)...quoted
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 2ba1942..4c6e7a3 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c@@ -312,6 +312,8 @@ static long vfio_pin_pages(unsigned long vaddr, long npage, } } + bump_rlimit(RLIMIT_MEMLOCK, (current->mm->locked_vm + i) << PAGE_SHIFT); + if (!rsvd) vfio_lock_acct(i);Not all cases passing through here bump rlimit (see: rsvd), there's an entire case above the other end of this closing bracket that does bump rlimit but returns before here, and I wonder why we wouldn't just do this in our vfio_lock_acct() accounting function anyway. Thanks,
Yes, just make disable_hugepages case go to end of function. -Topi
Alex