Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2147534imm; Thu, 9 Aug 2018 08:04:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxMrgtAisVbFQOriPBDWqTUUQ+wAyyVi6cKWOEmWijYItgSut8QH50LE4CyYiz30XvRJh2h X-Received: by 2002:a62:3703:: with SMTP id e3-v6mr2779149pfa.117.1533827058276; Thu, 09 Aug 2018 08:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533827058; cv=none; d=google.com; s=arc-20160816; b=m1qSydIY5GGZmMFk3+8lBTSnTZMmDJnaLJ2X+sE8+3k/17Fd9KMYt9I11yK97pIMPc tbUpqz39VGjExx+0HFJVDVgA+9Hovv9kERAcBpnQH9rzNT9JWtqO2GuiBsOclFaKDrQ5 G8rrDDsmjGpo8JRiIp6QWh7r+71n3JG/xrXne3zEylJKIUD6i2B4LuX2FXlo66YYZf8g HuD4ZGU3PpzguIqvRniWrXSkCkWDFJh3hwWsySAnMfuCBWXMgJWEhQsCSBRB/fhuSYbe U2LaL3LMDZuZu9jckT8UaORxlDB55AeWIdZ06o0kfnZXaL6Kf82fPSw2KztXkkrFyQAt +ppA== 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=ltXxijvhieyYrwYc1KNh9+smclxWgR9f/3CWyPc0AHg=; b=VgwMzSksFYeUCD85dpTYTvAInaJbMBk1LrSgNCWQSfnh1UsUMh6W35+HDiCFuqSES6 bnhWvqpt+yeFrGMA1TI9BjGZF7ng8IZQ5tque0MAliAsywDU2K7sKF8STsATW22OVQwZ D3Z5Vrx2aV6P+7xefUJkrkWDjkOjFYYMvujgSB4ys4amqX8w/rPG5fpOmJA4Hk+4mxR6 4lPS1YimAYUBZLPJxMmR8hyH0hVGxjpr0+uQoYJIxCetEdH8ujMvMql8GkUgT+JBsmmz laazKzATXBgzDE5GAP2P6pqz1/TcAYgAb9IZilu1njNClJV/bL9mZ3QKhdpSZeEi8jlf EREw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=we6I9jAw; 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 u3-v6si7443044pgq.354.2018.08.09.08.04.04; Thu, 09 Aug 2018 08:04:18 -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=we6I9jAw; 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 S1733217AbeHIR1N (ORCPT + 99 others); Thu, 9 Aug 2018 13:27:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbeHIR1N (ORCPT ); Thu, 9 Aug 2018 13:27:13 -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 2F84D2183D; Thu, 9 Aug 2018 15:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826915; bh=oWlAJyg24/utvwgo5abGtsf4qsLlHwKnFKURy2VsR54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=we6I9jAwtDYrv4I/ivL1g5cAv1018ytfGo8Sz/gjFb4o0ui6m8OLngtz7v0yNDENv Z0I/klN1I6UKsrEbGouRFF8B958IXNqS7+LA9fAcZ+aJLo5UUBuPUjinsWce7hwFR/ ai4Cr/cW6aLDsVSJj0s7s4yqRwm0EfmjpulTimes= 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 , Wang Nan Subject: [PATCH 41/44] perf trace: Setup the augmented syscalls bpf-output event fields Date: Thu, 9 Aug 2018 11:58:19 -0300 Message-Id: <20180809145822.21391-42-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 The payload that is put in place by the eBPF script attached to syscalls:sys_enter_openat (and other syscalls with pointers, in the future) can be consumed by the existing sys_enter beautifiers if evsel->priv is setup with a struct syscall_tp with struct tp_fields for the 'syscall_id' and 'args' fields expected by the beautifiers, this patch does just that. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-xfjyog8oveg2fjys9r1yy1es@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 43a699cfcadf..06215acb1481 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -77,7 +77,8 @@ struct trace { struct syscall *table; struct { struct perf_evsel *sys_enter, - *sys_exit; + *sys_exit, + *augmented; } events; } syscalls; struct record_opts opts; @@ -263,6 +264,30 @@ static int perf_evsel__init_syscall_tp(struct perf_evsel *evsel) return -ENOENT; } +static int perf_evsel__init_augmented_syscall_tp(struct perf_evsel *evsel) +{ + struct syscall_tp *sc = evsel->priv = malloc(sizeof(struct syscall_tp)); + + if (evsel->priv != NULL) { /* field, sizeof_field, offsetof_field */ + if (__tp_field__init_uint(&sc->id, sizeof(long), sizeof(long long), evsel->needs_swap)) + goto out_delete; + + return 0; + } + + return -ENOMEM; +out_delete: + zfree(&evsel->priv); + return -EINVAL; +} + +static int perf_evsel__init_augmented_syscall_tp_args(struct perf_evsel *evsel) +{ + struct syscall_tp *sc = evsel->priv; + + return __tp_field__init_ptr(&sc->args, sc->id.offset + sizeof(u64)); +} + static int perf_evsel__init_raw_syscall_tp(struct perf_evsel *evsel, void *handler) { evsel->priv = malloc(sizeof(struct syscall_tp)); @@ -3248,6 +3273,13 @@ int cmd_trace(int argc, const char **argv) goto out; } + if (evsel) { + if (perf_evsel__init_augmented_syscall_tp(evsel) || + perf_evsel__init_augmented_syscall_tp_args(evsel)) + goto out; + trace.syscalls.events.augmented = evsel; + } + err = bpf__setup_stdout(trace.evlist); if (err) { bpf__strerror_setup_stdout(trace.evlist, err, bf, sizeof(bf)); -- 2.14.4