[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH 2/4] VT-d / x86: re-arrange cache syncing


  • To: "Beulich, Jan" <JBeulich@xxxxxxxx>, Andrew Cooper <amc96@xxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Fri, 24 Dec 2021 07:24:22 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4EtgHTgdvoZyWdMxh0XiWHYZjaBSHOGh1WXMaHY8eFw=; b=X++73B9ePwl+QaZuDWwE7X/obzcSrIFx0AHUF/Whe/EtvIq/wZG9MF6coplO49bhEfH5asJvpXgJl8ESdjdsO6U5cy4dmwl/GwSzwrWb663ngrA/0/dFy0QXb1AmM/yMFLDIx37m9EXkofbgh+RQrGlePoD0d3UUJx5cu3CZyDNN0rpWrtNYCy6YChnFFUzy4VCvCyiORTK6zX+0oTldgfpGoxS86oMlJcNji6+BMd+meKiYvqPhVNcWAkhmyXiMu4vQUttwY9333r3R6Z3uem3+oNT3ylAEVLm9kEjYdVoiczC+K/UNRyD+kx1wtPIxphBL3ZN6Qqd2LZjlmFpu/g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=POdWB9GQvLI+SiZbdRexz5YdJGQ7OLhaucCsgNtrcrJ58BrUT88AXcygsKmr80dLFEXDbHpbS0jrR2kDKQMUfjbT2BipFJnY4QAYtHVtcwt9/VQ9p7C/6BChXEVmHdHrKGJguF0iT+qcxr5Ge/j2GicfhtU6JXA44Fba2A2pyFPnAssx8fBmPu2/U//s3d81xAoF25w6Op9f1T45rFoEfMzOvt4bpY015wA47prbItcqjC76ib6S0TL9EBhk9Q22ph75r6cQnH3foYWGyGIdvhoFCwacACk6gKs/+4fPhKZIx+8BjPKop7qB10n3PunnDnCxMiNyAZEWV5RhjvCYBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <paul@xxxxxxx>, "Cooper, Andrew" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Pau Monné, Roger <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 24 Dec 2021 07:25:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX5pein16Riinjd0WXoe65lFt6IqwdtVIAgAE4ywCAInJTkA==
  • Thread-topic: [PATCH 2/4] VT-d / x86: re-arrange cache syncing

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Thursday, December 2, 2021 5:19 PM
> 
> On 01.12.2021 15:39, Andrew Cooper wrote:
> > On 01/12/2021 09:40, Jan Beulich wrote:
> >> The actual function should always have lived in core x86 code; move it
> >> there, replacing get_cache_line_size() by readily available (except very
> >> early during boot; see the code comment) data.
> >>
> >> Drop the respective IOMMU hook, (re)introducing a respective boolean
> >> instead. Replace a true and an almost open-coding instance of
> >> iommu_sync_cache().
> >
> > Coherency (or not) is a per-IOMMU property, not a global platform
> > property.  iGPU IOMMUs are very different to those the uncore, and
> > there's no reason to presume that IOMMUs in the PCH would have the
> same
> > properties as those in the uncore.
> >
> > Given how expensive sync_cache() is, we cannot afford to be using it for
> > coherent IOMMUs in a mixed system.
> >
> > This wants to be a boolean in arch_iommu.
> 
> That's a valid consideration, but may not be as easy as it may seem on
> the surface. Certainly not something I could promise to find time for
> soon. And definitely separate from the specific change here.

I'm fine with this patch if you prefer to a staging approach to improve it.
By any means this patch doesn't make things worse.

> 
> >> ---
> >> Placing the function next to flush_area_local() exposes a curious
> >> asymmetry between the SFENCE placements: sync_cache() has it after the
> >> flush, while flush_area_local() has it before it. I think the latter one
> >> is misplaced.
> >
> > Wow this is a mess.
> >
> > First and foremost, AMD state that on pre-CLFLUSHOPT parts, CLFLUSH is
> > unordered with ~anything (including SFENCE), and need bounding with
> > MFENCE on both sides.  We definitely aren't doing this correctly right now.
> >
> >
> > AMD explicitly states that SFENCE drains the store and WC buffers (i.e.
> > make stuff instantaneously globally visible).  Intel does not, and
> > merely guarantees ordering.
> >
> > A leading SFENCE would only make sense if there were WC concerns, but
> > both manuals say that the memory type doesn't matter, so I can't see a
> > justification for it.
> >
> > What does matter, from the IOMMU's point of view, is that the line has
> > been written back (or evicted on pre-CLWB parts) before the IOTLB
> > invalidation occurs.  The invalidation will be a write to a different
> > address, which is why the trailing SFENCE is necessary, as CLFLUSHOPT
> > isn't ordered with respect to unaliasing writes.
> 
> IOW for the purposes of this change all is correct, and everything else
> will require taking care of separately.
> 

Same for this part. btw Linux does mfence both before and after clflush.

Thanks
Kevin

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.