Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3025873pxk; Mon, 21 Sep 2020 03:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUlq16yp5Km3Mj5C9RGRqEdqQbhwnTBTxy0DxKqwxsk+LYEiWfGHSaX6frphXVI0FJZ7eW X-Received: by 2002:a17:907:9c3:: with SMTP id bx3mr49567149ejc.164.1600683979302; Mon, 21 Sep 2020 03:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600683979; cv=none; d=google.com; s=arc-20160816; b=ynxlz6wXy8W0l2B8jUo6GUqh1gtZZdtYSsitaBPkQOAEDi5mqflzIvRKcoEi0ygGvR oAeD/WAwX5z+/u09ss3HWWK9clSHPECthdzWaLisKo/676GzA4dBOoN9BhwVxhvORK0A s3vs5872scXB2sgNoi0eez3WaQbtFI8JCIcPy/OJQEecuyhs2Yi8vbai9mufgMUkUrOC Wg2KvqzIau/HUX9ed/6gjCcLekI029g3aBGrKdeTeJYJivooyZXFrxEGSeB92FBalTXx WmPIU5PXXjYkh6CoTUkejZx3HQWzouenZS2NYQmAEhLZLa5Et2LqQYoFu+x1WrCrbIGe FUCA== 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=nXLSRgJ1NwJlygVsKMNwZZ5/k5tFxWzlJPyhSnYKIn0=; b=YI4vSCZpYioWwv53E82j+/JqD4k7oWek4o3eyIhHeHfXZd8+6wG6BTpyAcSO7Eazbv rCua97pnTXNKNFfpD3yXEMtVX6x5+gkrxi6J1FUrvMHYKLLmOc8gJy82mLYXA1Isx85o LNmNAmWUatk53+XKYPzoLy2jpO841G/ag7dhXcGzm0U+gDHtBwjrP3Xeih/ULTFkabIx iMdOIKKYDV2ISOKWt+c6/7yrsf4+4Op+CGZX+n3Fgv3cVQXPTaF1EY7P7V7v75yAX7aT NGkW6UyEO34z9MLTIXhB3mkq2dI/cYu6CNcnz4dCrf8Mj6Px9DqeM7uRlwR6rvoiJn78 UX+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JYMtdLld; 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 d23si7756683edt.338.2020.09.21.03.25.55; Mon, 21 Sep 2020 03:26:19 -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=JYMtdLld; 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 S1727000AbgIUKVu (ORCPT + 99 others); Mon, 21 Sep 2020 06:21:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39856 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbgIUKVr (ORCPT ); Mon, 21 Sep 2020 06:21:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600683706; 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=nXLSRgJ1NwJlygVsKMNwZZ5/k5tFxWzlJPyhSnYKIn0=; b=JYMtdLldXRBzPrF0ZWGD3BXT/MnkkAeA2eeynBqiy7FveayNfVuaOsIPGAZJJxdCqaoBPn n8h5kcK1/Y5CDMqnIyFnJ18gbwuYcs7SHA+Xp8xau4tHfF+atALBNvJZZDLM1LRAcyz3cK eofRdoAo3ZI6BbVx/zTwJB5O5peOKXo= 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-376-1nOGtU6IOIqAV3FA_Qw7cw-1; Mon, 21 Sep 2020 06:21:44 -0400 X-MC-Unique: 1nOGtU6IOIqAV3FA_Qw7cw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEE77107464F; Mon, 21 Sep 2020 10:21:42 +0000 (UTC) Received: from gondolin (ovpn-112-187.ams2.redhat.com [10.36.112.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E42310013D0; Mon, 21 Sep 2020 10:21:37 +0000 (UTC) Date: Mon, 21 Sep 2020 12:21:34 +0200 From: Cornelia Huck To: Zenghui Yu Cc: , , , Subject: Re: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty Message-ID: <20200921122134.5c7794f3.cohuck@redhat.com> In-Reply-To: <20200921045116.258-2-yuzenghui@huawei.com> References: <20200921045116.258-1-yuzenghui@huawei.com> <20200921045116.258-2-yuzenghui@huawei.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Sep 2020 12:51:16 +0800 Zenghui Yu wrote: > Now we regenerate vconfig for all the BARs via vfio_bar_fixup(), every time > any offset of any of them are read. Though BARs aren't re-read regularly, > the regeneration can be avoid if no BARs had been written since they were s/avoid/avoided/ > last read, in which case the vdev->bardirty is false. s/the// > > Let's predicate the vfio_bar_fixup() on the bardirty so that it can return > immediately if !bardirty. Maybe "Let's return immediately in vfio_bar_fixup() if bardirty is false." ? > > Suggested-by: Alex Williamson > Signed-off-by: Zenghui Yu > --- > * From v1: > - Per Alex's suggestion, let vfio_bar_fixup() test vdev->bardirty to > avoid doing work if bardirty is false, instead of removing it entirely. > - Rewrite the commit message. > > drivers/vfio/pci/vfio_pci_config.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c > index d98843feddce..5e02ba07e8e8 100644 > --- a/drivers/vfio/pci/vfio_pci_config.c > +++ b/drivers/vfio/pci/vfio_pci_config.c > @@ -467,6 +467,9 @@ static void vfio_bar_fixup(struct vfio_pci_device *vdev) > __le32 *vbar; > u64 mask; > > + if (!vdev->bardirty) Finally, bardirty can actually affect something :) > + return; > + > vbar = (__le32 *)&vdev->vconfig[PCI_BASE_ADDRESS_0]; > > for (i = 0; i < PCI_STD_NUM_BARS; i++, vbar++) { Reviewed-by: Cornelia Huck