From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5731C49361 for ; Thu, 17 Jun 2021 08:06:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1305610A0 for ; Thu, 17 Jun 2021 08:06:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbhFQIJA (ORCPT ); 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACD3BC2B9F4 for ; Thu, 17 Jun 2021 08:07:02 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CAA8610A1 for ; Thu, 17 Jun 2021 08:07:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4CAA8610A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 16ACD415E1; Thu, 17 Jun 2021 08:07:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3BtPuTrofwVf; Thu, 17 Jun 2021 08:06:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6AA0A415D6; Thu, 17 Jun 2021 08:06:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 22C3EC000E; Thu, 17 Jun 2021 08:06:57 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id C4A23C000B for ; Thu, 17 Jun 2021 08:06:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id ABC2A606E6 for ; Thu, 17 Jun 2021 08:06:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CJNg6D06hr8W for ; Thu, 17 Jun 2021 08:06:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 18278606A0 for ; Thu, 17 Jun 2021 08:06:52 +0000 (UTC) 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 , , , , , 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-Language: en-US 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 Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, iommu@lists.linux-foundation.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" T24gMTcvMDYvMjAyMSAwODozMiwgTHUgQmFvbHUgd3JvdGU6Cj4gT24gNi8xNi8yM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