From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757170AbdJKL76 (ORCPT ); Wed, 11 Oct 2017 07:59:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbdJKL75 (ORCPT ); Wed, 11 Oct 2017 07:59:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BBC217E383 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Wed, 11 Oct 2017 13:59:54 +0200 From: Jiri Olsa To: Peter Zijlstra Cc: rostedt@goodmis.org, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, zhouchengming1@huawei.com Subject: Re: [PATCH 2/4] perf/ftrace: Fix function trace events Message-ID: <20171011115954.GA7940@krava> References: <20171011074528.764500836@infradead.org> <20171011080224.257804988@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171011080224.257804988@infradead.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 11 Oct 2017 11:59:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 11, 2017 at 09:45:30AM +0200, Peter Zijlstra wrote: SNIP > void perf_trace_del(struct perf_event *p_event, int flags) > { > struct trace_event_call *tp_event = p_event->tp_event; > - hlist_del_rcu(&p_event->hlist_entry); > - tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event); > + > + /* > + * If TRACE_REG_PERF_DEL returns false; no custom action was performed > + * and we need to take the default action of dequeueing our event from > + * the right per-cpu hlist. > + */ > + if (!tp_event->class->reg(tp_event, TRACE_REG_PERF_DEL, p_event)) > + hlist_del_rcu(&p_event->hlist_entry); > } > > void *perf_trace_buf_alloc(int size, struct pt_regs **regs, int *rctxp) > @@ -307,14 +321,24 @@ perf_ftrace_function_call(unsigned long > struct ftrace_ops *ops, struct pt_regs *pt_regs) > { > struct ftrace_entry *entry; > - struct hlist_head *head; > + struct perf_event *event; > + struct hlist_head head; > struct pt_regs regs; > int rctx; > > - head = this_cpu_ptr(event_function.perf_events); > - if (hlist_empty(head)) > + if ((unsigned long)ops->private != smp_processor_id()) > return; > > + event = container_of(ops, struct perf_event, ftrace_ops); > + > + /* > + * @event->hlist entry is NULL (per INIT_HLIST_NODE), and all > + * the perf code does is hlist_for_each_entry_rcu(), so we can > + * get away with simply setting the @head.first pointer in order > + * to create a singular list. > + */ > + head.first = &event->hlist_entry; > + > #define ENTRY_SIZE (ALIGN(sizeof(struct ftrace_entry) + sizeof(u32), \ > sizeof(u64)) - sizeof(u32)) > > @@ -330,7 +354,7 @@ perf_ftrace_function_call(unsigned long > entry->ip = ip; > entry->parent_ip = parent_ip; > perf_trace_buf_submit(entry, ENTRY_SIZE, rctx, TRACE_FN, > - 1, ®s, head, NULL); > + 1, ®s, &head, NULL); nice idea.. I'll test it jirka