Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2056351ybi; Sat, 25 May 2019 14:52:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfgglCrS0jMspi51XR97swlm1k2hFOBt87oQwDmyeAB03kctcBU5LZS8w7/IeiaturkoDh X-Received: by 2002:a62:fb18:: with SMTP id x24mr58350627pfm.76.1558821165833; Sat, 25 May 2019 14:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558821165; cv=none; d=google.com; s=arc-20160816; b=ORxIoBcck1aILmU9S+BwV+WePUG/OJtCGl4xlgWSqkukj9MT6d8SygWbDTPrBAajd/ Q+JwS6NaYPxhfZ71fHllVzpGLGTeR5SOTPsjvlNwmOMN0ROEFO6KrgElLEh3p8BgfQrz uR+oMDm+W91pKUKfUtFznEzW8oQa4ueagacHY9zTCUgi/Ui6fz8zjzpcUmsvrpy7AntN uewU6k396Dq2J3Q3NLBYgQyDTDRpSRwae3h75zO8ptScJ3YCVOnIW62B2EyxG4ekxicW gMwix9fDBmqSqEg8tvcp5hftBK/UolAGYaQhN5TJDGFl4r3Y245SoNTLVcBbr14oOepV 5eSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Ggdf+nwMYpqOtPfchVX3fGXJn/l3ESKOGJa08VuJQj8=; b=Ms2Q3MGJWTNWUfBmb/4RC/TlEL9ja42/PpTMabPchV6H2GKQ3H9NRWQQ0WdKe+lzsk 1wB1+GTnlwgbtWdTJFj2PX2e6p+aN5un354RnRtn9qHypZQ/p8o2LTUQ1+N+/eZ33WZy vo7SDDrxsFrozPNfAKtn/t70IszWETw7d3JPOg4dcw1PnmKg9CBSskyaBfqTadeQp+Yo ruaFfXSEqsAgcrxXMjiDXrbeRQfNLzZwnbjPq232mikbREjFCRX60nH6w6CfRtPkkPnI qCefaZeIsL+N0jK0YKjfC3IQXEycNBGSviWjpqNtXeaR4cNn7DJizUmYaqSYE0tBrDXK UABw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yeCoL/9Y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si10901519plh.252.2019.05.25.14.52.30; Sat, 25 May 2019 14:52:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yeCoL/9Y"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727514AbfEYVvV (ORCPT + 99 others); Sat, 25 May 2019 17:51:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:36054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbfEYVvV (ORCPT ); Sat, 25 May 2019 17:51:21 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7150B20717; Sat, 25 May 2019 21:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558821080; bh=9GojVzJw4LUT0FwL1uJ2uxQz/GR22xKEGuM8E5lF4U4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yeCoL/9YBkEk1sCDuZGtqcOLLhjEc3XPpvmQxhmXpl1ivii7ueziKdgVyPiry9ByA ADOT2OgdVR0DYv4LRRgW5QSfW6vt2A05lzKc6kYMl7/+P1G4g6y87rsbUW7KSF+/pj wELWVZx/6l9yaDm7Gysp2a6pdP0M1R6mJkI2X3yI= Date: Sat, 25 May 2019 14:51:18 -0700 From: Andrew Morton To: Daniel Jordan Cc: Alexey Kardashevskiy , Alan Tull , Alex Williamson , Benjamin Herrenschmidt , Christoph Lameter , Christophe Leroy , Davidlohr Bueso , Jason Gunthorpe , Mark Rutland , Michael Ellerman , Moritz Fischer , Paul Mackerras , Steve Sistare , Wu Hao , linux-mm@kvack.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm: add account_locked_vm utility function Message-Id: <20190525145118.bfda2d75a14db05a001e49ad@linux-foundation.org> In-Reply-To: <20190524175045.26897-1-daniel.m.jordan@oracle.com> References: <20190524175045.26897-1-daniel.m.jordan@oracle.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 May 2019 13:50:45 -0400 Daniel Jordan wrote: > locked_vm accounting is done roughly the same way in five places, so > unify them in a helper. Standardize the debug prints, which vary > slightly, but include the helper's caller to disambiguate between > callsites. > > Error codes stay the same, so user-visible behavior does too. The one > exception is that the -EPERM case in tce_account_locked_vm is removed > because Alexey has never seen it triggered. > > ... > > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1564,6 +1564,25 @@ long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, > int get_user_pages_fast(unsigned long start, int nr_pages, > unsigned int gup_flags, struct page **pages); > > +int __account_locked_vm(struct mm_struct *mm, unsigned long pages, bool inc, > + struct task_struct *task, bool bypass_rlim); > + > +static inline int account_locked_vm(struct mm_struct *mm, unsigned long pages, > + bool inc) > +{ > + int ret; > + > + if (pages == 0 || !mm) > + return 0; > + > + down_write(&mm->mmap_sem); > + ret = __account_locked_vm(mm, pages, inc, current, > + capable(CAP_IPC_LOCK)); > + up_write(&mm->mmap_sem); > + > + return ret; > +} That's quite a mouthful for an inlined function. How about uninlining the whole thing and fiddling drivers/vfio/vfio_iommu_type1.c to suit. I wonder why it does down_write_killable and whether it really needs to...