Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2141141imm; Thu, 9 Aug 2018 08:00:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy/hMMtymuK7NEG/gNWurFqonjHGki+BDnVMwpraXXUXDpKJad1t42FGMlpF0puK+eMdjMT X-Received: by 2002:a65:4888:: with SMTP id n8-v6mr2535883pgs.149.1533826805050; Thu, 09 Aug 2018 08:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533826805; cv=none; d=google.com; s=arc-20160816; b=SKmljC7WxG+Szx0HM/f40lYv4xGMYsJy+HrIsVqGDUY8PtktsuWQ1ZOMbjzrk9zWk2 BZdVDqj+O8wpwPQa2Rx87vLb+4pm7Te0Lujxu9m37kBfWlYG6ZYpZ7QinG1VoI3WKA4c 9NuHOC6tzI7REkah+5Iutp78lCHa9Upmk79H6tJmk6YRSkHzwap+Y1IGvyerwucC71gw 9YXvZTeFCYe/Gj+C6m38Vg+ed3CWdzc+MCPIpR815CQq8Ywv0NziGas7dJF+lWMylyY8 bkukIXZ1/ZLAT46Ihy4LrHMj5C+FaGU8g9avIoQn0CL8A6llK5Ql7fku+pWCdF5LjCoJ FHrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=o8ngQuQz7JtVTSpyDGgnS2LTGkc6OEHKqIfj9mn+MOk=; b=AH9qapabjWTTZA910f+EGGImR6HQZ0zRQ+Or2DmSuS+D/BrqyinjtY8wcInl1lIBDa oaBqKFDD4u/+0u1Xg5B5zU74/zYSqbKb2t3WSKCG1gnbvLCLSXSPAtkJlVXA9WOh/U/u eu1avoOCT9oez+Ie1heu4G0Q9EBuywhknVnqIFXn+zwu/ZhS3JsufJayifnol1NsqRoo PJ9oPYBT/SrMP7xfVCviM4HQkbwk3aV+SzdOcJMb21vDuaIvMzUDsD2Lv1Jcz9Z7vvjI uulp7NxABp/R/U4uB3YTKXxv/CbOmfw53BmFvyT4U5aqGaFN+LQZ4dmA8OJIo7gqj5UT yLXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G99yTXnI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13-v6si6625591pgi.317.2018.08.09.07.59.50; Thu, 09 Aug 2018 08:00:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=G99yTXnI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732578AbeHIRYK (ORCPT + 99 others); Thu, 9 Aug 2018 13:24:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:36004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732388AbeHIRYK (ORCPT ); Thu, 9 Aug 2018 13:24:10 -0400 Received: from jouet.infradead.org (179-240-153-38.3g.claro.net.br [179.240.153.38]) (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 EC30121DEC; Thu, 9 Aug 2018 14:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826733; bh=bHI23HoagloeMGhTmGA1BzBzSW4RYbBb2dl6l7pSpzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G99yTXnITueBIX1rzUpNSMolLX/2e9f/ks/0RQKmDBOgJBAS6bNzaAT06r2TiIc3B 8rlX3XJTLDKyNc4jIRiF5WsQks8k4YCO+ZeALmoWMT1u5nYl9PVS/NBgBRZLsCM/dz pOROFFh8TlSPMyOAuQzlx9Esp8TciM3SDIYjZbdc= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , David Ahern , Jiri Olsa , Namhyung Kim , Steven Rostedt , Wang Nan Subject: [PATCH 02/44] perf trace: Use beautifiers on syscalls:sys_enter_ handlers Date: Thu, 9 Aug 2018 11:57:40 -0300 Message-Id: <20180809145822.21391-3-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180809145822.21391-1-acme@kernel.org> References: <20180809145822.21391-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo We were using the beautifiers only when processing the raw_syscalls:sys_enter events, but we can as well use them for the syscalls:sys_enter_NAME events, as the layout is the same. Some more tweaking is needed as we're processing them straight away, i.e. there is no buffering in the sys_enter_NAME event to wait for things like vfs_getname to provide pointer contents and then flushing at sys_exit_NAME, so we need to state in the syscall_arg that this is unbuffered, just print the pointer values, beautifying just non-pointer syscall args. This just shows an alternative way of processing tracepoints, that we will end up using when creating "tracepoint" payloads that already copy pointer contents (or chunks of it, i.e. not the whole filename, but just the end of it, not all the bf for a read/write, but just the start, etc), directly in the kernel using eBPF. E.g.: # perf trace -e syscalls:*enter*sleep,*sleep sleep 1 0.303 ( ): syscalls:sys_enter_nanosleep:rqtp: 0x7ffc93d5ecc0 0.305 (1000.229 ms): sleep/8746 nanosleep(rqtp: 0x7ffc93d5ecc0) = 0 # perf trace -e syscalls:*_*sleep,*sleep sleep 1 0.288 ( ): syscalls:sys_enter_nanosleep:rqtp: 0x7ffecde87e40 0.289 ( ): sleep/8748 nanosleep(rqtp: 0x7ffecde87e40) ... 1000.479 ( ): syscalls:sys_exit_nanosleep:0x0 0.289 (1000.208 ms): sleep/8748 ... [continued]: nanosleep()) = 0 # Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Steven Rostedt Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-jehyd2zwhw00z3p7v7mg9632@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 47 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 2a85f5198da0..7336552c22cf 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1666,6 +1666,44 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel, return err; } +static int trace__fprintf_sys_enter(struct trace *trace, struct perf_evsel *evsel, + struct perf_sample *sample) +{ + struct format_field *field = perf_evsel__field(evsel, "__syscall_nr"); + struct thread_trace *ttrace; + struct thread *thread; + struct syscall *sc; + char msg[1024]; + int id, err = -1; + void *args; + + if (field == NULL) + return -1; + + id = format_field__intval(field, sample, evsel->needs_swap); + sc = trace__syscall_info(trace, evsel, id); + + if (sc == NULL) + return -1; + + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); + ttrace = thread__trace(thread, trace->output); + /* + * We need to get ttrace just to make sure it is there when syscall__scnprintf_args() + * and the rest of the beautifiers accessing it via struct syscall_arg touches it. + */ + if (ttrace == NULL) + goto out_put; + + args = sample->raw_data + field->offset + sizeof(u64); /* skip __syscall_nr, there is where args are */ + syscall__scnprintf_args(sc, msg, sizeof(msg), args, trace, thread); + fprintf(trace->output, "%s", msg); + err = 0; +out_put: + thread__put(thread); + return err; +} + static int trace__resolve_callchain(struct trace *trace, struct perf_evsel *evsel, struct perf_sample *sample, struct callchain_cursor *cursor) @@ -1964,9 +2002,12 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel, if (perf_evsel__is_bpf_output(evsel)) { bpf_output__fprintf(trace, sample); } else if (evsel->tp_format) { - event_format__fprintf(evsel->tp_format, sample->cpu, - sample->raw_data, sample->raw_size, - trace->output); + if (strncmp(evsel->tp_format->name, "sys_enter_", 10) || + trace__fprintf_sys_enter(trace, evsel, sample)) { + event_format__fprintf(evsel->tp_format, sample->cpu, + sample->raw_data, sample->raw_size, + trace->output); + } } fprintf(trace->output, "\n"); -- 2.14.4