Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp229364pxj; Thu, 17 Jun 2021 01:08:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO4o1mlp0LmtRLjBcKIvvrb/iaz21bqSiS4ApYkV7U279wFcJFr8Ha02ZxcO/yp9RgCUR/ X-Received: by 2002:a92:c792:: with SMTP id c18mr2622524ilk.103.1623917323824; Thu, 17 Jun 2021 01:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623917323; cv=none; d=google.com; s=arc-20160816; b=nPJimuQGUwST3f+NdB+vqh0/Sksq55VWRWpt0TNcAsgXz3rM2o9ydc6raFN25HqyIK lEKjDeSshJk2SR8YE8LwFOXxgkBCH5h3I8qAzypxq/Sigio0ijhEwI1BnRjlpPRY89r2 36lvFHKpXLPm1XJSUG7TUrRqvi9KX6txsPTTcslF3h3BdUcAHdMVhi7eCOzYDKHPg3tm E9iGF2+wZ5hdIvDz9fqfg132BR7uE3gl1rUtqcw1ssVQp4rLywM0fMM+qLKEEp3WH4dw EEOXFXhsXta2yKv2ptSocMCfk0M9lLhyVBlhYXw4nLAduAnux5z36wMuyhhJrsmJ7q86 pgFw== 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=iKmcTMLnblgq2qDLJoozRoHWsauQkVVAUyku6FvmVMM=; b=p3tmH9sQkkIIJKXtgxz5HPr1nTAmMcaPUJLRPrPV8CHZLo7NNxpirgJMh9/ong5HAF 7LeWvfSEtI41nZCU2gpwiqiOgrrV89EDosHKro10mgmcwYeR1QDsuggBSg8YQaAkIdlf MeZDv/QuBdY6Wzrzu+17MlmFZteyvsRF7DrDw384CpKWtEPTMd4jvuz8j1a6isEuYx/S RzydC0KW0hRZ/ouuMqJ+IHx3Mi2c1lUYq1Ifauo9YRdwVQuizIICMAbjMXscyC4H11Yz MH/wZWg0HxarKgbhI9CGzxY+OSvlicgUq/LFC9RwOgL1/HN/Fby+dG6WeynMDdApuhZV lffA== 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 v9si5533846ilu.78.2021.06.17.01.08.30; Thu, 17 Jun 2021 01:08:43 -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 S230205AbhFQIJA (ORCPT + 99 others); Thu, 17 Jun 2021 04:09:00 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3260 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbhFQII7 (ORCPT ); Thu, 17 Jun 2021 04:08:59 -0400 Received: from fraeml709-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4G5Dnw3xwBz6K6Hr; Thu, 17 Jun 2021 15:53:40 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml709-chm.china.huawei.com (10.206.15.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 17 Jun 2021 10:06:50 +0200 Received: from [10.47.95.81] (10.47.95.81) 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; Thu, 17 Jun 2021 09:06:49 +0100 Subject: Re: [PATCH v13 4/6] iommu/vt-d: Add support for IOMMU default DMA mode build options To: Lu Baolu , , , , , CC: , , , , , References: <1623841437-211832-1-git-send-email-john.garry@huawei.com> <1623841437-211832-5-git-send-email-john.garry@huawei.com> <46dbce5c-1c2b-60d4-df56-d2b95a959425@linux.intel.com> From: John Garry Message-ID: Date: Thu, 17 Jun 2021 09:00:37 +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: <46dbce5c-1c2b-60d4-df56-d2b95a959425@linux.intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.47.95.81] X-ClientProxiedBy: lhreml743-chm.china.huawei.com (10.201.108.193) 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 17/06/2021 08:32, Lu Baolu wrote: > On 6/16/21 7:03 PM, John Garry wrote: >> @@ -4382,9 +4380,9 @@ 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 (!intel_iommu_strict && cap_caching_mode(iommu->cap)) { >> -            pr_warn("IOMMU batching is disabled due to virtualization"); >> -            intel_iommu_strict = 1; >> +        if (cap_caching_mode(iommu->cap)) { >> +            pr_warn("IOMMU batching disallowed due to >> virtualization\n"); >> +            iommu_set_dma_strict(true); > > With this change, VM guest will always show this warning. Would they have got it before also normally? I mean, default is intel_iommu_strict=0, so if cap_caching_mode(iommu->cap) is true and intel_iommu_strict not set to 1 elsewhere previously, then we would get this print. > How about > removing this message? Users could get the same information through the > kernel message added by "[PATCH v13 2/6] iommu: Print strict or lazy > mode at init time". I think that the print from 2/6 should occur before this print. Regardless I would think that you would still like to be notified of this change in policy, right? However I now realize that the print is in a loop per iommu, so we would get it per iommu: for_each_active_iommu(iommu, drhd) { /* * The flush queue implementation does not perform * page-selective invalidations that are required for efficient * TLB flushes in virtual environments. The benefit of batching * is likely to be much lower than the overhead of synchronizing * the virtual and physical IOMMU page-tables. */ if (!intel_iommu_strict && cap_caching_mode(iommu->cap)) { pr_warn("IOMMU batching is disabled due to virtualization"); intel_iommu_strict = 1; } ... } I need to change that. How about this: bool print_warning = false; for_each_active_iommu(iommu, drhd) { /* * The flush queue implementation does not perform * page-selective invalidations that are required for efficient * TLB flushes in virtual environments. The benefit of batching * is likely to be much lower than the overhead of synchronizing * the virtual and physical IOMMU page-tables. */ if (!print_warning && cap_caching_mode(iommu->cap)) { pr_warn("IOMMU batching disallowed due to virtualization\n"); iommu_set_dma_strict(true); print_warning = true; } ... } or use pr_warn_once(). Thanks, John