Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1629352pxk; Fri, 18 Sep 2020 19:13:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuTsYmOssqorB5tNOn82EGxxOXbXZGJUjnXmO2qoPyMp/dff/GfSUQOltMDx/M4j8JRDEv X-Received: by 2002:aa7:d4d0:: with SMTP id t16mr41864679edr.83.1600481587883; Fri, 18 Sep 2020 19:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600481587; cv=none; d=google.com; s=arc-20160816; b=00XiPm6kl6pAwTc45uVV2G2GhGmrEWOtDjxmSJyooRk8L33rljSNlTeKXYs3kkXCsK q945tWoKjBRTONpcxVDV3NtdWMvgCcrNdlZ1goOZDdeLBRxZy4oTBU0SoH2YXz6brrhl 0tfK9FwGHfJfWO7qzCWWj8aVen9cAKfQkGyuZ3noqNMng9oZUWP9x7d0Mcq5neJvZx+k dWrTHTRxrezBFYU7vZYM8jI9xUzfvgvPmyDpvNaPE86nUU7ygAfJk0VTVQX6ixLDj6sZ NXJRqLUZMTEJBqM3kobkJXqrllq4fB+LMh3z3X9ootFM32/OW64qPt/5rHhGLPJJvzfL lQNw== 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=1fWqbBBRX5EVeWNpvGlaoHo5M6bYu8vy+AmYAkNS+X4=; b=vIeg63LrtoploHPRG5b/6McVt7DVrA03R2xSIY2ubdBuhfn2X5LhnB7TYyBcz4fEZZ ODGy5BvfH3FTyyWsUJZYPAWy15byjIgDScJB+V2KOy4I2HgDdQw8GIa9N8PSG60zOpoj 81r0EoqV/ilw5DBHEdYgVbF3Oa1zrAxwafjfcvB0hwiWbb69kAEx1wbcYKBIpVCHWGvU ChsHAnE8RHEReDlk5cV4QQlsyYMh0aurt3HsVh2eL9WVvC+IoFD49SDDIGxT7s61suZR G7HylP7bcfHOFxXt+Sypa/z1/ImPUssSrQvrMbEtu2pCK4EGPe9EBuv05s+12SzP3dlU SYkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FzCBVfPx; 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 lx24si3379146ejb.89.2020.09.18.19.12.44; Fri, 18 Sep 2020 19:13:07 -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=FzCBVfPx; 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 S1726134AbgISCLe (ORCPT + 99 others); Fri, 18 Sep 2020 22:11:34 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:30146 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726054AbgISCLe (ORCPT ); Fri, 18 Sep 2020 22:11:34 -0400 X-Greylist: delayed 117635 seconds by postgrey-1.27 at vger.kernel.org; Fri, 18 Sep 2020 22:11:33 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600481492; 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=1fWqbBBRX5EVeWNpvGlaoHo5M6bYu8vy+AmYAkNS+X4=; b=FzCBVfPx7PTREl6RS+TjrQrnS99aRX5O/7r2fcG36xu+tAX0U0hoYJJSPheUJJ1S+lUP9d VhnXGEokT80Am+j09FFLcZHbpQuLnqLRwBIy1BYmnX49pbQrye3lGOJo7IozaZriLZOrWB p5zPWoLrOSNQQzXy4F62BzpJYXx59+I= 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-450-eSdF0UN0OC6HpK54gdFNUQ-1; Fri, 18 Sep 2020 22:11:30 -0400 X-MC-Unique: eSdF0UN0OC6HpK54gdFNUQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F46E1074665; Sat, 19 Sep 2020 02:11:29 +0000 (UTC) Received: from x1.home (ovpn-112-71.phx2.redhat.com [10.3.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5D6D60BF1; Sat, 19 Sep 2020 02:11:28 +0000 (UTC) Date: Fri, 18 Sep 2020 20:11:28 -0600 From: Alex Williamson To: Zenghui Yu Cc: Cornelia Huck , , , Subject: Re: [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device Message-ID: <20200918201128.16cf0a1c@x1.home> In-Reply-To: <3b5214f9-9e17-2bcd-1b92-57bacc1c1b31@huawei.com> References: <20200917033128.872-1-yuzenghui@huawei.com> <20200917033128.872-2-yuzenghui@huawei.com> <20200917133537.17af2ef3.cohuck@redhat.com> <20200917160742.4e4d6efd@x1.home> <3b5214f9-9e17-2bcd-1b92-57bacc1c1b31@huawei.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.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 19 Sep 2020 09:54:00 +0800 Zenghui Yu wrote: > Hi Alex, > > On 2020/9/18 6:07, Alex Williamson wrote: > > On Thu, 17 Sep 2020 13:35:37 +0200 > > Cornelia Huck wrote: > > > >> On Thu, 17 Sep 2020 11:31:28 +0800 > >> Zenghui Yu wrote: > >> > >>> It isn't clear what purpose the @bardirty serves. It might be used to avoid > >>> the unnecessary vfio_bar_fixup() invoking on a user-space BAR read, which > >>> is not required when bardirty is unset. > >>> > >>> The variable was introduced in commit 89e1f7d4c66d ("vfio: Add PCI device > >>> driver") but never actually used, so it shouldn't be that important. Remove > >>> it. > >>> > >>> Signed-off-by: Zenghui Yu > >>> --- > >>> drivers/vfio/pci/vfio_pci_config.c | 7 ------- > >>> drivers/vfio/pci/vfio_pci_private.h | 1 - > >>> 2 files changed, 8 deletions(-) > >> > >> Yes, it seems to have been write-only all the time. > > > > I suspect the intent was that vfio_bar_fixup() could test > > vdev->bardirty to avoid doing work if no BARs had been written since > > they were last read. As it is now we regenerate vconfig for all the > > BARs every time any offset of any of them are read. BARs aren't > > re-read regularly and config space is not a performance path, > > Yes, it seems that Qemu itself emulates all BAR registers and will read > the BAR from the kernel side only at initialization time. > > > but maybe > > we should instead test if we see any regressions from returning without > > doing any work in vfio_bar_fixup() if vdev->bardirty is false. Thanks, > > I will test it with the following diff. Please let me know which way do > you prefer. > > diff --git a/drivers/vfio/pci/vfio_pci_config.c > b/drivers/vfio/pci/vfio_pci_config.c > index d98843feddce..77c419d536d0 100644 > --- a/drivers/vfio/pci/vfio_pci_config.c > +++ b/drivers/vfio/pci/vfio_pci_config.c > @@ -515,7 +515,7 @@ static int vfio_basic_config_read(struct > vfio_pci_device *vdev, int pos, > int count, struct perm_bits *perm, > int offset, __le32 *val) > { > - if (is_bar(offset)) /* pos == offset for basic config */ > + if (is_bar(offset) && vdev->bardirty) /* pos == offset for basic > config */ > vfio_bar_fixup(vdev); > > count = vfio_default_config_read(vdev, pos, count, perm, > offset, val); There's only one caller currently, but I'd think it cleaner to put this in vfio_bar_fixup(), ie. return immediately if !bardirty. Thanks, Alex