From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753752AbcFQS5r (ORCPT ); Fri, 17 Jun 2016 14:57:47 -0400 Received: from foss.arm.com ([217.140.101.70]:52429 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479AbcFQS5q (ORCPT ); Fri, 17 Jun 2016 14:57:46 -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> <57642608.9070504@arm.com> <20160617125042.24c554a7@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: <57644828.3000000@arm.com> Date: Fri, 17 Jun 2016 13:57:44 -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: <20160617125042.24c554a7@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 On 06/17/2016 11:50 AM, Steven Rostedt wrote: > On Fri, 17 Jun 2016 11:32:08 -0500 > Jeremy Linton wrote: > > >>>> + >>>> + 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 > > I don't see any sizeof() calls in my format files. And still, its > useless to add sizeof() for __u64 and __u32 unless perhaps a type is a > macro defined to that. > > Ah, this is arm64 (as I don't see it in x86). > > No the real fix is to nuke the sizeof(__u64) in the TP_printk(), it's > useless because it will always be 8. That is the simple case, initially I was going to just hand code some of the sizeofs in the kernel, but then I started noticing more complex cases, and why I RFCed this patch. For example, on x64/xen there are fair number with sizeof(pXXval_t), IIRC I've also seen a fair number of sizeof(struct page *). Some, but I dont think all of these case be determined from the field sizes like this one: [root@X tracing]# cat events/xen/xen_mmu_set_pte/format name: xen_mmu_set_pte ID: 45 format: field:unsigned short common_type; offset:0; size:2; signed:0; field:unsigned char common_flags; offset:2; size:1; signed:0; field:unsigned char common_preempt_count; offset:3; size:1; signed:0; field:int common_pid; offset:4; size:4; signed:1; field:pte_t * ptep; offset:8; size:8; signed:0; field:pteval_t pteval; offset:16; size:8; signed:0; print fmt: "ptep %p pteval %0*llx (raw %0*llx)", REC->ptep, (int)sizeof(pteval_t) * 2, (unsigned long long)pte_val(native_make_pte(REC->pteval)), (int)sizeof(pteval_t) * 2, (unsigned long long)REC->pteval