Messages in this thread | | | Date | Fri, 17 Jun 2016 15:08:27 -0400 | From | Steven Rostedt <> | Subject | Re: [RFC/PATCH] perf: Add sizeof operator support |
| |
On Fri, 17 Jun 2016 13:57:44 -0500 Jeremy Linton <jeremy.linton@arm.com> wrote:
> 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:
Right, but there's no easy fix for that. Your patch wont fix these, because they can change over time.
Now, what we can do is add a sizeof() helper that is like the TRACE_DEFINE_ENUM() macro. We could add a TRACE_DEFINE_SIZEOF(), that basically does the same, and in update_event_printk() we could substitute the sizeof() with the actual number value.
You want to take a crack at that?
Take a look at commit 0c564a538aa93.
-- Steve
> > [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 >
| |