Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1623102pxk; Fri, 18 Sep 2020 18:57:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC32F70p4dPIUtMk/zg9+86/U12W1xStBdUgFPw8sh0YgV0p2s5uKH37aNvi+dCabbXB6/ X-Received: by 2002:a17:906:19c7:: with SMTP id h7mr38250578ejd.517.1600480642294; Fri, 18 Sep 2020 18:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600480642; cv=none; d=google.com; s=arc-20160816; b=pzdnkHk7RuAdb/gxiCEyIQwpOYa2GmaxJO2oRvNJj73iFaDhydnZSbhKN7SzrrTOAP EmUUiauJMVceSAfdc2OLAS82Cgc5nxDWd52Qd+xHZn/y4mjcS2qBuXE/H1y1NAk1qx26 HuOznusCJcmwp4GI10xbfd5yNAJ/cJmGKxYgHaN5RHt31E8aRp3ZhfjqWIPgO90OkG92 /kMG+BKkf8LooWk2m31kBShxNRvwGH/YikYBpe3DqEJG46HLK7t6I4SefgUVip2QMT2N DGxHCQ7oP5kPhPK7IS1wDS78zqgNbmkE8COg40KwR01+0iSVa5/z3YfEjPMIgpZrqb8I aXLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=FD9Q5Uwq6TYaHQdVjRTe4P3DdA6aOYz/jtoqtcMNXKI=; b=HW1+PVO7dcqFndl0TvmE/lItfifWn/pVqv7Zbk2Vos+86GbLLF6wo/oOfSc8b/OG/N 4Ns1u1jQW8j4hXQ6WK52KxsH/qLPYHycCMXD8wEZHDCggFxfiZjE15mbz6+jwnozROpq o6S8lZ4CilngK380LlAjWd6UwesLGpnD6BqBoAQYadC2elzMTUz4+MZt8yImaq+FxOCw ZfSL19rrt8LRX8qilxacn1MJOdhvccmqJqQyqAxxJlGmcrOghCHw8MVqiOrQbNInAG36 JBFyBdf9JNZY3RUG3sOW+qEbQs7EbSit81UPSyaJ+4EdFoGjCByWXxzClatCFWgWdOP7 OMTA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si3397867ejb.519.2020.09.18.18.56.58; Fri, 18 Sep 2020 18:57:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726308AbgISByI (ORCPT + 99 others); Fri, 18 Sep 2020 21:54:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51176 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726054AbgISByI (ORCPT ); Fri, 18 Sep 2020 21:54:08 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EBEC54A831E356ED8E93; Sat, 19 Sep 2020 09:54:06 +0800 (CST) Received: from [10.174.185.226] (10.174.185.226) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Sat, 19 Sep 2020 09:54:00 +0800 Subject: Re: [PATCH 2/2] vfio/pci: Remove bardirty from vfio_pci_device To: Alex Williamson , Cornelia Huck CC: , , References: <20200917033128.872-1-yuzenghui@huawei.com> <20200917033128.872-2-yuzenghui@huawei.com> <20200917133537.17af2ef3.cohuck@redhat.com> <20200917160742.4e4d6efd@x1.home> From: Zenghui Yu Message-ID: <3b5214f9-9e17-2bcd-1b92-57bacc1c1b31@huawei.com> Date: Sat, 19 Sep 2020 09:54:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200917160742.4e4d6efd@x1.home> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.185.226] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); Thanks, Zenghui