Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp896824pxj; Thu, 17 Jun 2021 16:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnwmzq/XJHU1OssO8QkaRvgMDmtBpWg9y1fYn2i3kZHJN+RcAK2Att1e1sL2dpNfXgyIj1 X-Received: by 2002:a17:906:b857:: with SMTP id ga23mr7954065ejb.296.1623973937549; Thu, 17 Jun 2021 16:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623973937; cv=none; d=google.com; s=arc-20160816; b=EKshJr26ubTZIjjaOfru5CU8gtl0ZA25s82SRGiNU9nWYpmd77Bsn98nz5Pd8/z+Dv OWg802d9aHg3dOjHvA6ONROU0zILoxCAi3SdrSkqtEhn216ZADGEXBRU1YY07a3U+533 atuWkylyyhy9V1PAL6VFyq0YblnYokaegoysdVlJQVJRDJ3PVMxWV3V+d7c9Vdt4CRSN AU1yQsBVmMSDMyK8CQY5nInrwbngsp/MPu39S+pyo5O4DSoT47+rH9g6e0iC5ge/c7qe W/TO3vxkIVDOkyvtbyJIhbwHBi1IJJAoYmfHQr/mFpckZFU3HXgsOqG85P4ldygrBLZJ dsfA== 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=a19J7aI9TYtOfK6DqKjU0shr2MsX1zcOBoMvxskF4zE=; b=uIQ+hVaO++M2QH7gQNsg8CUvXjDRluQuS4kQpsUc58Kj4TXDMXZT/8OnKqhWTl4TOQ nsaZw5HyxhW/fH7GUP5AtpSMBzLeI1TcCa4t9bmJ+6ThlvYdRrE9SyiiWm50P1SaK7cV uMjcLTs71vQbYNpw6sI7MfRfo/P85XjpJEMHnLF++OzchSHODl+TkNvNbOv4x+4+Z9bC OwxBZm2PFR0rp0YvKWnD9kLvfDksTFXvwesSzKCVO6ZZ/EIV006jfWm1CbYFPzqbxSr9 rX1m3p6GdWCoot6JJAXG2HP6w8h/Ca908VwETk0NZm6nIDv0EVGqMO6Tk7aSAT3M5LLV odng== 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si526363edz.286.2021.06.17.16.51.53; Thu, 17 Jun 2021 16:52:17 -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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbhFQTFp (ORCPT + 99 others); Thu, 17 Jun 2021 15:05:45 -0400 Received: from foss.arm.com ([217.140.110.172]:58672 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbhFQTFn (ORCPT ); Thu, 17 Jun 2021 15:05:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B459313A1; Thu, 17 Jun 2021 12:03:35 -0700 (PDT) Received: from [10.57.9.136] (unknown [10.57.9.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A150E3F694; Thu, 17 Jun 2021 12:03:33 -0700 (PDT) Subject: Re: [PATCH v13 4/6] iommu/vt-d: Add support for IOMMU default DMA mode build options To: John Garry , 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@huawei.com, thunder.leizhen@huawei.com, chenxiang66@hisilicon.com, linux-doc@vger.kernel.org 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: Robin Murphy Message-ID: Date: Thu, 17 Jun 2021 20:03:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-06-17 09:00, John Garry wrote: > 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(). Maybe even downgrade it to pr_info_once(), since AIUI it's not really anything scary? I suppose you could technically fake up a domain on the stack to get the global setting out of iommu_get_dma_strict(), or perhaps give iommu_set_dma_strict() a cheeky return value to indicate what the previous setting was, in order to suppress the message entirely if strict is already set, but I'm not at all convinced it's worth the bother. Robin.