Message ID | 20240229223544.257207-1-alex.williamson@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp720653dyb; Thu, 29 Feb 2024 14:36:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrNRXZm7mDRsr0QfpLCUdPp0Z/7aqbafbm93AZq6JsqNQ0RqCnXiYr7bJkF2kEMYCtORK2QIpEOy8Ot/rnKLrIvP8/hg== X-Google-Smtp-Source: AGHT+IFeg0HsgrPnYQOljy4th+SX1XAgi6bTp6YLNABjQLiLaHIqI09oZK5uBCn8WkGQjsUsRseO X-Received: by 2002:a05:6358:591c:b0:17b:5c81:839e with SMTP id g28-20020a056358591c00b0017b5c81839emr3894427rwf.7.1709246187559; Thu, 29 Feb 2024 14:36:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709246187; cv=pass; d=google.com; s=arc-20160816; b=UjFzN1Qp+7pQGlNpboPPBUwe5YkT3sDUkvXxL/eMoh4kDyqddG7CEnJ4RFZoFCcosZ 9/9TYCObnxOFzhrsQn0YxIEG5cMKDE5OFEDJSA8TDBcXemjTmgesLPOWnJoW3JRdD9JB 0f2RJQpwt8etQqYvnjsowJmFK3IMrmt3DbxlbjGaiRARbt2mDFqMpLTmfLW3BO3C4a8Z qLX/VRUYHfcq2XO7IPCsU5ewkvwFgswthM0JHPxjYSA2aUJHNOm+iRspsXrK1/mBgk8O oyQqZtbV2vdj2hYVsCXdlNZA+XNJFLAwReP8OBP1NmGoo37VVfa1JhN9AAS4M9dS4Xwa VBmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=pPbMIoaOFEzd4CIJyR5bdcWJChrXb88CaqXQOthl8XY=; fh=l7TYXD6aMcaB+HrFItyOSMpwFGXSeSr9IvczbGdbJxk=; b=sV5g9HjbFsa+eqPakISnynhM9+xZQi08uawPH+jiNH6Tru4hDlYULa9WbDbaES8RkU 2mcPzUEkVSc3WHVvhuNqbf86t6FAxI3uUOyytO3ddlTJO98HCUXdh5hYYLBtWsFvczTo RWsGYtjUiN+zfYJZOYiG2v9LR/TgE6VrWJPMhEIhoNMhFAJG4N91mhhuKJ0gb5Zwmrk0 p4WGpcOg+TkHwZzkcUyPRj8cJfiNpWn9ztw4hBDlNA8tjzzBk/aKTb4RQ6hdya+FQPn4 TuvdkUoPOGGK819iFMEinAe2IimMaSDvKAg13oyxC4FcPivRYKHodpey6NRksgIhNDui edwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b0DTi40j; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gf12-20020a056214250c00b0068f3624fa5fsi2274139qvb.302.2024.02.29.14.36.27 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 14:36:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b0DTi40j; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87646-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 185681C20CFE for <ouuuleilei@gmail.com>; Thu, 29 Feb 2024 22:36:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30A413FB88; Thu, 29 Feb 2024 22:36:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="b0DTi40j" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A44A9200D9 for <linux-kernel@vger.kernel.org>; Thu, 29 Feb 2024 22:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246164; cv=none; b=iEJyZz7yXzzzHq8WQ/iYsb1Mjca55nwM+z5syLFsbAiH+24U2rYL1S6JprP3elTdPp7bXSb+ZugZxaVle9s8zSh8Ij2tTSKlzJuYXa79bS2dp5dckHIVUhTPDZwf2uTU2MWfffnXDHHT897RZs4MqlnHQ9nzeo6w3c6C9iV/gBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709246164; c=relaxed/simple; bh=XiYWXAEkJNz3jiTdHBo8zNvpfm3+VlZhC+wdvHcT8wc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EcW+GjcpaQoT8lIDsUwnZOdLZr03ui1DxAL7GTRWNSz9WDr1fG7kfa2O6REbCg//h3c/ou7l952o7KmOlBgx3hbK5lWYa3wQrsRmt1uQpFNFjoAdGlTs9IsNSQ/crNrRPh745blEMyeKcBlyi0Q+b011u42cX90aEOsFwxfYUH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=b0DTi40j; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709246161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pPbMIoaOFEzd4CIJyR5bdcWJChrXb88CaqXQOthl8XY=; b=b0DTi40jb432G4jVZ7Sq7W6EG3xOwvZvnvvWg3ZYG7aLAlSR01hoIaeShLpoA5LlDpGXaB LcUk0qh1Dc9WlgioCbgmT89mnTlMfw2Etl0/H27Zl+n2fJcuqut/0+j5LenyqS+98ty2du 3RwMLewnpNWAye0LLlK3T0lQjeWZeEs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-TJBCsRcINEiRxl9Vde4ifw-1; Thu, 29 Feb 2024 17:35:59 -0500 X-MC-Unique: TJBCsRcINEiRxl9Vde4ifw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D296800074; Thu, 29 Feb 2024 22:35:57 +0000 (UTC) Received: from omen.home.shazbot.org (unknown [10.22.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF4872166AE8; Thu, 29 Feb 2024 22:35:56 +0000 (UTC) From: Alex Williamson <alex.williamson@redhat.com> To: alex.williamson@redhat.com Cc: david@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Revert "vfio/type1: Unpin zero pages" Date: Thu, 29 Feb 2024 15:35:40 -0700 Message-ID: <20240229223544.257207-1-alex.williamson@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792274530498803837 X-GMAIL-MSGID: 1792274530498803837 |
Series |
Revert "vfio/type1: Unpin zero pages"
|
|
Commit Message
Alex Williamson
Feb. 29, 2024, 10:35 p.m. UTC
This reverts commit 873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4.
This was a heinous workaround and it turns out it's been fixed in mm
twice since it was introduced. Most recently, commit c8070b787519
("mm: Don't pin ZERO_PAGE in pin_user_pages()") would have prevented
running up the zeropage refcount, but even before that commit
84209e87c696 ("mm/gup: reliable R/O long-term pinning in COW mappings")
avoids the vfio use case from pinning the zeropage at all, instead
replacing it with exclusive anonymous pages.
Remove this now useless overhead.
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/vfio/vfio_iommu_type1.c | 12 ------------
1 file changed, 12 deletions(-)
Comments
On 29.02.24 23:35, Alex Williamson wrote: > This reverts commit 873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4. > > This was a heinous workaround and it turns out it's been fixed in mm > twice since it was introduced. Most recently, commit c8070b787519 > ("mm: Don't pin ZERO_PAGE in pin_user_pages()") would have prevented > running up the zeropage refcount, but even before that commit > 84209e87c696 ("mm/gup: reliable R/O long-term pinning in COW mappings") > avoids the vfio use case from pinning the zeropage at all, instead > replacing it with exclusive anonymous pages. > > Remove this now useless overhead. > > Suggested-by: David Hildenbrand <david@redhat.com> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com> > --- > drivers/vfio/vfio_iommu_type1.c | 12 ------------ > 1 file changed, 12 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index b2854d7939ce..b5c15fe8f9fc 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -567,18 +567,6 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, > ret = pin_user_pages_remote(mm, vaddr, npages, flags | FOLL_LONGTERM, > pages, NULL); > if (ret > 0) { > - int i; > - > - /* > - * The zero page is always resident, we don't need to pin it > - * and it falls into our invalid/reserved test so we don't > - * unpin in put_pfn(). Unpin all zero pages in the batch here. > - */ > - for (i = 0 ; i < ret; i++) { > - if (unlikely(is_zero_pfn(page_to_pfn(pages[i])))) > - unpin_user_page(pages[i]); > - } > - > *pfn = page_to_pfn(pages[0]); > goto done; > } Reviewed-by: David Hildenbrand <david@redhat.com>
> From: Alex Williamson <alex.williamson@redhat.com> > Sent: Friday, March 1, 2024 6:36 AM > > This reverts commit 873aefb376bbc0ed1dd2381ea1d6ec88106fdbd4. > > This was a heinous workaround and it turns out it's been fixed in mm > twice since it was introduced. Most recently, commit c8070b787519 > ("mm: Don't pin ZERO_PAGE in pin_user_pages()") would have prevented > running up the zeropage refcount, but even before that commit > 84209e87c696 ("mm/gup: reliable R/O long-term pinning in COW mappings") > avoids the vfio use case from pinning the zeropage at all, instead > replacing it with exclusive anonymous pages. > > Remove this now useless overhead. > > Suggested-by: David Hildenbrand <david@redhat.com> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index b2854d7939ce..b5c15fe8f9fc 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -567,18 +567,6 @@ static int vaddr_get_pfns(struct mm_struct *mm, unsigned long vaddr, ret = pin_user_pages_remote(mm, vaddr, npages, flags | FOLL_LONGTERM, pages, NULL); if (ret > 0) { - int i; - - /* - * The zero page is always resident, we don't need to pin it - * and it falls into our invalid/reserved test so we don't - * unpin in put_pfn(). Unpin all zero pages in the batch here. - */ - for (i = 0 ; i < ret; i++) { - if (unlikely(is_zero_pfn(page_to_pfn(pages[i])))) - unpin_user_page(pages[i]); - } - *pfn = page_to_pfn(pages[0]); goto done; }