Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp716918lqo; Thu, 16 May 2024 22:01:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoYvkHkD5097FXPrhBJMsGBjdmFP1Zpc1QQt5QHoH1ZR2nov1CQi7nte5W+pgcFo8Eu7L/Rc0UYEHDbxqbha8GKOQkDMH4lW32Cb7G4w== X-Google-Smtp-Source: AGHT+IEvADlHwrXhFMjeukgG+n1Gq6JxpRMEI185Y2qANHdRnWc7ClKyh/F+c3/MWm2n1k0L1LN/ X-Received: by 2002:a17:90a:778c:b0:2bb:b23e:11e6 with SMTP id 98e67ed59e1d1-2bbb23e1a34mr3045960a91.17.1715922108501; Thu, 16 May 2024 22:01:48 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b628ea7512si19241000a91.111.2024.05.16.22.01.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 22:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181740-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ho6ZPaT8; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-181740-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181740-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 202AC282A2A for ; Fri, 17 May 2024 05:01:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15503EEB5; Fri, 17 May 2024 05:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Ho6ZPaT8" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D12801079D; Fri, 17 May 2024 05:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.11 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715922094; cv=fail; b=UPV/jC+ip1M2wlu/uAk5NUVIVWbyIyuA76IChAWkkFMpQALYWEw3MGQGels2bXBnEVHESD1BG7h+25DfTF/C79gt2L/u10N62zWov/xsld4VrWywXkbcfTGq8nJXSoyv9Dv2rlWNk2YHqEUxWnxp7aKjPSOTzjDv+kVscFfnCB8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715922094; c=relaxed/simple; bh=M7I4L0cH+NyHm/gyaCbOZUstBnl/Rzmkmeg9BOe6AfA=; h=Date:From:To:CC:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=QFPIJp1siZWSgIKZBfADbjDCUJfkVkeM55Fcv7q2GLbTpxJuVvaLNfVsdRTVJ2L6LOlniZG3UuCuS785oGddCnqBPJ4ARc7bwJI6giRXI8tRJy+sjfvADpRqNbyFYhTEoqW9V5hVEURHJm0rgtlRU8SXNL8sJWwwisUh5zcaox4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Ho6ZPaT8; arc=fail smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715922093; x=1747458093; h=date:from:to:cc:subject:message-id:reply-to:references: in-reply-to:mime-version; bh=M7I4L0cH+NyHm/gyaCbOZUstBnl/Rzmkmeg9BOe6AfA=; b=Ho6ZPaT8B0yMuIFU+jk99669E1X0DggH4gyIUVwBlqyqoG/JgcmbcWg+ M+v03RBiT1L6T+mtRKFzH60Z+lhaui561lXDNAI1T8WV9kv/+ipmMYaw0 +/cycLupARW06ncuqKzaB5jFuwZKrROIP8l1W+dY5BklxAW/AXvFGIJwn AWtQ/8soPJtEM2+gqKRPDj8IFkk+S+dcVaur+uln9upt6osV/4DbXinnb bcDe3kJmndP6Fh/OF55uPKYUDkqIBEwLl/sYQdvSUk4Fbf4eVcoSA+sda A2zXiaqreW0BwshBJe3mI4fzUGom8xYGTh7fS38NePFz1Ib5zA9BWippb g==; X-CSE-ConnectionGUID: fCrLz405QXOksRM8sShaog== X-CSE-MsgGUID: RCxvin5CSW+DGUAqYeasyQ== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="22684050" X-IronPort-AV: E=Sophos;i="6.08,166,1712646000"; d="scan'208";a="22684050" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2024 22:01:32 -0700 X-CSE-ConnectionGUID: jgxbhtOnTTWNQA1UFFl9tg== X-CSE-MsgGUID: bkBPYpLbTCyIdq9fgxQcIQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,166,1712646000"; d="scan'208";a="36463429" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 16 May 2024 22:01:31 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 16 May 2024 22:01:31 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 16 May 2024 22:01:30 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 16 May 2024 22:01:30 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 16 May 2024 22:01:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k4d4YeSL6n/N0odgrXsmNLIxovaMmf3gLCWtCSJNpOmHrE357T5TSz59LS1mBege/jwobu1b9Zg1wzu9t9AujOLcX59kFiF9S+Z0LhEKYjeBSSJYPOdqJaMZFWlK43f4VYWZag+a7Hd8jDJ9t9ROi5ZKErrF5AnQwO9JoXgr3+fKJfT2h6iriljvgfMeJOx8kkF0q+/o/9vv0pRUPODlPM8SFE13Kgcqrg2sPP1goXZ7T2kv1piC1ZBTBWR9wjA+sG5T11Md8kSfYUI/1lu5vq6lyhOWBUnsfh12yJETXaE67iszklYCw8U7W3hHllnH5ZRLrwef/dNhS9g/9vTSZA== 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=vPb0odojeHaNhqiepWoD9zN98pLYFOquMTiVE/bhM2k=; b=T12FeTgjC/EMklkU1SXJ30+ljZiTw3A3ri354tB3QPmSGRYg8coJS1WwItXBLyIQqkhGxrnPiO3rqJ+Mnz6Sbz64MSU2jsbKKUydPrqbJmORJdVHCdVN5N8Ll00Tblpvislrz6yRGocaOi07Sw+sVtUOq9CMaHRCKoJFaYIQ4Vsl6nUNvjuybNDMoLE9MvwL7fSEmKXyO0/IOtqC3unfijeVCM2tR93vx8qHXggNwe/tdR2CTR4/06O+ICRl3GCbEIRZGYkFXyt21jxDzGyF3HUScnO/xFh/RDjkYnwDRJX5S2gJpMZsbl3yMZn+ZEBnJ8OVkJpfI3wyo1vR+NzFhg== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS7PR11MB5966.namprd11.prod.outlook.com (2603:10b6:8:71::6) by SN7PR11MB6655.namprd11.prod.outlook.com (2603:10b6:806:26d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Fri, 17 May 2024 05:01:28 +0000 Received: from DS7PR11MB5966.namprd11.prod.outlook.com ([fe80::e971:d8f4:66c4:12ca]) by DS7PR11MB5966.namprd11.prod.outlook.com ([fe80::e971:d8f4:66c4:12ca%6]) with mapi id 15.20.7587.026; Fri, 17 May 2024 05:01:28 +0000 Date: Fri, 17 May 2024 13:00:38 +0800 From: Yan Zhao To: Alex Williamson CC: , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 4/5] vfio/type1: Flush CPU caches on DMA pages in non-coherent domains Message-ID: Reply-To: Yan Zhao References: <20240507061802.20184-1-yan.y.zhao@intel.com> <20240507062138.20465-1-yan.y.zhao@intel.com> <20240509121049.58238a6f.alex.williamson@redhat.com> <20240510105728.76d97bbb.alex.williamson@redhat.com> <20240516145009.3bcd3d0c.alex.williamson@redhat.com> <20240516224442.56df5c23.alex.williamson@redhat.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240516224442.56df5c23.alex.williamson@redhat.com> X-ClientProxiedBy: SI1PR02CA0011.apcprd02.prod.outlook.com (2603:1096:4:1f7::19) To DS7PR11MB5966.namprd11.prod.outlook.com (2603:10b6:8:71::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR11MB5966:EE_|SN7PR11MB6655:EE_ X-MS-Office365-Filtering-Correlation-Id: c821d591-6ec1-4e6f-e07c-08dc762e693b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?KbQkEbtSNVagKNvgR87flvOWrFSFQZvcFQou2b/alieER/CcpS/DBXs103tb?= =?us-ascii?Q?N8uSPv4YFmhJ28wxtmco//iFnAIJAKbtuCJgoq15QrlyLFBj0eszP9y3YT+M?= =?us-ascii?Q?pMg+PjHbfeROrOz2udeQGSzH3ZSnBy2kslH2p1XZnZPkqbX+3mpPHeD8Q0eW?= =?us-ascii?Q?ZMPUqmmbR6m+Mpe4M3IkwUjJoJb4gfdE7g1JM6IhqTUWwkMXQmJeDcj0m1lL?= =?us-ascii?Q?8+ndkTOQXcOmN4qL8zEgCpYHRFsrRPhW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bFmMLuBVGqJ94xbiKApem1wJpPmco9lBjXhaRl+Qn3n5yDxQQ?= =?us-ascii?Q?uh+m5jpa9bh0ygY2BcwUi5jhA+734eIRt0l/yv/tJVyc9H2wo6UTMcJtvCTM?= =?us-ascii?Q?39+8Drizj3XNAfK4SmdoUSe8VnGABI6IjeYE7COmZQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR11MB5966.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015)(7416005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?BLl7v91oTNNK+uSBMsRJTKtNmcD5GhAPwTFGTibL/N6FqCx6A3CFpqSbVFX9?= =?us-ascii?Q?bZnhjCurSbzPdYcxNxZOw0QVYhD3JJfcsZqPbWh+ZNnqfwAIWeRewId9MMDm?= =?us-ascii?Q?w9zNZoeVTIbMVwgsTvfLl23ay0IdeBYA9++Z3u8RHWI9NDqG65nugxRFC4pr?= =?us-ascii?Q?u5OkxjJavALn8ePuQ13MqXCF76imFdRFOaL7utcOSAo5OfSW2p1JnMdwJ94O?= =?us-ascii?Q?W/WwJ3dZnJU/tMNzncI0x6Zh365dbG7OItoLwMmRxWT/6hALvKVyikJ2mp/h?= =?us-ascii?Q?lP4wM0khRpjk2VUzmpVszh4tTp4pmKobchHwl+fsCW5g/0XCH5S9N/r4xpdd?= =?us-ascii?Q?2PCol+/FCRErySumIZWV0KXOk/qYpSiIik5kDRKPucacZo3+HyV1iKMRMiJ7?= =?us-ascii?Q?o35yMaPlWK0710UIbACOso41TthCx25pVbstHGqkeMAyAcYjojHXABXH6v9I?= =?us-ascii?Q?bWoOe3TyPfBYmAHa+zGBdbyT3Ngh5hhbJ0C4mHYXUcsVS3EoZfuNnB4Q5y5z?= =?us-ascii?Q?Akd6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q3?= =?us-ascii?Q?14KPMPDyTajySOpS8EGqJ0YJ8oIUMsxnqa5HCEGYAqxMrrBZ73FeWO8gOUNx?= =?us-ascii?Q?Nlj70sIi5tTFalexnXkl069cuPhoQ6cG4RvD6r4WphLE58ukfuSA0Izn3ahX?= =?us-ascii?Q?Qi4Keb9wsftsqXPl3hLKFz/zYt7th/BVEsKQjqtk?= X-MS-Exchange-CrossTenant-Network-Message-Id: c821d591-6ec1-4e6f-e07c-08dc762e693b X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5966.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2024 05:01:28.7298 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OelTdtRmV/bozm5dREa4FiQoX698zE2t30uoaryI8hmZ8qvv1moWv8UcNRVpUpztQihyZTZuxQtZzgWTdcGoPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR11MB6655 X-OriginatorOrg: intel.com On Thu, May 16, 2024 at 10:44:42PM -0600, Alex Williamson wrote: > On Fri, 17 May 2024 11:11:48 +0800 > Yan Zhao wrote: > > > On Thu, May 16, 2024 at 02:50:09PM -0600, Alex Williamson wrote: > > > On Mon, 13 May 2024 15:11:28 +0800 > > > Yan Zhao wrote: > > > > > > > On Fri, May 10, 2024 at 10:57:28AM -0600, Alex Williamson wrote: > > > > > On Fri, 10 May 2024 18:31:13 +0800 > > > > > Yan Zhao wrote: > > > > > > > > > > > On Thu, May 09, 2024 at 12:10:49PM -0600, Alex Williamson wrote: > > > > > > > On Tue, 7 May 2024 14:21:38 +0800 > > > > > > > Yan Zhao wrote: > > ... > > > > > > > > @@ -1683,9 +1715,14 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu, > > > > > > > > for (; n; n = rb_next(n)) { > > > > > > > > struct vfio_dma *dma; > > > > > > > > dma_addr_t iova; > > > > > > > > + bool cache_flush_required; > > > > > > > > > > > > > > > > dma = rb_entry(n, struct vfio_dma, node); > > > > > > > > iova = dma->iova; > > > > > > > > + cache_flush_required = !domain->enforce_cache_coherency && > > > > > > > > + !dma->cache_flush_required; > > > > > > > > + if (cache_flush_required) > > > > > > > > + dma->cache_flush_required = true; > > > > > > > > > > > > > > The variable name here isn't accurate and the logic is confusing. If > > > > > > > the domain does not enforce coherency and the mapping is not tagged as > > > > > > > requiring a cache flush, then we need to mark the mapping as requiring > > > > > > > a cache flush. So the variable state is something more akin to > > > > > > > set_cache_flush_required. But all we're saving with this is a > > > > > > > redundant set if the mapping is already tagged as requiring a cache > > > > > > > flush, so it could really be simplified to: > > > > > > > > > > > > > > dma->cache_flush_required = !domain->enforce_cache_coherency; > > > > > > Sorry about the confusion. > > > > > > > > > > > > If dma->cache_flush_required is set to true by a domain not enforcing cache > > > > > > coherency, we hope it will not be reset to false by a later attaching to domain > > > > > > enforcing cache coherency due to the lazily flushing design. > > > > > > > > > > Right, ok, the vfio_dma objects are shared between domains so we never > > > > > want to set 'dma->cache_flush_required = false' due to the addition of a > > > > > 'domain->enforce_cache_coherent == true'. So this could be: > > > > > > > > > > if (!dma->cache_flush_required) > > > > > dma->cache_flush_required = !domain->enforce_cache_coherency; > > > > > > > > Though this code is easier for understanding, it leads to unnecessary setting of > > > > dma->cache_flush_required to false, given domain->enforce_cache_coherency is > > > > true at the most time. > > > > > > I don't really see that as an issue, but the variable name originally > > > chosen above, cache_flush_required, also doesn't convey that it's only > > > attempting to set the value if it wasn't previously set and is now > > > required by a noncoherent domain. > > Agreed, the old name is too vague. > > What about update_to_noncoherent_required? > > set_noncoherent? Thanks, > Concise! > > > Then in vfio_iommu_replay(), it's like > > > > update_to_noncoherent_required = !domain->enforce_cache_coherency && !dma->is_noncoherent; > > if (update_to_noncoherent_required) > > dma->is_noncoherent = true; > > > > ... > > if (update_to_noncoherent_required) > > arch_flush_cache_phys((phys, size); > > > > > > > > > > It might add more clarity to just name the mapping flag > > > > > > > dma->mapped_noncoherent. > > > > > > > > > > > > The dma->cache_flush_required is to mark whether pages in a vfio_dma requires > > > > > > cache flush in the subsequence mapping into the first non-coherent domain > > > > > > and page unpinning. > > > > > > > > > > How do we arrive at a sequence where we have dma->cache_flush_required > > > > > that isn't the result of being mapped into a domain with > > > > > !domain->enforce_cache_coherency? > > > > Hmm, dma->cache_flush_required IS the result of being mapped into a domain with > > > > !domain->enforce_cache_coherency. > > > > My concern only arrives from the actual code sequence, i.e. > > > > dma->cache_flush_required is set to true before the actual mapping. > > > > > > > > If we rename it to dma->mapped_noncoherent and only set it to true after the > > > > actual successful mapping, it would lead to more code to handle flushing for the > > > > unwind case. > > > > Currently, flush for unwind is handled centrally in vfio_unpin_pages_remote() > > > > by checking dma->cache_flush_required, which is true even before a full > > > > successful mapping, so we won't miss flush on any pages that are mapped into a > > > > non-coherent domain in a short window. > > > > > > I don't think we need to be so literal that "mapped_noncoherent" can > > > only be set after the vfio_dma is fully mapped to a noncoherent domain, > > > but also we can come up with other names for the flag. Perhaps > > > "is_noncoherent". My suggestion was more from the perspective of what > > > does the flag represent rather than what we intend to do as a result of > > > the flag being set. Thanks, > > Makes sense! > > I like the name "is_noncoherent" :) > > >