From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753233AbcFQQcT (ORCPT ); Fri, 17 Jun 2016 12:32:19 -0400 Received: from foss.arm.com ([217.140.101.70]:51746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750751AbcFQQcS (ORCPT ); Fri, 17 Jun 2016 12:32:18 -0400 Subject: Re: [RFC/PATCH] perf: Add sizeof operator support To: Steven Rostedt References: <1465922312-30064-1-git-send-email-jeremy.linton@arm.com> <20160617121736.023f009f@gandalf.local.home> Cc: linux-kernel@vger.kernel.org, acme@redhat.com, namhyung@kernel.org, kapileshwar.singh@arm.com, scottwood@freescale.com, hekuang@huawei.com From: Jeremy Linton Message-ID: <57642608.9070504@arm.com> Date: Fri, 17 Jun 2016 11:32:08 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <20160617121736.023f009f@gandalf.local.home> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, On 06/17/2016 11:17 AM, Steven Rostedt wrote: > On Tue, 14 Jun 2016 11:38:32 -0500 > Jeremy Linton wrote: > >> There are a fair number of tracepoints in the kernel making >> use of the sizeof operator. Allow perf to understand some of >> those cases, and report a more informative error message for >> the ones it cannot understand. >> >> Signed-off-by: Jeremy Linton >> --- >> >> So this is as much a RFC as a patch because the use of sizeof >> seems to extend to structures, pointers, etc that aren't easy >> to deduce from userspace. I'm not sure what the correct solution >> should be in those cases. >> >> tools/lib/traceevent/event-parse.c | 46 ++++++++++++++++++++++++++++++++++++++ (trimming) >> + >> + if (strcmp(token, "__u64") == 0) { >> + if (asprintf(&arg->atom.atom, "%zd", sizeof(__u64)) < 0) >> + goto out_free_atom; >> + } else if (strcmp(token, "__u32") == 0) { >> + if (asprintf(&arg->atom.atom, "%zd", sizeof(__u32)) < 0) >> + goto out_free_atom; > > What events are doing sizeof(__u64) and sizeof(__u32)? > > First, that's useless, as sizeof(__u64) will always be 8, and > sizeof(__u32) will always be 4. > > What exactly is this fixing? It starts to fix things like: kmem:mm_page_alloc Warning: [kmem:mm_page_alloc] function sizeof not defined or: # perf stat -e kvm:kvm_arm_set_regset -- true Warning: [kvm:kvm_arm_set_regset] function sizeof not defined Warning: Error: expected type 5 but read 0 *** Error in `perf': double free or corruption (fasttop): 0x00000000303f5930 *** There is a RH bug about it (and the "~" operator, which has been fixed) here: https://bugzilla.redhat.com/show_bug.cgi?id=1298229 Thanks for taking a look at this,