From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FEDAC43463 for ; Mon, 21 Sep 2020 10:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E89B0205F4 for ; Mon, 21 Sep 2020 10:21:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JYMtdLld" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgIUKVu (ORCPT ); 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