From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932695AbcECC7i (ORCPT ); Mon, 2 May 2016 22:59:38 -0400 Received: from mga03.intel.com ([134.134.136.65]:17311 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932232AbcECC7g convert rfc822-to-8bit (ORCPT ); Mon, 2 May 2016 22:59:36 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,570,1455004800"; d="scan'208";a="797390198" From: "Tian, Kevin" To: Yongji Xie , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kvm@vger.kernel.org" , "linux-doc@vger.kernel.org" CC: "alex.williamson@redhat.com" , "bhelgaas@google.com" , "aik@ozlabs.ru" , "benh@kernel.crashing.org" , "paulus@samba.org" , "mpe@ellerman.id.au" , "corbet@lwn.net" , "warrier@linux.vnet.ibm.com" , "zhong@linux.vnet.ibm.com" , "nikunj@linux.vnet.ibm.com" , "gwshan@linux.vnet.ibm.com" Subject: RE: [PATCH] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive Thread-Topic: [PATCH] vfio-pci: Allow to mmap sub-page MMIO BARs if the mmio page is exclusive Thread-Index: AQHRoH+tlu5pzc5cg0yFTywClD3ty5+mjWnQ Date: Tue, 3 May 2016 02:59:30 +0000 Message-ID: References: <1461759740-5072-1-git-send-email-xyjxie@linux.vnet.ibm.com> In-Reply-To: <1461759740-5072-1-git-send-email-xyjxie@linux.vnet.ibm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzFhMDNiNWUtZDVlNS00NDdkLTllYTItMDVmZjZlOThkOGVkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkFFanZhUDAzXC9kU1hFQkc0Z1Z4YlpydGNUSzhqT1FCNXNEcHNmOEJHXC9QYz0ifQ== x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Yongji Xie > Sent: Wednesday, April 27, 2016 8:22 PM > > Current vfio-pci implementation disallows to mmap > sub-page(size < PAGE_SIZE) MMIO BARs because these BARs' mmio > page may be shared with other BARs. This will cause some > performance issues when we passthrough a PCI device with > this kind of BARs. Guest will be not able to handle the mmio > accesses to the BARs which leads to mmio emulations in host. > > However, not all sub-page BARs will share page with other BARs. > We should allow to mmap those sub-page MMIO BARs which we can > make sure will not share page with other BARs. > > This patch adds support for this case. And we also try to use > shadow resource to reserve the remaind of the page which hot-add > device's BAR might be assigned into. 'shadow' usually means you have a corresponding part being shadowed, while here looks you mostly want some 'dummy' resource for reservation purpose? > + > + if (!(res->start & ~PAGE_MASK)) { > + /* > + * Add shadow resource for sub-page bar whose mmio > + * page is exclusive in case that hot-add device's > + * bar is assigned into the mem hole. > + */ > + shadow_res = kzalloc(sizeof(*shadow_res), GFP_KERNEL); > + shadow_res->resource.start = res->end + 1; > + shadow_res->resource.end = res->start + PAGE_SIZE - 1; What about res->start not page aligned so you end up still having a portion before res->start not exclusively reserved? > + shadow_res->resource.flags = res->flags; > + if (request_resource(res->parent, > + &shadow_res->resource)) { > + kfree(shadow_res); > + return false; > + } > + shadow_res->index = index; > + list_add(&shadow_res->res_next, > + &vdev->shadow_resources_list); > + return true; Thanks Kevin