Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5140317ybi; Tue, 28 May 2019 08:11:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZmWXexRcE8pN5ZE/UU5GekXB7xcQIh4hr9R/B9h2QWD8sm1xRvrq212mU9orNorSfnh8s X-Received: by 2002:a17:902:e28a:: with SMTP id cf10mr131478141plb.77.1559056297011; Tue, 28 May 2019 08:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559056297; cv=none; d=google.com; s=arc-20160816; b=dH5L7MaUomjypL0ouc8z3Ka31tUm9Ib97FtR1TwIFxVeauwVnwL0hBZCeARA8UxQ87 TkStNq+U+8Xug60aTXHccYU8BcUG2AQFO1QL2Ne8xwaxy6pv6iKM/t43uPjuzU2yqlEh P8kFcpNO37cKMpowCgxPsQ1JSwkbjQXDS5jEF6wqOUYLq4u6cAYHAHgVSbAw6xbqDYgP 7808FAG0bvsOPYcYl8gK+u028qTav2jXpElptZ5eNLMijSGUMxKwzWGwPnTnN1EtJlFV ZD2NqycfyaqotASHmU/VXclLLdA/TW4PPYpmTXQN95yl3tar78ZBj3zgnIOO8f7Ah3BG YuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=G9vBM5THlG8pywNzVbsKIK8sbELnMUDNM7aCaLdslP0=; b=gLe4Fmitdr2jTQo2SBAzYLJpndhbVa+DEASh5Lq3aeIouJA8zjbFN14BasJjb9IDVd EtbZZjjYdO0yu3iij2vnUjmhqF7UonV09qg2zzFepKPZp2+hgJeBam7Ip3Vzun/wtJEH OBOQJ3wHyUNeH/tLOfUwD25oqHo8zQDvK9y1W1v6lP7fBVwea7MBpvQ3IaYvxFofw8+j hy5HetDcgBppEeCnQ2PyUnr6ze+cHkckKlaegd5pl7d0R6jEU2nLmmAGJ6X+HeUFoXHt 0AdSTvxItnWIpp3u0BkSc9poaJ/Ys8aJa+7ozOLGQjiAIS3B3owjPzmpusVFCA5tf1Wo g6jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="bgq/F8b/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34si22272219pgm.114.2019.05.28.08.11.20; Tue, 28 May 2019 08:11:36 -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=@oracle.com header.s=corp-2018-07-02 header.b="bgq/F8b/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbfE1PFd (ORCPT + 99 others); Tue, 28 May 2019 11:05:33 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:58076 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbfE1PFc (ORCPT ); Tue, 28 May 2019 11:05:32 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4SF4QUp083027; Tue, 28 May 2019 15:04:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=G9vBM5THlG8pywNzVbsKIK8sbELnMUDNM7aCaLdslP0=; b=bgq/F8b/2xwUVXMlsJqTT/j8YvUXLiDeS1H4MJ+nX4NOQ5xuZxuO5UeAXzVEoTG1w3bf iu6Ce7E+Lhxw9casXB7xzxnF/LglbRQEC8Hux6StMYE/xjblB+T7bJ8nOxdBonl07JjK i4LWZr8dbuD44I3nkitg/rpMislB3CGkymXU4mlpDIqIm+8/2CgEmV0kh75+vCfvC2L4 Z8Adu0/Y0OQ8FReXSRrA1zB1u+Z7W4E2Dt6b4GdDgXE31SyMNMgBPdc0LZpdUzdIuZHh ka4eUEOZ3WXQdsjyQL6SgjVs8mBV0FmA9pPrU0yOOD7DKhfxFyHFYXk1s/ronu4hv6Mr 7g== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2spw4tbtqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 May 2019 15:04:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x4SF3Kh9017458; Tue, 28 May 2019 15:04:39 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2ss1fmwp16-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 May 2019 15:04:38 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x4SF4OV0025272; Tue, 28 May 2019 15:04:24 GMT Received: from ca-dmjordan1.us.oracle.com (/10.211.9.48) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 28 May 2019 08:04:24 -0700 Date: Tue, 28 May 2019 11:04:24 -0400 From: Daniel Jordan To: Andrew Morton Cc: Daniel Jordan , 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: <20190528150424.tjbaiptpjhzg7y75@ca-dmjordan1.us.oracle.com> References: <20190524175045.26897-1-daniel.m.jordan@oracle.com> <20190525145118.bfda2d75a14db05a001e49ad@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190525145118.bfda2d75a14db05a001e49ad@linux-foundation.org> User-Agent: NeoMutt/20180323-268-5a959c X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9270 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=18 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905280098 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9270 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=18 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905280098 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 25, 2019 at 02:51:18PM -0700, Andrew Morton wrote: > 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... Sure, I can uninline it. vfio changelogs don't show a particular reason for _killable[1]. Maybe Alex has something to add. Otherwise I'll respin without it since the simplification seems worth removing _killable. [1] 0cfef2b7410b ("vfio/type1: Remove locked page accounting workqueue")