Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1222473imj; Thu, 14 Feb 2019 03:13:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IaA0DGgx+c4lfVpYNzG/5UxdygWiaIib6WensvjX8DXe3xIZvfdzblIxz5wccnnHszzsgwm X-Received: by 2002:a63:194f:: with SMTP id 15mr3302086pgz.192.1550142792851; Thu, 14 Feb 2019 03:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550142792; cv=none; d=google.com; s=arc-20160816; b=O88b6YykUlM12tddobI+08+vca/Ts1Ve5zsdE0c52bUQPq15LX8yAmyU25fwOFbIrh jIn9MvXrCgYAIl4lnPBVkdjlYZKg91U43wGIH8ZUoCSji3duQIKC4504huwTwzQpUq5u 38cIUSaKzG2j6CtqcJSwfc7sZQFHe02hmjpydfiXxA1fiyJZjfkkd7W6lf1JFfZJBQWy DRLG+JKCAyVU5USHfnQUOLSi55fzxaDGQvgK/wYYFOpnFf5CCZCZZ1oR4S3jvzdgPhRo GLWvgFauW6ous+wDpal0cp6enGBAsIj8YyBI/vqrr4jNMqtsEsmswShizSbfHefklxjP IiZg== 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=EyhZ0LXI8S6DO+1lKPJ+3xCo7Hi2M9DApl/OXP8GRG0=; b=sdqzj/6t+MPpYgVxuF82iN2K8orVljfAfEbQwoeeqxbaTm9hyPkET27fA9AXxQf2H5 dIA5uK0wHjyWzEphoZXEA8Bj+6P/ZZ8Rk6OdC7LvpjGGKsdjJpMCwIbEB2Kfou6P/2Zr d0WpiDp90haLZeSIHLQCdGDMe/3fBpgLwDueMrUoYlfJLcCBanIr3nKQoO800tHghSFX 2Dx1VrPQW8a8iXWaGEXLss7DZQ8yZGJ6qJez0Lc7Jb+cMPujM93aw4TIOZcw2odPrntx ja+JXhY7exzKVlWapA/wC12LT6Y4Bbo7eVWx8Fj3XY7+9mSqx52xTdISWwt7jPXS+rlH haLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=AqFGGKQk; 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 a11si2420675pla.20.2019.02.14.03.12.56; Thu, 14 Feb 2019 03:13:12 -0800 (PST) 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=@ziepe.ca header.s=google header.b=AqFGGKQk; 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 S2393529AbfBNGAJ (ORCPT + 99 others); Thu, 14 Feb 2019 01:00:09 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36376 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391894AbfBNGAJ (ORCPT ); Thu, 14 Feb 2019 01:00:09 -0500 Received: by mail-pg1-f194.google.com with SMTP id r124so2479033pgr.3 for ; Wed, 13 Feb 2019 22:00:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=EyhZ0LXI8S6DO+1lKPJ+3xCo7Hi2M9DApl/OXP8GRG0=; b=AqFGGKQkWIE4m9oWUPQKPfYDWffEV3DD3kw2gte/hIVc+ZOI2ALww287MyZktoOcDi CbpDfqNDDxjQTYKo+HSL1jPCcxgIu0tlHCqsVDa+M5KY9ZBsLFTmv/t2wqc5kisOEAq3 Ey9IsWcwZPCXnG/nVFmz7GUhhGKdm8IWeTP2Dk0HwbmuU3cqx7K5BZzuoEE5qUenFwFw FhXuEgKL+2MrnrRuMG0A1nR+NYB/69dpYPvc7V/phtqqydIA5J2EkPID7AxDk9lsLjAP NbaOeXfbMwnJ+uPtI2ATX/eErFA+0vBz71ipAT/cQzRY+HNlZcQmNhta5uk0wuPGbr4p 3GKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=EyhZ0LXI8S6DO+1lKPJ+3xCo7Hi2M9DApl/OXP8GRG0=; b=Sf9ViAPvpAdBJmj885N4HAugn4Z8C0WEztRTfcOzG/xEz+2t45Cl8WRoHtTp2x0mPI uE0QJLIWjrlt+hgWuT/k8BVELMMeyUExu9Apkqfh+tVmjEE6KIjqvndBN2wINCA8VH4h MP1ZBlzkEjl4q8IoKIpxysT4fJxj+31A1nVKVp1Jsqf7JeY+OKCaRNvyylMcWNiRZ6Pb 1nKwK+bjupZ7QYa8RMfmoYxsJVR/YatryEwhQWqwIkf7croqoMWv46Gk3HC3SIIj4MV9 eg/kib456aLlUcz1/7w5p8y5LJebLRQlqx/ebDco2xyePEtk76OyLuY0Qrr+dJrnj+DO 7Mfw== X-Gm-Message-State: AHQUAuZZKUvbGNu2/H8ZATATvhegLLAtMUDheIkotq6kZhu//ZCYeC0Q HJ6hre2Plu3/Tv62XhVXKDnGxg== X-Received: by 2002:a62:9f1a:: with SMTP id g26mr2297647pfe.123.1550124008008; Wed, 13 Feb 2019 22:00:08 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id z127sm2288820pfb.80.2019.02.13.22.00.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Feb 2019 22:00:07 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1guA46-00040P-Jk; Wed, 13 Feb 2019 23:00:06 -0700 Date: Wed, 13 Feb 2019 23:00:06 -0700 From: Jason Gunthorpe To: Ira Weiny Cc: Daniel Jordan , akpm@linux-foundation.org, dave@stgolabs.net, jack@suse.cz, cl@linux.com, 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, alex.williamson@redhat.com, paulus@ozlabs.org, benh@kernel.crashing.org, mpe@ellerman.id.au, hao.wu@intel.com, atull@kernel.org, mdf@kernel.org, aik@ozlabs.ru Subject: Re: [PATCH 0/5] use pinned_vm instead of locked_vm to account pinned pages Message-ID: <20190214060006.GE24692@ziepe.ca> References: <20190211224437.25267-1-daniel.m.jordan@oracle.com> <20190211225447.GN24692@ziepe.ca> <20190214015314.GB1151@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190214015314.GB1151@iweiny-DESK2.sc.intel.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 13, 2019 at 05:53:14PM -0800, Ira Weiny wrote: > On Mon, Feb 11, 2019 at 03:54:47PM -0700, Jason Gunthorpe wrote: > > On Mon, Feb 11, 2019 at 05:44:32PM -0500, Daniel Jordan wrote: > > > > > All five of these places, and probably some of Davidlohr's conversions, > > > probably want to be collapsed into a common helper in the core mm for > > > accounting pinned pages. I tried, and there are several details that > > > likely need discussion, so this can be done as a follow-on. > > > > I've wondered the same.. > > I'm really thinking this would be a nice way to ensure it gets cleaned up and > does not happen again. > > Also, by moving it to the core we could better manage any user visible changes. > > From a high level, pinned is a subset of locked so it seems like we need a 2 > sets of helpers. > > try_increment_locked_vm(...) > decrement_locked_vm(...) > > try_increment_pinned_vm(...) > decrement_pinned_vm(...) > > Where try_increment_pinned_vm() also increments locked_vm... Of course this > may end up reverting the improvement of Davidlohr Bueso's atomic work... :-( > > Furthermore it would seem better (although I don't know if at all possible) if > this were accounted for in core calls which tracked them based on how the pages > are being used so that drivers can't call try_increment_locked_vm() and then > pin the pages... Thus getting the account wrong vs what actually happened. > > And then in the end we can go back to locked_vm being the value checked against > RLIMIT_MEMLOCK. Someone would need to understand the bug that was fixed by splitting them. I think it had to do with double accounting pinned and mlocked pages and thus delivering a lower than expected limit to userspace. vfio has this bug, RDMA does not. RDMA has a bug where it can overallocate locked memory, vfio doesn't. Really unclear how to fix this. The pinned/locked split with two buckets may be the right way. Jason