Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp67024imm; Wed, 5 Sep 2018 15:06:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ4M6Jk4lLUECy3wvmntUDd8TLCCWECQZj91tHXH2fJ8V8KaR57zl2M8DajV432clNPa8Ot X-Received: by 2002:a63:221b:: with SMTP id i27-v6mr31165206pgi.212.1536185214094; Wed, 05 Sep 2018 15:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185214; cv=none; d=google.com; s=arc-20160816; b=NuMRdyL1J424x9Uw/rDFSP+W8yFS1ihwoBmvQ9tCHuyWvt+z/3maYmKpbDmOjWXtYM P08IaCoEO/4kyGwzo+iF4nOISv3NiC5MT3PG0dU6LJSj2Wy3Q21dJrYwKyNOgR8Cv3uv x7Wglh9lcDIHFg9XLZiD4IcwOSJ/f7l6wUdzvEPDQbzHF7a5dLbACV5rAr/dL0O7lE/8 hmPpwhK/EMKSyvRKaU7kcEGxoqwLnxQHJ2yuGj3nOCTIbuOmZAeel+Nwvvh0fDFeeTR9 d6fAZDphRaW8yi/1GBHAoq49zUtu69OYXUFW8gjslDi1nHBkn67jex5tsTaAQ9y5jgeK s+YQ== 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; bh=7fCrxU6zkdiGWKsJ+tDpzRTd959KYZJ+tB3qVE/p408=; b=uyELruKGlT+IeYEjNZKaOJBwvWMB7zyzpT69zt1e39VE6hHccWgTAR/ilkUfPWt6mQ pGJefHJZ21XzUC5Bl8GDlGRmM+5WXWIScbHyXMaTc0g39mQax3mvF8fFoSzOdtXlGLW0 Izp8+RYxhdYxQ73OKqEh76N2LvnKRjcZrqxOnZLxltW0KRbFT7HOJ8Q0DWpMpV4eBlfn pF2gdPMP4xOGaUjZUDbCH6+e9ePLkoiKRvQGKIKAyJFHUZ+E8VZsvXG4SXeV8ZAOpYq/ PuinU49pjq9e458PfnvEFwg5P8YJ00x8pk4i8zeDLCgMEUGvXO5pAjNEOG/sPacdxHwg SJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2po0MnEj; 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 l30-v6si3177166plg.12.2018.09.05.15.06.37; Wed, 05 Sep 2018 15:06:54 -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=2po0MnEj; 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 S1728039AbeIFChY (ORCPT + 99 others); Wed, 5 Sep 2018 22:37:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:51418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFChX (ORCPT ); Wed, 5 Sep 2018 22:37:23 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (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 C7F662083E; Wed, 5 Sep 2018 22:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185111; bh=N3TyeQXLGAXgTIi++Q9/A7EssG9eP0RC0TMJOjGq3vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2po0MnEj0FthPBYY1rupBQfnRlfKyZYhSk7g+iMINEQtj9gY1zmxujZAmPYnfq4oH yORyrURauLILL+SuV4S9e+f+99/2kBkvgNZ92GPe1jk+MWLtYY7arsZySu4iv9ilft oT3ZUYzGhDYBCD9BRFS+wItXjUX/FJAzd1gI0WMc= 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 07/77] perf trace: Augment the 'open' syscall 'filename' arg Date: Wed, 5 Sep 2018 19:03:30 -0300 Message-Id: <20180905220440.20256-8-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-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 As described in the previous cset, all we had to do was to touch the augmented_syscalls.c eBPF program, fire up 'perf trace' with that new eBPF script in system wide mode and wait for 'open' syscalls, in addition to 'openat' ones to see that it works: # perf trace -e tools/perf/examples/bpf/augmented_syscalls.c 0.000 StreamT~s #200/16150 openat(dfd: CWD, filename: /home/acme/.mozilla/firefox/fqxhj76d.default/prefs.js, flags: CREAT|EXCL|TRUNC|WRONLY, mode: IRUSR|IWUSR) 0.065 StreamT~s #200/16150 openat(dfd: CWD, filename: /home/acme/.mozilla/firefox/fqxhj76d.default/prefs-1.js, flags: CREAT|EXCL|TRUNC|WRONLY, mode: IRUSR|IWUSR) 0.435 StreamT~s #200/16150 openat(dfd: CWD, filename: /home/acme/.mozilla/firefox/fqxhj76d.default/prefs-1.js, flags: CREAT|TRUNC|WRONLY, mode: IRUSR|IWUSR) 1.875 perf/16772 openat(dfd: CWD, filename: /sys/kernel/debug/tracing/events/syscalls/sys_enter_openat/form) 1227.260 gnome-shell/1463 openat(dfd: CWD, filename: /proc/self/stat) 1227.397 gnome-shell/2125 openat(dfd: CWD, filename: /proc/self/stat) 7227.619 gnome-shell/1463 openat(dfd: CWD, filename: /proc/self/stat) 7227.661 gnome-shell/2125 openat(dfd: CWD, filename: /proc/self/stat) 10018.079 gnome-shell/1463 openat(dfd: CWD, filename: /proc/self/stat) 10018.514 perf/16772 openat(dfd: CWD, filename: /proc/1237/status) 10018.568 perf/16772 openat(dfd: CWD, filename: /proc/1237/status) 10022.409 gnome-shell/2125 openat(dfd: CWD, filename: /proc/self/stat) 10090.044 NetworkManager/1237 openat(dfd: CWD, filename: /proc/2125/stat) 10090.351 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 10090.407 perf/16772 openat(dfd: CWD, filename: /sys/kernel/debug/tracing/events/syscalls/sys_enter_open/format) 10091.763 NetworkManager/1237 openat(dfd: CWD, filename: /proc/2125/stat) 10091.812 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 10092.807 NetworkManager/1237 openat(dfd: CWD, filename: /proc/2125/stat) 10092.851 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 10094.650 NetworkManager/1237 openat(dfd: CWD, filename: /proc/1463/stat) 10094.926 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 10096.010 NetworkManager/1237 openat(dfd: CWD, filename: /proc/1463/stat) 10096.057 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 10097.056 NetworkManager/1237 openat(dfd: CWD, filename: /proc/1463/stat) 10097.099 NetworkManager/1237 open(filename: /etc/passwd, flags: CLOEXEC) 13228.345 gnome-shell/1463 openat(dfd: CWD, filename: /proc/self/stat) 13232.734 gnome-shell/2125 openat(dfd: CWD, filename: /proc/self/stat) 15198.956 lighttpd/16748 open(filename: /proc/loadavg, mode: ISGID|IXOTH) ^C# It even catches 'perf' itself looking at the sys_enter_open and sys_enter_openat tracefs format dictionaries when it first finds them in the trace... :-) Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-upmogc57uatljr6el6u8537l@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/augmented_syscalls.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c index 93960e891478..154379463c95 100644 --- a/tools/perf/examples/bpf/augmented_syscalls.c +++ b/tools/perf/examples/bpf/augmented_syscalls.c @@ -61,4 +61,31 @@ int syscall_enter(openat)(struct syscall_enter_openat_args *args) return 0; } +struct syscall_enter_open_args { + unsigned long long common_tp_fields; + long syscall_nr; + char *filename_ptr; + long flags; + long mode; +}; + +struct augmented_enter_open_args { + struct syscall_enter_open_args args; + struct augmented_filename filename; +}; + +int syscall_enter(open)(struct syscall_enter_open_args *args) +{ + struct augmented_enter_open_args augmented_args = { .filename.reserved = 0, }; + + probe_read(&augmented_args.args, sizeof(augmented_args.args), args); + augmented_args.filename.size = probe_read_str(&augmented_args.filename.value, + sizeof(augmented_args.filename.value), + args->filename_ptr); + perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, + &augmented_args, + sizeof(augmented_args) - sizeof(augmented_args.filename.value) + augmented_args.filename.size); + return 0; +} + license(GPL); -- 2.14.4