Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp75208imm; Wed, 5 Sep 2018 15:15:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZVC3EOgWst6XR7lHA8cgZrqL7ptT6tJWv6qd2mk8SVOpnixR5ZPk/RyvWd7UMpAyFD+k4y X-Received: by 2002:a63:4425:: with SMTP id r37-v6mr38593725pga.391.1536185721053; Wed, 05 Sep 2018 15:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185721; cv=none; d=google.com; s=arc-20160816; b=iteye5A7JkP+cNupihm40VarpTnaS78F3QotOzpJku8DXZ2nk7FG2WmcdvPCPjudQV xBb+nGsnv7mk7LthNqfe66QZxSMzC7KlAiYOrO1/ATzLYcweUPYWIfF8wtViEVlR/S3K n91QW6fqW09EiSJ9BPCkHfTGqQVBWRnWYi/IqkLcI5XBh4Pnp0DkmlvyK/rOwW5Q1MvJ uOrSTwF1x0tlkqjACIiODnOkTMPPiKjrLzSnnB8cS84tSgxEFwY0Mbjo0Oe+zLvCkTyQ clViiEnShXKlZCBH0FzZOegSSNH6cnUdxpGSnbuPUbUkXT90+qVXqBWru0EG4c3DjCxI /kWQ== 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=5IY9Wty+duqhbHA3OKEr7cj2OjuQchHGiaLg/l1MhWQ=; b=Zw3DS3ab4ZWaNS6RNMvLVPpWYp9XgBDS5LGVI+I9b4IGBbuwAcsXnscYjgORPb9iwr KkuMhCQVfi4tc0dmfGWLaSJQbig3xD/t2kRuBqrY4AiQhA7Oau7cAY+PPm2hNbOMhgFQ VfQ5yTfcKmJjqjxuCPaZmxIfiXgt+0x3pUvpH4X3MKQRhKz6Q6Dg2n6czzjdy5POFpt+ Yw7wsGsT7YNDBk7Sk7WnzQICjuyfhGeQNu3IrislG15IFBru97nIw4b8ClK4Ojp46iI7 H/qKym0DhTfrmMFBjx1sKoFpzHZvfZFz+2Ku2aKf7yLNTEAL2FR8/kJknEhsojXIBr3z gdPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mSCDugbB; 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 w8-v6si3262438plk.222.2018.09.05.15.15.01; Wed, 05 Sep 2018 15:15:21 -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=mSCDugbB; 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 S1728089AbeIFCha (ORCPT + 99 others); Wed, 5 Sep 2018 22:37:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:51558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFCh3 (ORCPT ); Wed, 5 Sep 2018 22:37:29 -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 058C52077C; Wed, 5 Sep 2018 22:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185117; bh=ASh+v5nnnlj82pAV2VHcQty992/UfKVUDDBNI6g4Zk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSCDugbBn+cpdGcAfp/NmTSgvljjboAsdx/rqdqVrc9J6xBiCafWqxZKqMyCAjdgc PldeiwxBjFfjQfRyeil0ZNgB/8CxllR+kFOKaqWSAgGebRfhTuUpwAyeoYfcZdXtUt hNj9FOhttobwbta6vyReh9iwqP+Lyq4jGeV2JfoQ= 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 09/77] perf trace: Introduce augmented_filename_syscall_enter() declarator Date: Wed, 5 Sep 2018 19:03:32 -0300 Message-Id: <20180905220440.20256-10-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 Helping with tons of boilerplate for syscalls that only want to augment a filename. Now supporting one such syscall is just a matter of declaring its arguments struct + using: augmented_filename_syscall_enter(openat); Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-ls7ojdseu8fxw7fvj77ejpao@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/augmented_syscalls.c | 78 ++++++++-------------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/tools/perf/examples/bpf/augmented_syscalls.c b/tools/perf/examples/bpf/augmented_syscalls.c index 6ec327850a15..e8486e8597de 100644 --- a/tools/perf/examples/bpf/augmented_syscalls.c +++ b/tools/perf/examples/bpf/augmented_syscalls.c @@ -33,6 +33,25 @@ struct augmented_filename { char value[256]; }; +#define augmented_filename_syscall_enter(syscall) \ +struct augmented_enter_##syscall##_args { \ + struct syscall_enter_##syscall##_args args; \ + struct augmented_filename filename; \ +}; \ +int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \ +{ \ + struct augmented_enter_##syscall##_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; \ +} + struct syscall_enter_openat_args { unsigned long long common_tp_fields; long syscall_nr; @@ -42,24 +61,7 @@ struct syscall_enter_openat_args { long mode; }; -struct augmented_enter_openat_args { - struct syscall_enter_openat_args args; - struct augmented_filename filename; -}; - -int syscall_enter(openat)(struct syscall_enter_openat_args *args) -{ - struct augmented_enter_openat_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; -} +augmented_filename_syscall_enter(openat); struct syscall_enter_open_args { unsigned long long common_tp_fields; @@ -69,50 +71,16 @@ struct syscall_enter_open_args { 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; -} +augmented_filename_syscall_enter(open); struct syscall_enter_inotify_add_watch_args { unsigned long long common_tp_fields; long syscall_nr; long fd; - char *pathname_ptr; + char *filename_ptr; long mask; }; -struct augmented_enter_inotify_add_watch_args { - struct syscall_enter_inotify_add_watch_args args; - struct augmented_filename pathname; -}; - -int syscall_enter(inotify_add_watch)(struct syscall_enter_inotify_add_watch_args *args) -{ - struct augmented_enter_inotify_add_watch_args augmented_args = { .pathname.reserved = 0, }; - - probe_read(&augmented_args.args, sizeof(augmented_args.args), args); - augmented_args.pathname.size = probe_read_str(&augmented_args.pathname.value, - sizeof(augmented_args.pathname.value), - args->pathname_ptr); - perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, - &augmented_args, - sizeof(augmented_args) - sizeof(augmented_args.pathname.value) + augmented_args.pathname.size); - return 0; -} +augmented_filename_syscall_enter(inotify_add_watch); license(GPL); -- 2.14.4