Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3143194imj; Mon, 11 Feb 2019 14:51:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IZkxfujG31M66pBEnrPrikF4A6ZCBrISkFiKhHcdxeXTFr/Wlu2Jh9hx5yexUVTTpBPFODB X-Received: by 2002:a63:5153:: with SMTP id r19mr577133pgl.281.1549925501215; Mon, 11 Feb 2019 14:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549925501; cv=none; d=google.com; s=arc-20160816; b=R+GWEHqGatmCSECzhk/L4XCyqGE+WhF/UwhUq4/3J6FUCtoTUyh0xkxgv+VfOe/iaq S09o5sItCB1rtj78Kr6IKC1HsNppIsDzKdZqt7IoPwnLEu/zfCg2pPrzPn4R8ERS6sgC VA15gaWWstb9RuEEsi1yXShzUXZXVtU/R3dDCEtMBtEqRtgTeyJk2YA9SiX+2O/WoxR6 DxvqfP0UTTMNByrMi5Y+QXmq68wTdd6A80pv+Np20EuvRe49u3XaxPv8PZxckIyUX9RO d2zwHFqghWMwRVzD1do9UvdxHmpxKfCPU0zNXR1wLFAuE3qA4NsM9bIEu4Mlj/LaiRpG vmAw== 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=g/wkTXu46FNOCtPsm2RcpgDTiMDCp2Wv41qyxuMJ8uw=; b=fP4m2miQxCSGdae7u+pvJ895v91M70f9Ghf+SLMRIHdS2rWn2+YJOjVDaeXqH6EEV2 ZYfI8bOorNy+ICrXzTDkec6aaCUfZ5+vE4dloMED6blO2RG69LH0ZU77iwWQO+f/r7FI 4m0K1gkEfonQJRSCwgdRV6kHuOIN7qh4aEms1sbi8tfsWdSUox50a8YbT70ET/R1NoeE EezL9qPEdYZzK4ynZfr3OEuHHCuHfRtPQVMrFf9UDHk71af4A/Vs6sQbFdYun9hYERvj p3PzZy9pLXaRKLYY1PGHZRK7h8UwRqvc2M5p1/nOh11bVfZF+kAlRVjz5YxjLu2T3/wF HyzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Xyicrd65; 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 71si11637123plb.8.2019.02.11.14.51.25; Mon, 11 Feb 2019 14:51:41 -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=Xyicrd65; 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 S1727598AbfBKWuz (ORCPT + 99 others); Mon, 11 Feb 2019 17:50:55 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43059 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbfBKWuy (ORCPT ); Mon, 11 Feb 2019 17:50:54 -0500 Received: by mail-pg1-f196.google.com with SMTP id v28so241410pgk.10 for ; Mon, 11 Feb 2019 14:50:54 -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=g/wkTXu46FNOCtPsm2RcpgDTiMDCp2Wv41qyxuMJ8uw=; b=Xyicrd65GrNQI2Ux5ANGkLgkEuWZD+V8zy3lXCzVtCwHfz+Pxa5RqFgZPBlj/bQR1x 4o8n5wvByoZRcFE9M3AaAY3O16dGh1VDI3zvsic+R30HCkc4h1VvB4DicoF6eiJTc6tf oVEfSVLiFE4J63MZduYr+ZlerunKjxa7az7slCF6bcMu8qHtEe7WvQLcVGuyLNaZhHST U1NYwp8s4lnQmY+x83d71JHYQcZ0AqTTSHuZ66NQfUwNPWkKOj86y7snH64M7fz47UhO GvT88qxEaj02hIYWJwcccVe66PSGXxw4YqdBuaYVWdhsK8trnOv2m0nCOq9M9ywl0SPc V9ig== 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=g/wkTXu46FNOCtPsm2RcpgDTiMDCp2Wv41qyxuMJ8uw=; b=MBzcd7PfQwW73tp49fjY7hXNLPpf405CGLf4pcPtLjKXBFtQ7Ams06lv3/kpCrdgwF DoSelgBLhl0gYPGYKaRJ9CL9dr9E8R/FLmNNXzPaR4c/M2P7CN+pimwG0VTdQ+523IFh R3ATOvBMaNgSYT1hpimL1fTmzL1tBqb6OmJTLz9aQ7fv5tSJLF/XeEGYz8OSauRB5Urx u4NgVgm0/o/nV454WxdSLX5zvZ8c0dTPx7ciWSSLPR4RNSazfeMWnMzlqbzKuyphumq8 gLuCBD/THW+FpbqSgkZVg83SfNI5IMc4p40UTuGjKkOc61akGUQQ470Gm6RDRKe3idrl 2Mpw== X-Gm-Message-State: AHQUAubtAiaOFlUzN66d3JyBbBOtu6NXTujtVaaFOobBz3HvoZcPjSyF jUb9L+j0jVL74ggtFPmJBDlONw== X-Received: by 2002:aa7:8199:: with SMTP id g25mr698005pfi.46.1549925453650; Mon, 11 Feb 2019 14:50:53 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id a187sm10236492pfb.61.2019.02.11.14.50.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 14:50:52 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1gtKPc-0003PQ-8i; Mon, 11 Feb 2019 15:50:52 -0700 Date: Mon, 11 Feb 2019 15:50:52 -0700 From: Jason Gunthorpe To: "Weiny, Ira" Cc: "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Daniel Borkmann , "netdev@vger.kernel.org" , "Marciniszyn, Mike" , "Dalessandro, Dennis" , Doug Ledford , Andrew Morton , "Kirill A. Shutemov" , "Williams, Dan J" Subject: Re: [PATCH 0/3] Add gup fast + longterm and use it in HFI1 Message-ID: <20190211225052.GL24692@ziepe.ca> References: <20190211201643.7599-1-ira.weiny@intel.com> <20190211203417.a2c2kbmjai43flyz@linux-r8p5> <20190211204710.GE24692@ziepe.ca> <20190211214257.GA7891@iweiny-DESK2.sc.intel.com> <20190211222208.GJ24692@ziepe.ca> <2807E5FD2F6FDA4886F6618EAC48510E79BCF37B@CRSMSX101.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2807E5FD2F6FDA4886F6618EAC48510E79BCF37B@CRSMSX101.amr.corp.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 Mon, Feb 11, 2019 at 10:40:02PM +0000, Weiny, Ira wrote: > > Many drivers do this, the 'doorbell' is a PCI -> CPU thing of some sort > > My surprise is why does _userspace_ allocate this memory? Well, userspace needs to read the memory, so either userpace allocates it and the kernel GUP's it, or userspace mmap's a kernel page which was DMA mapped. The GUP version lets the doorbells have lower alignment than a PAGE, and thes RDMA drivers hard requires GUP->DMA to function.. So why not use a umem here? It already has to work. > > > This does not seem to be allocating memory regions. Jason, do you > > > want a patch to just convert these calls and consider it legacy code? > > > > It needs to use umem like all the other drivers on this path. > > Otherwise it doesn't get the page pinning logic right > > Not sure what you mean regarding the pinning logic? The RLIMIT_MEMLOCK stuff and so on. > > There is also something else rotten with these longterm callsites, > > they seem to have very different ideas how to handle > > RLIMIT_MEMLOCK. > > > > ie vfio doesn't even touch pinned_vm.. and rdma is applying > > RLIMIT_MEMLOCK to mm->pinned_vm, while vfio is using locked_vm.. No > > idea which is right, but they should be the same, and this pattern should > > probably be in core code someplace. > > Neither do I. But AFAIK pinned_vm is a subset of locked_vm. I thought so.. > So should we be accounting both of the counters? Someone should check :) Since we don't increment locked_vm when we increment pinned_vm and vfio only checke RLIMIT_MEMLOCK against locked_vm one can certainly exceed the limit by mixing and matching RDMA and VFIO pins in the same process. Sure seems like there is a bug somewhere here. Jason