Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1105397ybj; Thu, 7 May 2020 15:06:02 -0700 (PDT) X-Google-Smtp-Source: APiQypLhK7XUxnqRNKkEbGuCGNQPbPUeoREwdMxkHI+LyPYdh/ysxy08H6Fmg0qyRrl7aM167bkJ X-Received: by 2002:a17:906:b217:: with SMTP id p23mr13726344ejz.136.1588889162751; Thu, 07 May 2020 15:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588889162; cv=none; d=google.com; s=arc-20160816; b=ifbJ0xD9BosZoiiai04IXcwJ+EUezN0tTveiTpJBucR5OKJxIYqUA8MgMKxZLSFBCT MSzBVm/4mTPO/7UGk4pkNWLdQNZjJZ6GSdKpUZr2yOflBuS/POQHCrS+8ukdixSPm2P1 VV5jcCHD0dodlvjHxY7IiztdkwyODZt540HPIzsLtpmuEflngocMD1iV9Ud+ARvq+tZ4 +idi/4bbSS9f7bq2VXLihhCHaMY+kjhqM2CVCwXzhvvLg9YSqiOy95V+T1D1tns94kAN zgO45vIs5trP+00tQ60hce/0e8XSbtuSOcGo1sLlB0UX9maCVOYq+h5njlOPkkZDrxEt 8AtA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=aspV1wJ37EFxEstXvcVEniumgTmeoY91YcA15b/xS8E=; b=Yt5qnSQlRoZk5xTecLCHnB/w8oSxNxANUaP4vwNUooIYBQrPwN8jU32OflNOKJi6mY cVbxO/S0wymstjMp/daiu/jf8LGCiCrLuunxPJei50Hmut8LrgM3rOVxYk//p0fRkLJc gzcY8bkZCEbDugNHs8nuClBR9Y8ASj1lGUdu3/eHL37Qds/8rUB5uMrGTnF/dTVHq183 FRBdPnqgQc19lcdCI23SsMlaWeWrJbXQkJeEpTuSKxEbf7erHAJGIGC9pI0hjC9QPf09 juwKtPH5qJT7318rQ/mys2fczzLxKYcsMYBMcsvIb3xCI9QCQBIejeSNeGWMh8oCuqxH eT1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LU7nxNbD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si3958899edr.444.2020.05.07.15.05.38; Thu, 07 May 2020 15:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LU7nxNbD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgEGWDo (ORCPT + 99 others); Thu, 7 May 2020 18:03:44 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60275 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726464AbgEGWDo (ORCPT ); Thu, 7 May 2020 18:03:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588889023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aspV1wJ37EFxEstXvcVEniumgTmeoY91YcA15b/xS8E=; b=LU7nxNbDItAGiU4CfK7K3bjKk9iTvV3dqSVhnYGOu8XIZi/F9jOjpGIsuLuDzJwEJTKzQA N7/1TSrjcII7wRi0zoMCprOXozREsBM9l6ifR0jDmVz4impPV9FLKPiYwCVYs1/eeKqazF gxIq7tcouwJZTszbPPkoTKYzxlh1r6g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-LL_F_fyvPrOgRP04awRMaA-1; Thu, 07 May 2020 18:03:39 -0400 X-MC-Unique: LL_F_fyvPrOgRP04awRMaA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63581180081D; Thu, 7 May 2020 22:03:38 +0000 (UTC) Received: from x1.home (ovpn-113-95.phx2.redhat.com [10.3.113.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id AED8B579AD; Thu, 7 May 2020 22:03:34 +0000 (UTC) Date: Thu, 7 May 2020 16:03:34 -0600 From: Alex Williamson To: Peter Xu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, cohuck@redhat.com, jgg@ziepe.ca Subject: Re: [PATCH v2 2/3] vfio-pci: Fault mmaps to enable vma tracking Message-ID: <20200507160334.4c029518@x1.home> In-Reply-To: <20200507214744.GP228260@xz-x1> References: <158871401328.15589.17598154478222071285.stgit@gimli.home> <158871569380.15589.16950418949340311053.stgit@gimli.home> <20200507214744.GP228260@xz-x1> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 May 2020 17:47:44 -0400 Peter Xu wrote: > Hi, Alex, > > On Tue, May 05, 2020 at 03:54:53PM -0600, Alex Williamson wrote: > > +/* > > + * Zap mmaps on open so that we can fault them in on access and therefore > > + * our vma_list only tracks mappings accessed since last zap. > > + */ > > +static void vfio_pci_mmap_open(struct vm_area_struct *vma) > > +{ > > + zap_vma_ptes(vma, vma->vm_start, vma->vm_end - vma->vm_start); > > A pure question: is this only a safety-belt or it is required in some known > scenarios? It's not required. I originally did this so that I'm not allocating a vma_list entry in a path where I can't return error, but as Jason suggested I could zap here only in the case that I do encounter that allocation fault. However I still like consolidating the vma_list handling to the vm_ops .fault and .close callbacks and potentially we reduce the zap latency by keeping the vma_list to actual users, which we'll get to eventually anyway in the VM case as memory BARs are sized and assigned addresses. > In all cases: > > Reviewed-by: Peter Xu Thanks! Alex