Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3064341pxk; Mon, 21 Sep 2020 04:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8i7Kua/8UJ6BXIixDv3MgHrbyVagMNkGxLopLggTit3I8B3oRGfu1M8oYodJBsf6XgqWF X-Received: by 2002:a17:906:4c81:: with SMTP id q1mr48019524eju.72.1600687797368; Mon, 21 Sep 2020 04:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600687797; cv=none; d=google.com; s=arc-20160816; b=sFMaR5JI/ZjiHCGxszPg9Dt/8f9XntzKgKwBIQWFwO+gBcX6uF9MnSW8e8RKau/kgf RUbkJbKtXbqGsAwRDMMnBq65/xS06ZXkwPKlf00cekcadNeNpwC5uJEsKrmC2VpJYCrE AQBU/gCZgcr6DKV7NfrsL88x8JVZI9uQs3mdwhcIVFv59TrFCQSfBl3m/nmFQ5BFD11p elE3PrAAubndCDz93XpBacKMdR44CmvzhPEz39cnW8S7xSnWnb0mlJEufAiLPMW0k/h6 VY2Lxumo8JmFo5VGuDg36elfbWgf3zwuz7yAF+l4RpUwQzYXdsdts35Qq/2eAinlYpJo wf7Q== 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=X115ykry/eY4HUS381SC5zSwNO7HeZR9lzem4a3dRic=; b=0Rxg6SExxfGN7wZO2h1GquDtMBf4CkVGCOtne5nHutruRzblxB17gv9fw3pQRV5xO7 G4ObY78Lg1YJIzm3kOeujvhcw8VIsnHC3wfjVZisgIb2qdLHVnCmi48pPnIrbwyoolt7 aNidDlmxb7VtcKdA29xQfwmO+84LfM12RkEoW0EXzoNepOwO8xAZsneZoR59ncMRSZde RA6OSWecKoZW51rtSv6WcVCzvkBKeILAAMnqu0oGR3jUQMZzS27/mV/1IZk+uIseczTz ih8o60wMZnlatI2xLgrEqYT2fkXzBu5CwZ0rb8vReWdTQxs7REPbIolx9HXXWGcK61iH Igdg== 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 q4si7950416edg.483.2020.09.21.04.29.33; Mon, 21 Sep 2020 04:29:57 -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 S1726444AbgIUL2e (ORCPT + 99 others); Mon, 21 Sep 2020 07:28:34 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13794 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726341AbgIUL2d (ORCPT ); Mon, 21 Sep 2020 07:28:33 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 012EF6E65A88CFDEF61C; Mon, 21 Sep 2020 19:28:32 +0800 (CST) Received: from [10.174.185.226] (10.174.185.226) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Mon, 21 Sep 2020 19:28:25 +0800 Subject: Re: [PATCH v2 2/2] vfio/pci: Don't regenerate vconfig for all BARs if !bardirty To: Cornelia Huck CC: , , , References: <20200921045116.258-1-yuzenghui@huawei.com> <20200921045116.258-2-yuzenghui@huawei.com> <20200921122134.5c7794f3.cohuck@redhat.com> From: Zenghui Yu Message-ID: <8cc2acc1-6eaa-8ed0-db78-7ff5dc36828d@huawei.com> Date: Mon, 21 Sep 2020 19:28:25 +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: <20200921122134.5c7794f3.cohuck@redhat.com> 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 Cornelia, On 2020/9/21 18:21, Cornelia Huck wrote: > 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." ? Yes. >> >> 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 Thanks for you review! I think Alex can help fix the commit message when applying? Otherwise I can send a v3. Thanks, Zenghui