Received: by 10.223.185.116 with SMTP id b49csp899602wrg; Fri, 16 Feb 2018 08:58:30 -0800 (PST) X-Google-Smtp-Source: AH8x225k+xg6VwdnEs7J2pxyAK9Y8Lbfod72dvLSVlcVHtXzTBEdpil20mujkEzMi7fBuTf2+S2P X-Received: by 10.98.196.204 with SMTP id h73mr6726535pfk.143.1518800310007; Fri, 16 Feb 2018 08:58:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518800309; cv=none; d=google.com; s=arc-20160816; b=TzM/TptPAS2jkW12P5TSPAQ8n+bCcSrT/8KmbFMks3DHIoHRbTtl445/lLVW/3ayxf v415TWttG3j3+HHw60S1lbVRVQGR5QzjVd1AvTAzveherHwttemubbV7cWC6tlcKY9F0 YjZLgqPmMSOHcyVeVW9wVskvtjPX6Ufce/D2mprFb3j54ibwdYQBIsj7Jo3pd9cbKdsJ pA4oYw5Q0aRKJT2tkQ6+36/wOV+zCsFy0XBqcDAC8roj27ItjF7NhoMoQvhZEDHW2ZVp 40x2DWM/Spu/0DTJZCSA3OmAa1/sguSQ0+Uplwn6WppVkfHvu1CmhIyV0xKMZuDG3zqH ZrsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=2p9BneH3TRfUd04FmSxhNwC2ORsYSTYwrC/bBWZwMAw=; b=LCtl8igf2vBeOa8oqYa97PIql6gy3za66UZ2LdfpKspzq6g1ld3Lml23oZG2d51KzZ St8yhh/sbedMmpv1q/WnywbgycjHEaqz479IMavS4TseBO5qmTSpVy0MFu7IitTLuGK7 RgOT7H5/NlBW364fyEnzsSqCsvUx43QzxeqLUPm5eSPh1UJwtq0ALmtzQP/nVFRdRvt9 IwkejqxSqliPK/gEmkTDVauY+mz46aKBsTHdYm9KcD986rhd/nyrAV5UvYjfs0XBIm9z AkY5jJXaPA5Wk9JuB1pv1f0H6YY7VKEC1f5i6pH3eG0gM4YovTSF515oQn1+MCT5G4Pu SN9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JXHaM2rm; dkim=pass header.i=@codeaurora.org header.s=default header.b=Y4xkzdfG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j184si1288362pgc.142.2018.02.16.08.58.15; Fri, 16 Feb 2018 08:58:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JXHaM2rm; dkim=pass header.i=@codeaurora.org header.s=default header.b=Y4xkzdfG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033653AbeBOUiK (ORCPT + 99 others); Thu, 15 Feb 2018 15:38:10 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:44648 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033595AbeBOUiH (ORCPT ); Thu, 15 Feb 2018 15:38:07 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 29C75604BE; Thu, 15 Feb 2018 20:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518727087; bh=3abDdweao/R+O3D1SXKqmGfJWXX4tjampiq/kleE+8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JXHaM2rmB7RTlMikCcn2bc6Mgkx3iul1NYK3ulH3G6hkrBVJ7Zlx3pfs3RbYAXb4U c6R4blL+9wBsNh4GpDoqiI3nMtlXP6C4KhDHE0VvPvi7iS3hAf2D9XjwDW2U0IL7d5 02Qaiaf3yMRrvsu8st+UyMe9sh/RLMsCyXgKUJGo= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2ADAE604BE; Thu, 15 Feb 2018 20:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518727086; bh=3abDdweao/R+O3D1SXKqmGfJWXX4tjampiq/kleE+8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y4xkzdfGjZCrkHiWsNfXtyeyX4OkLxH6UUKCw9lTz1Hy6vcLikzHh+dgPm3HPbj2p UFIUnstEm1VZ9jiv0NJeUgsb+CrKcZDMbyuwcBtM2kN9iUsCbcuYvmMJqPHzQ0qTeK txU8waiB/QVQfe7bPu7EXYHO5Tj9fYhxu+M0pvc0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2ADAE604BE Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org Date: Thu, 15 Feb 2018 20:38:05 +0000 From: Lina Iyer To: Steven Rostedt Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 03/10] drivers: qcom: rpmh-rsc: log RPMH requests in FTRACE Message-ID: <20180215203805.GE23714@codeaurora.org> References: <20180215173507.10989-1-ilina@codeaurora.org> <20180215173507.10989-4-ilina@codeaurora.org> <20180215145755.31346aff@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180215145755.31346aff@gandalf.local.home> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 15 2018 at 19:57 +0000, Steven Rostedt wrote: >On Thu, 15 Feb 2018 10:35:00 -0700 >Lina Iyer wrote: > >> @@ -298,6 +303,7 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int m, int n, >> write_tcs_reg(drv, RSC_DRV_CMD_MSGID, m, n + i, msgid); >> write_tcs_reg(drv, RSC_DRV_CMD_ADDR, m, n + i, cmd->addr); >> write_tcs_reg(drv, RSC_DRV_CMD_DATA, m, n + i, cmd->data); >> + trace_rpmh_send_msg(drv, m, n + i, msgid, cmd); > >No biggy, but I'm curious to why you didn't do something this: > >+static void __tcs_buffer_write(struct rsc_drv *drv, int m, int n, >+ struct tcs_request *msg) >+{ >+ u32 msgid, cmd_msgid = 0; >+ u32 cmd_enable = 0; >+ u32 cmd_complete; >+ struct tcs_cmd *cmd; >+ int i; >+ >+ cmd_msgid = CMD_MSGID_LEN; >+ cmd_msgid |= (msg->is_complete) ? CMD_MSGID_RESP_REQ : 0; >+ cmd_msgid |= CMD_MSGID_WRITE; >+ >+ cmd_complete = read_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0); >+ >+ for (i = 0; i < msg->num_payload; i++) { > > int bit = n + i; > >+ cmd = &msg->payload[i]; >+ cmd_enable |= BIT(bit); >+ cmd_complete |= cmd->complete << (n + i); >+ msgid = cmd_msgid; >+ msgid |= (cmd->complete) ? CMD_MSGID_RESP_REQ : 0; >+ write_tcs_reg(drv, RSC_DRV_CMD_MSGID, m, bit, msgid); >+ write_tcs_reg(drv, RSC_DRV_CMD_ADDR, m, bit, cmd->addr); >+ write_tcs_reg(drv, RSC_DRV_CMD_DATA, m, bit, cmd->data); > > trace_rpmh_send_msg(drv, m, bit, msgid, cmd); > >The compiler should optimize that, so this isn't really a big deal, but >I was just curious. > > No particular reason. Think I just went with the logic at that time and didn't look back deeply again on the code to tidy it up. Thanks for the suggestion. >+ } >+ >+ write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0, cmd_complete); >+ cmd_enable |= read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, m, 0); >+ write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, m, 0, cmd_enable); >+} > >> } >> >> write_tcs_reg(drv, RSC_DRV_CMD_WAIT_FOR_CMPL, m, 0, cmd_complete); > >[..] > >> +TRACE_EVENT(rpmh_send_msg, >> + >> + TP_PROTO(struct rsc_drv *d, int m, int n, u32 h, struct tcs_cmd *c), >> + >> + TP_ARGS(d, m, n, h, c), >> + >> + TP_STRUCT__entry( >> + __field(const char*, d->name) >> + __field(int, m) >> + __field(int, n) >> + __field(u32, hdr) >> + __field(u32, addr) >> + __field(u32, data) >> + __field(bool, complete) >> + ), >> + >> + TP_fast_assign( >> + __entry->name = s; >> + __entry->m = m; >> + __entry->n = n; >> + __entry->hdr = h; >> + __entry->addr = c->addr; >> + __entry->data = c->data; >> + __entry->complete = c->complete; >> + ), >> + >> + TP_printk("%s: send-msg: tcs(m): %d cmd(n): %d msgid: 0x%08x addr: 0x%08x data: 0x%08x complete: %d", >> + __entry->name, __entry->m, __entry->n, __entry->hdr, > >I'm sorry I didn't catch this in my other reviews, but please don't use >direct strings in TP_printk(). In trace-cmd and perf, it has no access >to that information when reading this trace event. Not to mention, if >drv is freed between the time it is recorded, and the time it is read >in the trace buffer, you are now referencing random memory. > >The way to do this in a trace event is to use the string functionality: > > TP_STRUCT__entry( > __string(name, d->name) > [..] > TP_fast_assign( > __assign_string(name, d->name) > [..] > TP_printk("%s: ...", > __get_str(name), ... > >Then the name is recorded in the ring buffer at the time of execution >of the trace event, and trace-cmd and perf can read it, and there's no >worries about it being freed between recording and reading the tracing >buffer. > The drv would not be freed. But that said, I will use this in my patches. Thanks Steve. -- Lina