Received: by 10.213.65.68 with SMTP id h4csp334308imn; Sat, 17 Mar 2018 05:43:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELtoKrCpALi2ONcXEglTophcDmbSGWBZNnWpBQufkkxuEsMxGQqc10yCVvhXi8P5gFLk00Wz X-Received: by 2002:a17:902:51ee:: with SMTP id y101-v6mr5680379plh.359.1521290638388; Sat, 17 Mar 2018 05:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521290638; cv=none; d=google.com; s=arc-20160816; b=047+kX7EdHy1Z/lO2Sxsrgqe7NkuEg6LilBbmIgRaSqm5vz5s+GnChH0WEh2XJfmbX iIHPRPDEtls0ax1YqwTSgosEEw/Z0dGCa3HuZ7Kn+r7jto05A9nqSWVyKToVjqdO7aVL PzYhA6GygJIwvJEHahAb1xCuKYyEoxPioPKSWwwaYFXD5Lh24/2iR9nmvsa6Utuk8ywa xwR26NpvQ6irfRbCp5P8GSP4DI8npfuLy9H6ThBCSf8SSNMhXZBJLpvnId3w4jrDkENr K2R2CChlaWFFsokW9iYNTo+24PHYdGw77hYcO2zoD/cO/YDRENK3tfiPunD6mJ0z/b3G pkuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dmarc-filter:arc-authentication-results; bh=fdAx+enDYxh8unaHzZI8nmGzbhTE/m6LL3QnNr7aFPY=; b=XALl6CNenKe3DaAMC1VpcaONYRZGToPgTf5IYohpsX6ZHHqMTK7vkxRgb4vCDpZfHg XNk/AI20/VlEF9IEZPo+ngkCEjKFARkopWMtSz2kYhmKLah3UXLUMmAOCX52XiEhTccx F7ze9hWUfKXBXc+amvhBLMCBQjacft++eRu/y/UnqChv1J3K7Sbt82kevPdboDL55Nou 01DiTz9p/tzJcYKOs6bH1KMnrv+YJ94U700gC8Y1/oZA/mTiVshgqzW1b3c3i/2fMm4b ocZDapxEyGAipHIvQrRe4iwz5pLlCBBNPnRnc8UB+mcwY2dI/k7cxZNCAzWoXR+aSBuh iGiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si2034013pgp.431.2018.03.17.05.43.44; Sat, 17 Mar 2018 05:43:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753141AbeCQMmp (ORCPT + 99 others); Sat, 17 Mar 2018 08:42:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:50810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752674AbeCQMmo (ORCPT ); Sat, 17 Mar 2018 08:42:44 -0400 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBD172177C; Sat, 17 Mar 2018 12:42:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBD172177C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org From: Masami Hiramatsu To: Steven Rostedt , linux-kernel@vger.kernel.org Cc: mhiramat@kernel.org, Ingo Molnar , Namhyung Kim , Tom Zanussi , Arnaldo Carvalho de Melo , linux-trace-users@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, Ravi Bangoria Subject: [PATCH v6 06/21] tracing: probeevent: Cleanup argument field definition Date: Sat, 17 Mar 2018 21:41:55 +0900 Message-Id: <152129051562.31874.14164494878447631336.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <152129024033.31874.15800253385376959274.stgit@devbox> References: <152129024033.31874.15800253385376959274.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cleanup event argument definition code in one place for maintenancability. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace_kprobe.c | 32 ++++---------------------------- kernel/trace/trace_probe.c | 21 +++++++++++++++++++++ kernel/trace/trace_probe.h | 2 ++ kernel/trace/trace_uprobe.c | 15 ++------------- 4 files changed, 29 insertions(+), 41 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 81e2eb5a1566..a8f8cce066a9 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -1146,49 +1146,25 @@ print_kretprobe_event(struct trace_iterator *iter, int flags, static int kprobe_event_define_fields(struct trace_event_call *event_call) { - int ret, i; + int ret; struct kprobe_trace_entry_head field; struct trace_kprobe *tk = (struct trace_kprobe *)event_call->data; DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0); - /* Set argument names as fields */ - for (i = 0; i < tk->tp.nr_args; i++) { - struct probe_arg *parg = &tk->tp.args[i]; - ret = trace_define_field(event_call, parg->type->fmttype, - parg->name, - sizeof(field) + parg->offset, - parg->type->size, - parg->type->is_signed, - FILTER_OTHER); - if (ret) - return ret; - } - return 0; + return traceprobe_define_arg_fields(event_call, sizeof(field), &tk->tp); } static int kretprobe_event_define_fields(struct trace_event_call *event_call) { - int ret, i; + int ret; struct kretprobe_trace_entry_head field; struct trace_kprobe *tk = (struct trace_kprobe *)event_call->data; DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0); DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0); - /* Set argument names as fields */ - for (i = 0; i < tk->tp.nr_args; i++) { - struct probe_arg *parg = &tk->tp.args[i]; - ret = trace_define_field(event_call, parg->type->fmttype, - parg->name, - sizeof(field) + parg->offset, - parg->type->size, - parg->type->is_signed, - FILTER_OTHER); - if (ret) - return ret; - } - return 0; + return traceprobe_define_arg_fields(event_call, sizeof(field), &tk->tp); } #ifdef CONFIG_PERF_EVENTS diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 8894b81e29b0..049e8531fdf8 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -680,3 +680,24 @@ int set_print_fmt(struct trace_probe *tp, bool is_return) return 0; } + +int traceprobe_define_arg_fields(struct trace_event_call *event_call, + size_t offset, struct trace_probe *tp) +{ + int ret, i; + + /* Set argument names as fields */ + for (i = 0; i < tp->nr_args; i++) { + struct probe_arg *parg = &tp->args[i]; + + ret = trace_define_field(event_call, parg->type->fmttype, + parg->name, + offset + parg->offset, + parg->type->size, + parg->type->is_signed, + FILTER_OTHER); + if (ret) + return ret; + } + return 0; +} diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 0c8e66f9c855..de928052926b 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -440,3 +440,5 @@ extern struct trace_event_call * create_local_trace_uprobe(char *name, unsigned long offs, bool is_return); extern void destroy_local_trace_uprobe(struct trace_event_call *event_call); #endif +extern int traceprobe_define_arg_fields(struct trace_event_call *event_call, + size_t offset, struct trace_probe *tp); diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 4c006a693663..887da2bb63aa 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -982,7 +982,7 @@ probe_event_disable(struct trace_uprobe *tu, struct trace_event_file *file) static int uprobe_event_define_fields(struct trace_event_call *event_call) { - int ret, i, size; + int ret, size; struct uprobe_trace_entry_head field; struct trace_uprobe *tu = event_call->data; @@ -994,19 +994,8 @@ static int uprobe_event_define_fields(struct trace_event_call *event_call) DEFINE_FIELD(unsigned long, vaddr[0], FIELD_STRING_IP, 0); size = SIZEOF_TRACE_ENTRY(false); } - /* Set argument names as fields */ - for (i = 0; i < tu->tp.nr_args; i++) { - struct probe_arg *parg = &tu->tp.args[i]; - - ret = trace_define_field(event_call, parg->type->fmttype, - parg->name, size + parg->offset, - parg->type->size, parg->type->is_signed, - FILTER_OTHER); - if (ret) - return ret; - } - return 0; + return traceprobe_define_arg_fields(event_call, size, &tu->tp); } #ifdef CONFIG_PERF_EVENTS