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.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 685A5C433E6 for ; Fri, 28 Aug 2020 07:42:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 2F88420776 for ; Fri, 28 Aug 2020 07:42:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="boVWpTa9"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vBZFpUuk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F88420776 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nHqImohK5a6wDcYhRNcZijCxHRPmzyraaDMLUHeKMiU=; b=boVWpTa90c40OeZLqs/yx1dOG hO92fDY3ANSGjUinWaL1wa9LKWmPnTJHvE7qS9gQznDscc7qjkiPp0NukuYT0vqQZddKfxqmrdqsr rrGD/phpfyiW+jWk20XGdf+KfGIZsimJJne0qJNXiy/lY1Q2bXRijXfFLOmDNacGN8ay6tgPID8b0 aWIbiLm7zWNAgOYf4wNA+QUK1nhPxR46Dz/JrvWizQuVCApQed+jkk0uk2Zteae2lzb0L0QngtBy/ TySXHRMZflOV68Z5pMgbCyf1PaHffvLPMpAZZ6Z4VgOy686F25q0YgTBwH6ylBBX85X6PZs9BTJY0 U08cb8wQQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBZ0r-00077t-CX; Fri, 28 Aug 2020 07:41:29 +0000 Received: from mail-ed1-x544.google.com ([2a00:1450:4864:20::544]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBZ0o-00077I-Aw for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2020 07:41:27 +0000 Received: by mail-ed1-x544.google.com with SMTP id n26so275903edv.13 for ; Fri, 28 Aug 2020 00:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+uNUuIw8xqYINfgXO90RD0KNG+EszSjrlv8fkPgSuXg=; b=vBZFpUukS9ej8HnUWumNJXv1d/NcuKguyLH6tyukCTnn66A5hCqhEj1HZBurteF5dk hJH6TGNAVoNfosSuexj0tZWBlKn/hMxw46/0zXuAQNzfjVEHGqgJATgmgB9+c/XX3uwi o+m+EU2SydcLI4q/zUeL7sUtjH8wo76OdiOA/pUNMW0qyoKBq358Nh+IhpEqZGvrd2Ep wfBV1V32klCYpLDoZ1oQMUanScI8OYEFolWEuK/PM3etCFvvtdaeus4LO1YzKNE/7t19 QQGaC4tgb2buRHSCpSbCl0qyuGdSO3xsBumTg9VYmF6nFe1sVzaaocM27/FISfvSNzZf 0VBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+uNUuIw8xqYINfgXO90RD0KNG+EszSjrlv8fkPgSuXg=; b=erKWRoDQbQkLOmr3EFBSggQ/AkzHmkXySJKa76yPGc2fLPlmRuk1+oduVOzRotR9ws 1GQNhinle4znCWyeTOTZGsE60Buuy1qJhEFUu9sRDlu50SaMX/SFMY2o5MorgyA7nu/y NXuyGKvl1ju4LFpJx946FdJB1ZNc+FQaMKuY7Y/iHoVNvptD1XISSpYtf8wKZvU267ay xDWcWjekP09MziahHTwCWDbjeSuG0MAmdIqspjpVGm4YZu8XR5TUh9LcYTWoyAFIEevk e/UE58l0tapf7RRXPI41CIiWCMpqd89jvnvOwgz/tJGzXFnBPORCnOAgPKgPCh/x+gkL YM9A== X-Gm-Message-State: AOAM5324gNYEu2cVzy5KzzDazdeqa9zTQmgAS4pxOuP7rX7yeAz2exDC e4IqiCZKyaC4dV7WwD/GWXa6/A== X-Google-Smtp-Source: ABdhPJx3/yoe1p4Ow8ICSkcmM5UJFAesUhgiZyccb3voOeeF/U3xni4PTgZ0pOj/DnQUJ1c19Zertg== X-Received: by 2002:aa7:d353:: with SMTP id m19mr514238edr.275.1598600484733; Fri, 28 Aug 2020 00:41:24 -0700 (PDT) Received: from myrica ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id b24sm300728edn.33.2020.08.28.00.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 00:41:23 -0700 (PDT) Date: Fri, 28 Aug 2020 09:41:07 +0200 From: Jean-Philippe Brucker To: Barry Song Subject: Re: [PATCH] iommu/arm-smmu-v3: add tracepoints for cmdq_issue_cmdlist Message-ID: <20200828074107.GB3825485@myrica> References: <20200827093351.15244-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200827093351.15244-1-song.bao.hua@hisilicon.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200828_034126_874329_15EDCCB5 X-CRM114-Status: GOOD ( 28.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: will@kernel.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, linuxarm@huawei.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Thu, Aug 27, 2020 at 09:33:51PM +1200, Barry Song wrote: > cmdq_issue_cmdlist() is the hotspot that uses a lot of time. This patch > adds tracepoints for it to help debug. > > Signed-off-by: Barry Song > --- > * can furthermore develop an eBPF program to benchmark using this trace Have you tried using kprobe and kretprobe instead of tracepoints? Any noticeable performance drop? Thanks, Jean > > cmdlistlat.c: > #include > > BPF_HASH(start, u32); > BPF_HISTOGRAM(dist); > > TRACEPOINT_PROBE(arm_smmu_v3, issue_cmdlist_entry) > { > u32 pid; > u64 ts, *val; > > pid = bpf_get_current_pid_tgid(); > ts = bpf_ktime_get_ns(); > start.update(&pid, &ts); > return 0; > } > > TRACEPOINT_PROBE(arm_smmu_v3, issue_cmdlist_exit) > { > u32 pid; > u64 *tsp, delta; > > pid = bpf_get_current_pid_tgid(); > tsp = start.lookup(&pid); > > if (tsp != 0) { > delta = bpf_ktime_get_ns() - *tsp; > dist.increment(bpf_log2l(delta)); > start.delete(&pid); > } > > return 0; > } > > cmdlistlat.py: > #!/usr/bin/python3 > # > from __future__ import print_function > from bcc import BPF > from ctypes import c_ushort, c_int, c_ulonglong > from time import sleep > from sys import argv > > def usage(): > print("USAGE: %s [interval [count]]" % argv[0]) > exit() > > # arguments > interval = 5 > count = -1 > if len(argv) > 1: > try: > interval = int(argv[1]) > if interval == 0: > raise > if len(argv) > 2: > count = int(argv[2]) > except: # also catches -h, --help > usage() > > # load BPF program > b = BPF(src_file = "cmdlistlat.c") > > # header > print("Tracing... Hit Ctrl-C to end.") > > # output > loop = 0 > do_exit = 0 > while (1): > if count > 0: > loop += 1 > if loop > count: > exit() > try: > sleep(interval) > except KeyboardInterrupt: > pass; do_exit = 1 > > print() > b["dist"].print_log2_hist("nsecs") > b["dist"].clear() > if do_exit: > exit() > > > drivers/iommu/arm/arm-smmu-v3/Makefile | 1 + > .../iommu/arm/arm-smmu-v3/arm-smmu-v3-trace.h | 48 +++++++++++++++++++ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 8 ++++ > 3 files changed, 57 insertions(+) > create mode 100644 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-trace.h > > diff --git a/drivers/iommu/arm/arm-smmu-v3/Makefile b/drivers/iommu/arm/arm-smmu-v3/Makefile > index 569e24e9f162..dba1087f91f3 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/Makefile > +++ b/drivers/iommu/arm/arm-smmu-v3/Makefile > @@ -1,2 +1,3 @@ > # SPDX-License-Identifier: GPL-2.0 > +ccflags-y += -I$(src) # needed for trace events > obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-trace.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-trace.h > new file mode 100644 > index 000000000000..29ab96706124 > --- /dev/null > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-trace.h > @@ -0,0 +1,48 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (C) 2020 Hisilicon Limited. > + */ > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM arm_smmu_v3 > + > +#if !defined(_ARM_SMMU_V3_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _ARM_SMMU_V3_TRACE_H > + > +#include > + > +struct device; > + > +DECLARE_EVENT_CLASS(issue_cmdlist_class, > + TP_PROTO(struct device *dev, int n, bool sync), > + TP_ARGS(dev, n, sync), > + > + TP_STRUCT__entry( > + __string(device, dev_name(dev)) > + __field(int, n) > + __field(bool, sync) > + ), > + TP_fast_assign( > + __assign_str(device, dev_name(dev)); > + __entry->n = n; > + __entry->sync = sync; > + ), > + TP_printk("%s cmd number=%d sync=%d", > + __get_str(device), __entry->n, __entry->sync) > +); > + > +#define DEFINE_ISSUE_CMDLIST_EVENT(name) \ > +DEFINE_EVENT(issue_cmdlist_class, name, \ > + TP_PROTO(struct device *dev, int n, bool sync), \ > + TP_ARGS(dev, n, sync)) > + > +DEFINE_ISSUE_CMDLIST_EVENT(issue_cmdlist_entry); > +DEFINE_ISSUE_CMDLIST_EVENT(issue_cmdlist_exit); > + > +#endif /* _ARM_SMMU_V3_TRACE_H */ > + > +#undef TRACE_INCLUDE_PATH > +#undef TRACE_INCLUDE_FILE > +#define TRACE_INCLUDE_PATH . > +#define TRACE_INCLUDE_FILE arm-smmu-v3-trace > +#include > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 7332251dd8cd..e2d7d5f1d234 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -33,6 +33,8 @@ > > #include > > +#include "arm-smmu-v3-trace.h" > + > /* MMIO registers */ > #define ARM_SMMU_IDR0 0x0 > #define IDR0_ST_LVL GENMASK(28, 27) > @@ -1389,6 +1391,8 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, > }, head = llq; > int ret = 0; > > + trace_issue_cmdlist_entry(smmu->dev, n, sync); > + > /* 1. Allocate some space in the queue */ > local_irq_save(flags); > llq.val = READ_ONCE(cmdq->q.llq.val); > @@ -1493,6 +1497,7 @@ static int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, > } > > local_irq_restore(flags); > + trace_issue_cmdlist_exit(smmu->dev, n, sync); > return ret; > } > > @@ -4166,6 +4171,9 @@ static struct platform_driver arm_smmu_driver = { > }; > module_platform_driver(arm_smmu_driver); > > +#define CREATE_TRACE_POINTS > +#include "arm-smmu-v3-trace.h" > + > MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations"); > MODULE_AUTHOR("Will Deacon "); > MODULE_ALIAS("platform:arm-smmu-v3"); > -- > 2.27.0 > > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel