Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2643319pxb; Tue, 9 Mar 2021 07:31:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxItNCMrSrFu9A5bJp/NqQv2TEVFMwUaG7nZvr1OpfkpodnX2NAInpsNyJ91Ly9GYUFoxkK X-Received: by 2002:a1c:3c8b:: with SMTP id j133mr4689730wma.164.1615303908554; Tue, 09 Mar 2021 07:31:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615303908; cv=none; d=google.com; s=arc-20160816; b=KPFcczfTV9LiDG/NhSgCdLn6NJlmF1aNThc6xOIqQCyNapGXcUCKZFHHnqhNDBpyLj pnV4oa0yzvXUUuYjuE0ovjzLppQOrsw16PvnSvkPA9maGjn9/MTggGEc28MPdBnMEir1 6+koorGhfvchH5+KNteXBJq6NjMZulWuhSiufZkjSuoPQrHGVk3G8wfDdVf+gwDqBhd6 H18pq7TBPEOtf7nmVWr28rEygWmO2hz7Hlcb9Edu4vOe4S89hAmQSLj8ZX0G65kdVvFT atTP7Veb3NZQjbll9+JJul7iQCA85uQh6wOzupkSNxXaDaekOjMx044ntmwSgLX0zRAS yHcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=4jxpAuLrdI2KEsxNtc6yigl8rRFIzhCgLVMdHGZZ+fc=; b=oXrTKmV7rPSpgUGrz6xSCTIj96tnlWi14UzTyDT3HTFTZ+KROzr2blWJuMYr+vB0RC xFGywtxPXrQVKmgH9+3RpzBGjZ8h7AUWmml4d2U/qNmK+IXZexOjG8lgLbaID7e960dn rmeOkFhpQ1iZzoaZTZ/kjRvmcEe3NdF+wpPdKmoq5VxSJaW3jkqxfh+aCEa9Lqk6HB41 mKgg8ZnuHlUB1DK3YKxUTt4X0mNAb6s2vb3WhOHax7V3ko6JnwRSHfrshdpxhA9NRRo6 ymMTk6jlqFU73LRETM1aOYnRMj98T0hz4pwuKs0YazG2GcoZxej7V5mdd6BO5fo6BgNZ KzlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YZmdyplQ; 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 j21si9284677edh.58.2021.03.09.07.31.26; Tue, 09 Mar 2021 07:31:48 -0800 (PST) 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=YZmdyplQ; 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 S231915AbhCIPaO (ORCPT + 99 others); Tue, 9 Mar 2021 10:30:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49354 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231891AbhCIPaD (ORCPT ); Tue, 9 Mar 2021 10:30:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615303802; 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=4jxpAuLrdI2KEsxNtc6yigl8rRFIzhCgLVMdHGZZ+fc=; b=YZmdyplQwxeUA0QcW+ZWNKr2iXWkUHzLCcyUzpUAfMazbykwJERis0/qd0SAVrItnoxn1w Adh7Xzi+7tE0KiP+oUyptEgXcg9IsNFKvC/Gwmu0ZLLXAnEZEIsy33UZQ6zAAyyT0aR79o fnsKzQzbzy4rUB1ZNv5mmSaZNStinvk= 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-299-PMx_YHNmNgK-G03W2rIzkA-1; Tue, 09 Mar 2021 10:29:59 -0500 X-MC-Unique: PMx_YHNmNgK-G03W2rIzkA-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 2509057; Tue, 9 Mar 2021 15:29:57 +0000 (UTC) Received: from x1.home.shazbot.org (ovpn-112-255.phx2.redhat.com [10.3.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 443A060CF0; Tue, 9 Mar 2021 15:29:52 +0000 (UTC) Date: Tue, 9 Mar 2021 08:29:51 -0700 From: Alex Williamson To: Jason Gunthorpe Cc: "Zengtao (B)" , Peter Xu , Cornelia Huck , Kevin Tian , Andrew Morton , Giovanni Cabiddu , Michel Lespinasse , Jann Horn , Max Gurtovoy , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Linuxarm Subject: Re: [PATCH] vfio/pci: make the vfio_pci_mmap_fault reentrant Message-ID: <20210309082951.75f0eb01@x1.home.shazbot.org> In-Reply-To: <20210309124609.GG2356281@nvidia.com> References: <1615201890-887-1-git-send-email-prime.zeng@hisilicon.com> <20210308132106.49da42e2@omen.home.shazbot.org> <20210308225626.GN397383@xz-x1> <6b98461600f74f2385b9096203fa3611@hisilicon.com> <20210309124609.GG2356281@nvidia.com> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 9 Mar 2021 08:46:09 -0400 Jason Gunthorpe wrote: > On Tue, Mar 09, 2021 at 03:49:09AM +0000, Zengtao (B) wrote: > > Hi guys: > > > > Thanks for the helpful comments, after rethinking the issue, I have proposed > > the following change: > > 1. follow_pte instead of follow_pfn. > > Still no on follow_pfn, you don't need it once you use vmf_insert_pfn vmf_insert_pfn() only solves the BUG_ON, follow_pte() is being used here to determine whether the translation is already present to avoid both duplicate work in inserting the translation and allocating a duplicate vma tracking structure. > > 2. vmf_insert_pfn loops instead of io_remap_pfn_range > > 3. proper undos when some call fails. > > 4. keep the bigger lock range to avoid unessary pte install. > > Why do we need locks at all here? For the vma tracking and testing whether the fault is already populated. Once we get rid of the vma list, maybe it makes sense to only insert the faulting page rather than the entire vma, at which point I think we'd have no reason to serialize. Thanks, Alex