From patchwork Sat Jan 28 08:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guorui Yu X-Patchwork-Id: 49823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1251252wrn; Sat, 28 Jan 2023 00:47:19 -0800 (PST) X-Google-Smtp-Source: AK7set8zQPnRJFUfs15ydyt/LSlOwofgXTDh6oSq7rVHZpo2M9HEVAuNOT/wVGmU7m66XcUmq0U0 X-Received: by 2002:a05:6a20:158e:b0:bc:2d7f:786a with SMTP id h14-20020a056a20158e00b000bc2d7f786amr7743220pzj.15.1674895639344; Sat, 28 Jan 2023 00:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674895639; cv=none; d=google.com; s=arc-20160816; b=TScMEr92v6MC38YfOEt192WQBByC0kCyVpZ1UM7S4KW427fveMNh8I+5QBBvCknjBR inHZTjBrAza/MW5YZifEIa0Zc/NVQ79omQ9WucKq01DWyF9V9zPcN/OGSmdJ2zkg3+lE CILPSee5qxuh5M3o5qvOliljcjmy7vNd6BLtQ1QYx0Yb51YSswKFgs695KXlVvjCdB0n BkEg2hMQRpDs90ow1bRiH/tOgVSqkol8tGDUcJHCoMeMuj0mBfkFnlZs1nov/7O/Upqx BkgYYWmPlW1YAvdhAgA4D3pbgDxqX5TopPWZy17dKxmb4PbDTAv14hwSPWC5tIY15ePV dWgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=asX5HbW0LmdCpiGOHa9PiPuNIlNj8JW7+KLyEi6tzbU=; b=F51d36PO8E8HehfB4j9pZ398XgzbEjMUiWnQVlv1IKh4a3wKSxnhmupPYbuXtOH6SL eKmxkvso1b2dABFygQsevMyic8ksCTi6qNLPVv2Xw0Z2eiWy6ZkIPgvBzVYDcoIZZpGw 6Brt61DQYejFp2fkQmmfTrSsytiJcaImeOLCuQ11Igye5TB8or9C7mQEj08xs/0NtEZH GNCCSzxiJ20njo8asdqntUHfEdYY2NkhJ5oKH/YjkRtSDxzxrytzXAcAx3+3EybkYpdZ TKyTeaPEh5jxvrBpqDdnkzrMuQGA2eNsbdFV/OYuCcdew7VBIgbTbPEMjzpKIKEa+GRX pTfw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a63b30e000000b0049cd15c93fcsi6066379pgf.625.2023.01.28.00.47.05; Sat, 28 Jan 2023 00:47:19 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234002AbjA1IdV (ORCPT + 99 others); Sat, 28 Jan 2023 03:33:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233965AbjA1IdP (ORCPT ); Sat, 28 Jan 2023 03:33:15 -0500 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C148E32529 for ; Sat, 28 Jan 2023 00:33:12 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=guorui.yu@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VaGyb8l_1674894788; Received: from localhost(mailfrom:GuoRui.Yu@linux.alibaba.com fp:SMTPD_---0VaGyb8l_1674894788) by smtp.aliyun-inc.com; Sat, 28 Jan 2023 16:33:09 +0800 From: "GuoRui.Yu" To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, konrad.wilk@oracle.com, linux-coco@lists.linux.dev Cc: GuoRui.Yu@linux.alibaba.com, robin.murphy@arm.com Subject: [PATCH 3/4] swiotlb: Add tracepoint swiotlb_unbounced Date: Sat, 28 Jan 2023 16:32:53 +0800 Message-Id: <20230128083254.86012-4-GuoRui.Yu@linux.alibaba.com> X-Mailer: git-send-email 2.29.2.540.g3cf59784d4 In-Reply-To: <20230128083254.86012-1-GuoRui.Yu@linux.alibaba.com> References: <20230128083254.86012-1-GuoRui.Yu@linux.alibaba.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756255369735917812?= X-GMAIL-MSGID: =?utf-8?q?1756255369735917812?= Add a new tracepoint swiotlb_unbounced to facilitate statistics of swiotlb buffer usage. Signed-off-by: GuoRui.Yu --- include/trace/events/swiotlb.h | 28 ++++++++++++++++++++++++++++ kernel/dma/common-swiotlb.c | 1 + 2 files changed, 29 insertions(+) diff --git a/include/trace/events/swiotlb.h b/include/trace/events/swiotlb.h index da05c9ebd224..0707adc34df5 100644 --- a/include/trace/events/swiotlb.h +++ b/include/trace/events/swiotlb.h @@ -35,6 +35,34 @@ TRACE_EVENT(swiotlb_bounced, __entry->force ? "FORCE" : "NORMAL") ); +TRACE_EVENT(swiotlb_unbounced, + TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size), + TP_ARGS(dev, dev_addr, size), + + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(u64, dma_mask) + __field(dma_addr_t, dev_addr) + __field(size_t, size) + __field(bool, force) + ), + + TP_fast_assign( + __assign_str(dev_name, dev_name(dev)); + __entry->dma_mask = (dev->dma_mask ? *dev->dma_mask : 0); + __entry->dev_addr = dev_addr; + __entry->size = size; + __entry->force = is_swiotlb_force_bounce(dev); + ), + + TP_printk("dev_name: %s dma_mask=%llx dev_addr=%llx size=%zu %s", + __get_str(dev_name), + __entry->dma_mask, + (unsigned long long)__entry->dev_addr, + __entry->size, + __entry->force ? "FORCE" : "NORMAL") +); + #endif /* _TRACE_SWIOTLB_H */ /* This part must be outside protection */ diff --git a/kernel/dma/common-swiotlb.c b/kernel/dma/common-swiotlb.c index 553325d5c9cd..e3676a8358f2 100644 --- a/kernel/dma/common-swiotlb.c +++ b/kernel/dma/common-swiotlb.c @@ -46,6 +46,7 @@ void swiotlb_tbl_unmap_single(struct device *dev, phys_addr_t tlb_addr, size_t mapping_size, enum dma_data_direction dir, unsigned long attrs) { + trace_swiotlb_unbounced(dev, phys_to_dma(dev, tlb_addr), mapping_size); /* * First, sync the memory before unmapping the entry */