Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp625553pxa; Fri, 14 Aug 2020 13:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9+9Cvzy3jRxpGWkFc2Iakih0iatzDRasYPV1UiNg3Tp6Zyr1l3iL9M5s6z+GX/LaF9Q99 X-Received: by 2002:a17:906:85ce:: with SMTP id i14mr4255570ejy.318.1597436154481; Fri, 14 Aug 2020 13:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597436154; cv=none; d=google.com; s=arc-20160816; b=R/3PFZzzf3f7RbmONieiSrW2TBmZO1H9CFtPtgzF4lcUzGmj9/FWzADXakeYmxd45M N6zB/lTDh+mbQhtgXxbKwOkBIaWamq/0jgWJHAZ6Uvm2zCwt7sE1FGl8F+EkXax9/3Gb S/FRORVA6qMf5aWha3N4MUJ/kCmEXjryoKN88VvrI+qKLNRSKGZv6pbRxE5pryySlvYq 95/hnjiotiUaOR5t9FTkoatoRBtjiZGEYV4ulrI6HW6RTSjGM+BPdxaQESdaTSottpJq Xoruyq59QpWAJ3GlxArcSY08kzPCBjwD6FKv8GLbATKTNM4xdSD1ej8dPYM/MF90Dc8w J8fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Ayx2osqkGYyYmtCpQpi4VnenZwpKUC2ibrz4ES7QYAw=; b=mGzcToXX/rGrSKjmHOAxKE+STNVWonZTtHLR6hYKwDR/dffanMfJAOPrzS3D0HLzNe ENVZRXt662KoBxxHMgHlg8XMzF/fOVdtjNAHGiXdnlGLfr6/ipwgXZVVhVvgfusNc/rq DtGh/zXKLG2pt9ezNcM5ayLJxGdak13/nzoFUkqgz3gWjwXP8+YgHNwc6619k+Kv1t0d wQ+bCnLGDm6e8wz070TOQuV8ac9XCTZXMcc0SPYhpa8s8vomBEQSRNraBzroOC8hpS4a 7AigC1U7bZG3w9lmxpWqLtGr7r5IK7NnnVW5MPqiYba++PdmV8zhwxfTlQf+8MBftn+a uw5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aFW4l0oX; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si5494566ejx.78.2020.08.14.13.15.31; Fri, 14 Aug 2020 13:15:54 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=aFW4l0oX; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728212AbgHNTZl (ORCPT + 99 others); Fri, 14 Aug 2020 15:25:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgHNTZl (ORCPT ); Fri, 14 Aug 2020 15:25:41 -0400 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3789C061385 for ; Fri, 14 Aug 2020 12:25:40 -0700 (PDT) Received: by mail-io1-xd41.google.com with SMTP id v6so11763614iow.11 for ; Fri, 14 Aug 2020 12:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ayx2osqkGYyYmtCpQpi4VnenZwpKUC2ibrz4ES7QYAw=; b=aFW4l0oXOFK3RjfBWLSYv0SKDYvgo1Jb3Kib2RyWH86/htADthQcwHGRKISPm2vaM3 o4J9DFzNRN1a82XLrqM3NsTCaL2O/e6SbU8/8qxeDyxHAjq0fCI7LLiXuaiB9C02H0nv bpvhzj3WPTWxaOUD0TI91yvt78w6TSnyf9KezelXCQR1RWmcbGXyzn6g+RlJWo7eHJ24 luAi6R2Xdqo52h7Pn9we21zyzsbx8kfcwTp2dfRdqQxvwKYhvdJrawsgugZIOW9hWkIN pZkl2v0GRSJFz6iYolf/EZP5KtDtcfCvWoBD407i6UgPwjFjjhXSpy/DhQUqvib/9Chj znIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ayx2osqkGYyYmtCpQpi4VnenZwpKUC2ibrz4ES7QYAw=; b=dGYuSSwHO4WNPx5OTqVg6gpKL59K5hUKhSkD6nRSAvYClBhGXTcguAv01tVpNJeoah eZTX9uove5svZ5yuwmqMt89OEo0ZjNyp9KyI5AeTaSJb+KAJEqVLcujUutwU26LGztjv VUBAIf0sFYYxhHOiLPfgfyxCOt6Z07YcPHwMRraP0dKaoxDsv2A9nt5ZY8becpoAe3y+ QgvanUa4qL2eqlwlmMKjM692XjROcbP7kjK15oFC/NU1BQyGxaSd8e7gGOnesGYgPU1D nLningKgmac1n17IHWI9wxVtI/5lHUZP0O3H0i/vQuHYsRZV74v5nGvuN6jss2yVQ/rB qrRg== X-Gm-Message-State: AOAM533WXPwNaIfqBqXmpzfnwz/8hFU6M4IO1CFO7GIGQCGXeJleAp+u IsvQbva3JCM71R7ITH44zy8zE7G4GWYWXW32XrQtDg== X-Received: by 2002:a6b:2b52:: with SMTP id r79mr3295106ior.157.1597433140015; Fri, 14 Aug 2020 12:25:40 -0700 (PDT) MIME-Version: 1.0 References: <20200813210357.146936-1-lpy@google.com> <159741850487.10342.14268227307882225260@build.alporthouse.com> In-Reply-To: <159741850487.10342.14268227307882225260@build.alporthouse.com> From: Peiyong Lin Date: Fri, 14 Aug 2020 12:25:24 -0700 Message-ID: Subject: Re: [PATCH] Add power/gpu_frequency tracepoint. To: Chris Wilson , Sidath Senanayake , zzyiwei@android.com Cc: Amit Kucheria , Greg Kroah-Hartman , Ingo Molnar , Masahiro Yamada , Paul Walmsley , Pavel Machek , "Rafael J. Wysocki" , Steven Rostedt , Ulf Hansson , linux-kernel@vger.kernel.org, Prahlad Kilambi , android-kernel@google.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chris, please see my comments inline. On Fri, Aug 14, 2020 at 8:22 AM Chris Wilson wrote: > > Quoting Peiyong Lin (2020-08-13 22:03:57) > > Historically there is no common trace event for GPU frequency, in > > downstream Android each different hardware vendor implements their own > > way to expose GPU frequency, for example as a debugfs node. This patch > > standardize it as a common trace event in upstream linux kernel to help > > the ecosystem have a common implementation across hardware vendors. > > Toolings in the Linux ecosystem will benefit from this especially in the > > downstream Android, where this information is critical to graphics > > developers. > > > > Signed-off-by: Peiyong Lin > > --- > > drivers/gpu/Makefile | 1 + > > drivers/gpu/trace/Kconfig | 3 +++ > > drivers/gpu/trace/Makefile | 1 + > > drivers/gpu/trace/trace_gpu_frequency.c | 13 +++++++++++++ > > include/trace/events/power.h | 26 +++++++++++++++++++++++++ > > 5 files changed, 44 insertions(+) > > create mode 100644 drivers/gpu/trace/trace_gpu_frequency.c > > > > diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile > > index 835c88318cec..f289a47eb031 100644 > > --- a/drivers/gpu/Makefile > > +++ b/drivers/gpu/Makefile > > @@ -6,3 +6,4 @@ obj-$(CONFIG_TEGRA_HOST1X) += host1x/ > > obj-y += drm/ vga/ > > obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ > > obj-$(CONFIG_TRACE_GPU_MEM) += trace/ > > +obj-$(CONFIG_TRACE_GPU_FREQUENCY) += trace/ > > diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig > > index c24e9edd022e..ac4aec8d5845 100644 > > --- a/drivers/gpu/trace/Kconfig > > +++ b/drivers/gpu/trace/Kconfig > > @@ -2,3 +2,6 @@ > > > > config TRACE_GPU_MEM > > bool > > + > > +config TRACE_GPU_FREQUENCY > > + bool > > diff --git a/drivers/gpu/trace/Makefile b/drivers/gpu/trace/Makefile > > index b70fbdc5847f..2b7ae69327d6 100644 > > --- a/drivers/gpu/trace/Makefile > > +++ b/drivers/gpu/trace/Makefile > > @@ -1,3 +1,4 @@ > > # SPDX-License-Identifier: GPL-2.0 > > > > obj-$(CONFIG_TRACE_GPU_MEM) += trace_gpu_mem.o > > +obj-$(CONFIG_TRACE_GPU_FREQUENCY) += trace_gpu_frequency.o > > diff --git a/drivers/gpu/trace/trace_gpu_frequency.c b/drivers/gpu/trace/trace_gpu_frequency.c > > new file mode 100644 > > index 000000000000..f5af5800b52d > > --- /dev/null > > +++ b/drivers/gpu/trace/trace_gpu_frequency.c > > @@ -0,0 +1,13 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * GPU frequency trace points > > + * > > + * Copyright (C) 2020 Google, Inc. > > + */ > > + > > +#include > > + > > +#define CREATE_TRACE_POINTS > > +#include > > + > > +EXPORT_TRACEPOINT_SYMBOL(gpu_frequency); > > diff --git a/include/trace/events/power.h b/include/trace/events/power.h > > index af5018aa9517..befc0157131e 100644 > > --- a/include/trace/events/power.h > > +++ b/include/trace/events/power.h > > @@ -500,6 +500,32 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request, > > > > TP_ARGS(name, type, new_value) > > ); > > + > > +/** > > + * gpu_frequency - Reports frequency changes in GPU clock domains > > + * @state: New frequency (in KHz) > > + * @gpu_id: GPU clock domain > > + */ > > +TRACE_EVENT(gpu_frequency, > > + > > + TP_PROTO(unsigned int state, unsigned int gpu_id), > > + > > + TP_ARGS(state, gpu_id), > > + > > + TP_STRUCT__entry( > > + __field(unsigned int, state) > > + __field(unsigned int, gpu_id) > > What is a gpu-id and how are we supposed to create one? gpu_id is the id for per GPU clock domain, it should be created for per GPU clock domain. It's not necessarily tied to a physical GPU. > > 'state' is quite non-descript, and since this is not an event template > you could be a little more specific. > > So when should this tracepoint fire? For the frequency change we request, > or the frequency change of the black box of the pcu? If an implementation implements this, the GPU frequency tracepoint should be fired whenever there's a frequency change. That is to say, when gpu goes from idle to active or vice versa, or when the gpu frequency goes up and down. > > We have found that a tracepoint is not a useful monitor of the actual GPU > frequencies, for that we use provide sampling via perf-events. > -Chris