Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3724240pxj; Mon, 21 Jun 2021 05:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw58tZ8+7gFf0YpDN6hPdrhtNNpYnjX89GgzC06ZGDhgy9Yf4BmTrYJ7TzXMCZCeGsL7Ojs X-Received: by 2002:a50:fc90:: with SMTP id f16mr6112425edq.254.1624277809977; Mon, 21 Jun 2021 05:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624277809; cv=none; d=google.com; s=arc-20160816; b=0WhpQ69DhGOu7LNC9zGVfE/r7FaQKl2y0WovZJBOCwCtJ3rJH7X4oo4Tb6yw2L7rSw tw57heC3IvONiNjnU+h+kI0T+uoRCJkaAb3rEjuV0eZrpgRnN3VF7fDUeYrl43CDC5Vq RzuMVegKtbfJrdJj7c9yNaObrXYum3aZLNnZyn39VmpdK3pz5MyO52N57YhPrhQ+ps/e WMm+QuU74OJ3kibSzpZ5DPZFMOVep/ly+fDIGUslyXw+g2X4Pi6Qe+APRHwmBRc/tDtQ AZ99T8JPWYAzmFVYqfYgdTGXraLOBBrH9Z6iRiJUK23B+7HyXG+IkeINoySZ3lKIwleM qLrQ== 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=LH368AUvnbnlo/xBNWmDdYe1nT48EoVQ5ZWHb7uy1Ng=; b=g0O9jFjKV+1dTUKM6PI42QOxsEjjhTMB7qcA7dzXAIlsmKrFE7GkGyHv6O78AuJica weFzXL1TJWhdpzaP9ShJxtnVr/W59GiIGfcIli9+XnceSNUxAY5AJssVsFq2JGjfJ6Gb EATlRyAyWdYXn3K4a1XzyQOXHyX/m6E5Qlxz9GoEUo7GcOA5O09GTm0uvanj62HlCzq7 jtWBHbtDiDQ9ugB7vLnPpUMNzHSefTJfQHDxWJQSBsx6eY3qsgVmoYtIY1d5o+IuCeTT wvd3JEhsIuAlRjnFjjGdw81juQEeOjWWyy7JokBfu3KrGEk9AbqnAJgiorOt7v0UxYPE 7enA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi20si18458159edb.462.2021.06.21.05.16.27; Mon, 21 Jun 2021 05:16:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbhFUMRd (ORCPT + 99 others); Mon, 21 Jun 2021 08:17:33 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3294 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhFUMRc (ORCPT ); Mon, 21 Jun 2021 08:17:32 -0400 Received: from fraeml741-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4G7pFW27Qbz6FBVY; Mon, 21 Jun 2021 20:07:59 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml741-chm.china.huawei.com (10.206.15.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 21 Jun 2021 14:15:17 +0200 Received: from [10.47.93.67] (10.47.93.67) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 21 Jun 2021 13:15:16 +0100 Subject: Re: [PATCH v14 6/6] iommu: Remove mode argument from iommu_set_dma_strict() To: Robin Murphy , Lu Baolu , "joro@8bytes.org" , "will@kernel.org" , "dwmw2@infradead.org" , "corbet@lwn.net" CC: "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , Linuxarm , "Leizhen (ThunderTown)" , "chenxiang (M)" , "linux-doc@vger.kernel.org" , References: <1624016058-189713-1-git-send-email-john.garry@huawei.com> <1624016058-189713-7-git-send-email-john.garry@huawei.com> <60bdd7c3-d73e-c005-ddf7-069bc5065bce@huawei.com> <855dd109-1449-7bc6-3d25-7ffeeeffa82a@linux.intel.com> <2330bb52-1768-5122-9378-7923034c82bd@arm.com> From: John Garry Message-ID: Date: Mon, 21 Jun 2021 13:08:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <2330bb52-1768-5122-9378-7923034c82bd@arm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.47.93.67] X-ClientProxiedBy: lhreml747-chm.china.huawei.com (10.201.108.197) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/06/2021 12:59, Robin Murphy wrote: + Nadav >> On a personal level I would be happy with that approach, but I think >> it's better to not start changing things right away in a follow-up series. >> >> So how about we add this patch (which replaces 6/6 "iommu: Remove mode >> argument from iommu_set_dma_strict()")? >> >> Robin, any opinion? > For me it boils down to whether there are any realistic workloads where > non-strict mode*would* still perform better under virtualisation. The > only reason for the user to explicitly pass "iommu.strict=0" is because > they expect it to increase unmap performance; if it's only ever going to > lead to an unexpected performance loss, I don't see any value in > overriding the kernel's decision purely for the sake of subservience. > > If there*are* certain valid cases for allowing it for people who really > know what they're doing, then we should arguably also log a counterpart > message to say "we're honouring your override but beware it may have the > opposite effect to what you expect" for the benefit of other users who > assume it's a generic go-faster knob. At that point it starts getting > non-trivial enough that I'd want to know for sure it's worthwhile. > > The other reason this might be better to revisit later is that an AMD > equivalent is still in flight[1], and there might be more that can > eventually be factored out. I think both series are pretty much good to > merge for 5.14, but time's already tight to sort out the conflicts which > exist as-is, without making them any worse. ok, fine. Can revisit. As for getting these merged, I'll dry-run merging both of those series to see the conflicts. It doesn't look too problematic from a glance. Cheers, John > > Robin. > > [1] > https://lore.kernel.org/linux-iommu/20210616100500.174507-3-namit@vmware.com/ > >> ------->8--------- >> >> [PATCH] iommu/vt-d: Make "iommu.strict" override batching due to >>  virtualization >> >> As a change in policy, make iommu.strict cmdline argument override >> whether we disable batching due to virtualization. >> >> The API of iommu_set_dma_strict() is changed to accept a "force" >> argument, which means that we always set iommu_dma_strict true, >> regardless of whether we already set via cmdline. Also return a boolean, >> to tell whether iommu_dma_strict was set or not. >> >> Note that in all pre-existing callsites of iommu_set_dma_strict(), >> argument strict was true, so this argument is dropped. >> >> Signed-off-by: John Garry >> >> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c >> index 06666f9d8116..e8d65239b359 100644 >> --- a/drivers/iommu/intel/iommu.c >> +++ b/drivers/iommu/intel/iommu.c >> @@ -4380,10 +4380,8 @@ int __init intel_iommu_init(void) >>           * is likely to be much lower than the overhead of synchronizing >>           * the virtual and physical IOMMU page-tables. >>           */ >> -        if (cap_caching_mode(iommu->cap)) { >> +        if (cap_caching_mode(iommu->cap) && iommu_set_dma_strict(false)) >>              pr_info_once("IOMMU batching disallowed due to >> virtualization\n"); >> -            iommu_set_dma_strict(true); >> -        } >>          iommu_device_sysfs_add(&iommu->iommu, NULL, >>                         intel_iommu_groups, >>                         "%s", iommu->name); >> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c >> index 60b1ec42e73b..1434bee64af3 100644 >> --- a/drivers/iommu/iommu.c >> +++ b/drivers/iommu/iommu.c >> @@ -349,10 +349,14 @@ static int __init iommu_dma_setup(char *str) >>  } >>  early_param("iommu.strict", iommu_dma_setup); >> >> -void iommu_set_dma_strict(bool strict) >> +/* Return true if we set iommu_dma_strict */ >> +bool iommu_set_dma_strict(bool force) >>  { >> -    if (strict || !(iommu_cmd_line & IOMMU_CMD_LINE_STRICT)) >> -        iommu_dma_strict = strict; >> +    if (force || !(iommu_cmd_line & IOMMU_CMD_LINE_STRICT)) { >> +        iommu_dma_strict = true; >> +        return true; >> +    } >> +    return false; >>  } >> >>  bool iommu_get_dma_strict(struct iommu_domain *domain) >> diff --git a/include/linux/iommu.h b/include/linux/iommu.h >> index 32d448050bf7..f17b20234296 100644 >> --- a/include/linux/iommu.h >> +++ b/include/linux/iommu.h >> @@ -476,7 +476,7 @@ int iommu_enable_nesting(struct iommu_domain *domain); >>  int iommu_set_pgtable_quirks(struct iommu_domain *domain, >>          unsigned long quirks); >> >> -void iommu_set_dma_strict(bool val); >> +bool iommu_set_dma_strict(bool force); >>  bool iommu_get_dma_strict(struct iommu_domain *domain); >> >>  extern int report_iommu_fault(struct iommu_domain *domain, struct >> device *dev,