From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rT5GQ5YWYzDqcg for ; Tue, 14 Jun 2016 07:17:50 +1000 (AEST) Received: by mail-wm0-x242.google.com with SMTP id n184so17821227wmn.1 for ; Mon, 13 Jun 2016 14:17:50 -0700 (PDT) Subject: Re: [RFC 12/18] limits: track RLIMIT_MEMLOCK actual max To: Alex Williamson References: <1465847065-3577-1-git-send-email-toiwoton@gmail.com> <1465847065-3577-13-git-send-email-toiwoton@gmail.com> <20160613144359.677edee4@ul30vt.home> Cc: linux-kernel@vger.kernel.org, Tony Luck , Fenghua Yu , Alexander Graf , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Doug Ledford , Sean Hefty , Hal Rosenstock , Mike Marciniszyn , Dennis Dalessandro , Christian Benvenuti , Dave Goodell , Sudeep Dutt , Ashutosh Dixit , Ingo Molnar , Peter Zijlstra , Alexei Starovoitov , Arnaldo Carvalho de Melo , Alexander Shishkin , Andrew Morton , Konstantin Khlebnikov , Jiri Slaby , Cyrill Gorcunov , Thomas Gleixner , Dave Hansen , Greg Kroah-Hartman , Dan Carpenter , Nikhil Rao , Vlastimil Babka , "Kirill A. Shutemov" , Michal Hocko , Eric B Munson , Alexey Klimov , Andrea Arcangeli , Alexander Kuleshov , Oleg Nesterov , Chen Gang , Andrey Ryabinin , David Rientjes , Hugh Dickins , Laurent Dufour , "open list:IA64 (Itanium) PLATFORM" , "open list:KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC" , "open list:KERNEL VIRTUAL MACHINE (KVM)" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , "open list:INFINIBAND SUBSYSTEM" , "open list:BPF (Safe dynamic programs and tools)" , "open list:MEMORY MANAGEMENT" From: Topi Miettinen Message-ID: <6e1a7caa-e4e8-fd41-4bab-00089c12b781@gmail.com> Date: Mon, 13 Jun 2016 21:17:43 +0000 MIME-Version: 1.0 In-Reply-To: <20160613144359.677edee4@ul30vt.home> Content-Type: text/plain; charset=windows-1252 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 06/13/16 20:43, Alex Williamson wrote: > On Mon, 13 Jun 2016 22:44:19 +0300 > Topi Miettinen wrote: > >> Track maximum size of locked memory, presented in /proc/self/limits. >> >> Signed-off-by: Topi Miettinen >> --- >> 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(-) > ... >> >> 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 >