Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp581012rdg; Thu, 10 Aug 2023 12:07:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtw7pRLR8kRdFjCX7AAgyZerd9en2NpcR8UcNjLs2jlo5pJDl2beiIixTR5nAhXhdxpVuW X-Received: by 2002:a05:6a20:9f06:b0:13e:99c0:fe6e with SMTP id mk6-20020a056a209f0600b0013e99c0fe6emr3048873pzb.5.1691694478403; Thu, 10 Aug 2023 12:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691694478; cv=none; d=google.com; s=arc-20160816; b=areEDsKRJt43MAYxP8DSbYn6R1rDcxVWmQFY1MjLzpEBE5FJVWHCQluGVfp421GP4i zN/QDr6YPZ08L1T2sOrUqGJwqEeawVUHyZrSl2a1YjXq35+FUP5ZFV28V2UeN80QI3Cd EvufE8ryMGHqc2suscesRN/DSIQx18ODttxWfQc6NYQbWpwyNiXyxsVksoXSrtV6road ElXHbUNtZBujAnjNpXHT0sAyKhxp5VmaF4qYEYCMfHElFjlfarE65bc9zmePTLnLPTtV MkkVmH8ffzn8f9kTIKH06H9mKu2jz40Idls0qo9ON/TPvglHt7Ln0z5ggS6ljXZqmLsu sgnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bAgbHdZulKU3K7f/EuuxZjoKn0orosVfhysoCXSx/kw=; fh=zAgme00+qcJ327xFOnTZiiGGsWI3qxNNvwnnHlCY4Qk=; b=RK7hy5EqaCsTSHqxVBrXWLT4D58zNgGJBmFVGmrvQWV2djieBlPMUwNVGfDo6nqESW ZBvVvH0ufanahWRwCTexuUnpLlEnttuV4U18Dpd0Lgp6ZnYrztb3p7zJ0eAPi9rOSg5g foWkabEZLt2dSK7xGMYL9QpN5etgt4Wo96+fJ9aRU5JeeCFx3Zut2E4iwHStJ950nP5R K2HkxsAM+maSW6manFJ9oFGdxeig9gi//dk5ZC6CuauZBQcZodmwZvqR3t8fE37d9wTh +60ovBwiE7yWWnHM0KX1785UhodF4DLjJcROXEIsU/lxWzvn0xC5WbKkGSfbYZ4mmMGH gpuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VETPhGi5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e65-20020a636944000000b0056546b5fef5si2000966pgc.561.2023.08.10.12.07.45; Thu, 10 Aug 2023 12:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VETPhGi5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236072AbjHJQ2H (ORCPT + 99 others); Thu, 10 Aug 2023 12:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235863AbjHJQ1v (ORCPT ); Thu, 10 Aug 2023 12:27:51 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297E32136 for ; Thu, 10 Aug 2023 09:27:51 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-26b0b92e190so560884a91.1 for ; Thu, 10 Aug 2023 09:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1691684870; x=1692289670; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=bAgbHdZulKU3K7f/EuuxZjoKn0orosVfhysoCXSx/kw=; b=VETPhGi5BV7BlEyy7+mq0clcaexkXyPfE/T7R9lKifXJANcQ8YQR+OwtYkB78MSCGY riYUOfDwL8P9pxAiAH1UDDXvpEpOjzhNdz7p0NssnLsgElUGHw89TJTKs1z/eL/ajwNb YKxZIoSeRaZ51OK6CXDHb37hFZI0h5I5U097EhQ3U9lwOKPzDbMst5jYMrEt8GsELr8E 1dT4gCGqJJRM7wA4X0KNfgsmUwmY5XK0Bf4TNwtnAN9Y5sL7R2XbmMRHTt/VLYqeHD+T NLZiLV1kWkL9jsdAzi+220bYNPJQQFhNwDzHwGeKmx3K4e6ZZdr0kMr7O3G/SaPAnSpc evyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691684870; x=1692289670; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bAgbHdZulKU3K7f/EuuxZjoKn0orosVfhysoCXSx/kw=; b=SdKPa1jOgGxBsTyvFkKK6B/OpRfugAD1lWBhIVnDrRQo4+eleMEXtAufmOFIFobMYl 5UkZipgy9TL/7NLn/D4zeo5QTNioSe3fV4k5YmjOecrOSqd5G/4mTW5F6EO9M6xyz9Tb Yd8Fc8DETqI0cTcvyt9R7ITOnJQg+0NnAQMMOp8b1YQHurDmvEGMopp3fvYmHfromzpf 68XUBjZINDpkfo0PAD5peAOr8coFeDLEL+lOkDAL+NjB0zlZlzP8bryPsnPxreLM1moR apdBzIAojvzpE7D6IP/zTJob36OOWw8opDAdljYFs5Vn+t2hvUdoEBy1EIl90BjrvORU 85Wg== X-Gm-Message-State: AOJu0YwzKn8HdF3E5F1eUL+1eb6QyTR4csWIBvJ/sg+ohWUyS5kd6IpI UoLy0PI/BBxjwULP2s9MphY78w== X-Received: by 2002:a17:90b:1010:b0:268:f8c8:bd5c with SMTP id gm16-20020a17090b101000b00268f8c8bd5cmr3496252pjb.17.1691684870420; Thu, 10 Aug 2023 09:27:50 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id c4-20020a17090ab28400b00256a4d59bfasm3535713pjr.23.2023.08.10.09.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 09:27:49 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qU8Vn-005Gwz-QD; Thu, 10 Aug 2023 13:27:47 -0300 Date: Thu, 10 Aug 2023 13:27:47 -0300 From: Jason Gunthorpe To: "Tian, Kevin" Cc: "Zhang, Tina" , Lu Baolu , Michael Shavit , "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 0/5] Share sva domains with all devices bound to a mm Message-ID: References: <20230808074944.7825-1-tina.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 10, 2023 at 07:49:11AM +0000, Tian, Kevin wrote: > > From: Zhang, Tina > > Sent: Thursday, August 10, 2023 9:32 AM > > > > Hi, > > > > On 8/9/23 17:41, Tian, Kevin wrote: > > >> From: Zhang, Tina > > >> Sent: Tuesday, August 8, 2023 3:50 PM > > >> > > >> A sva domain's lifetime begins with binding a device to a mm and ends > > >> by releasing all the bound devices from that sva domain. Technically, > > >> there could be more than one sva domain identified by the mm PASID for > > >> the use of bound devices issuing DMA transactions. > > > > > > Could you elaborate it with some concrete examples which motivate > > > this change? > > The motivation is to remove the superfluous IOTLB invalidation in > > current VT-d driver. > > > > Currently, in VT-d driver, due to lacking shared sva domain info, in > > intel_flush_svm_range(), both iotlb and dev-tlb invalidation operations > > are performed per-device. However, difference devices could be behind > > one IOMMU (e.g., four devices are behind one IOMMU) and invoking iotlb > > per-device gives us more iotlb invalidation than necessary (4 iotlb > > invalidation instead of 1). This issue may give more performance impact > > when in a virtual machine guest, as currently we have one virtual VT-d > > for in front of those virtual devices. > > > > > > This patch fixes this issue by attaching shared sva domain information > > to mm, so that it can be utilized in the mm_notifier_ops callbacks. > > > > that is one of the motivations. e.g. another one as Jason suggested > is to cleanup to decouple the common sva logic from enqcmd. Both > should be mentioned in next version cover letter. I also want to purge all the de-duplication and refcounting code around mm's and sva_binds from the drivers. Eg see the mess this makes of SMMUv3. Core code provides a single iommu_domain per-mm for SVA. Driver can rely on this optimization and does not need to de-duplicate. Single domain tracks all attachments. Driver can optimize using that information by de-duplicating (eg ASID invalidation vs ATC invalidation) After this we need to fix the domain allocation op to add a 'alloc_domain_sva(dev, mm_struct)' op so that the drivers can setup their SVA domains fully in a nice lock-safe environment. Jason