From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9195 invoked by alias); 11 Sep 2009 19:26:48 -0000 Received: (qmail 9188 invoked by uid 22791); 11 Sep 2009 19:26:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1-old.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 11 Sep 2009 19:26:41 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com ([10.11.47.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8BJQct3018046 for ; Fri, 11 Sep 2009 15:26:38 -0400 Received: from [10.16.2.46] (dhcp-100-2-46.bos.redhat.com [10.16.2.46]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8BJQYWs011383; Fri, 11 Sep 2009 15:26:35 -0400 Message-ID: <4AAAA550.9010203@redhat.com> Date: Fri, 11 Sep 2009 19:26:00 -0000 From: Masami Hiramatsu User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3 MIME-Version: 1.0 To: Frederic Weisbecker CC: Steven Rostedt , Ingo Molnar , lkml , systemtap , DLE , Jim Keniston , Ananth N Mavinakayanahalli , Andi Kleen , Christoph Hellwig , "Frank Ch. Eigler" , "H. Peter Anvin" , Jason Baron , "K.Prasad" , Lai Jiangshan , Li Zefan , Peter Zijlstra , Srikar Dronamraju , Tom Zanussi Subject: Re: [PATCH tracing/kprobes 4/7] tracing/kprobes: Add event profiling support References: <20090910235258.22412.29317.stgit@dhcp-100-2-132.bos.redhat.com> <20090910235329.22412.94731.stgit@dhcp-100-2-132.bos.redhat.com> <20090911031253.GD16396@nowhere> In-Reply-To: <20090911031253.GD16396@nowhere> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00692.txt.bz2 Frederic Weisbecker wrote: > On Thu, Sep 10, 2009 at 07:53:30PM -0400, Masami Hiramatsu wrote: >> +#ifdef CONFIG_EVENT_PROFILE >> + >> +/* Kprobe profile handler */ >> +static __kprobes int kprobe_profile_func(struct kprobe *kp, >> + struct pt_regs *regs) >> +{ >> + struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp); >> + struct ftrace_event_call *call =&tp->call; >> + struct kprobe_trace_entry *entry; >> + int size, i, pc; >> + unsigned long irq_flags; >> + >> + local_save_flags(irq_flags); >> + pc = preempt_count(); >> + >> + size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args); > > > > Note that the end-result must be u64 aligned for perf ring buffer. > And this is a bit tricky. > What is inserted in the perf ring buffer is: > > raw_trace + (u32)raw_trace_size > > So we must ensure that sizeof(raw_trace) + sizeof(u32) > is well u64 aligned. > > We don't insert the trace_size ourself though, this is done > from kernel/perf_counter.c > > But we need to handle the size of the size (sorry) in the final > alignment. > To sum-up: sizeof(raw_trace) doesn't need (shouldn't) to be u64 > aligned but sizeof(raw_trace) + sizeof(u32) must be. > > Given this aligned size, we then substract it by sizeof(u32) > to have the needed size of the raw entry. > > This result gives you the size of char raw_data[], which > is also the same size passed in perf_tpcounter_event(). > > See? Ah, I see. So the size to write to perf_tpcounter_event must be '(a multiple number of sizeof(u64)) - sizeof(u32)', right? (Hmm, why would not perf_counter align data by itself? :) > > That's why we have this in trace/ftrace.h: > > __data_size = "the real entry data size" > __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32), sizeof(u64)); > __entry_size -= sizeof(u32); > > do { > char raw_data[__entry_size]; > ... > perf_tpcounter_event(event_call->id, __addr, __count, entry, > __entry_size); > ... > } while (0); Ok, I'll do that. Thank you, -- Masami Hiramatsu Software Engineer Hitachi Computer Products (America), Inc. Software Solutions Division e-mail: mhiramat@redhat.com