From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935105AbdGTIoB (ORCPT ); Thu, 20 Jul 2017 04:44:01 -0400 Received: from terminus.zytor.com ([65.50.211.136]:58371 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932806AbdGTIn5 (ORCPT ); Thu, 20 Jul 2017 04:43:57 -0400 Date: Thu, 20 Jul 2017 01:41:42 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: tglx@linutronix.de, namhyung@kernel.org, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, acme@redhat.com, jolsa@kernel.org, adrian.hunter@intel.com, ast@kernel.org, wangnan0@huawei.com, dsahern@gmail.com Reply-To: linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com, namhyung@kernel.org, tglx@linutronix.de, dsahern@gmail.com, wangnan0@huawei.com, ast@kernel.org, adrian.hunter@intel.com, jolsa@kernel.org, acme@redhat.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf beauty open: Detach the syscall_arg agnostic bits from the flags formatter Git-Commit-ID: b239ad28a8c9571c45e62e486ce75ebad17de6c1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b239ad28a8c9571c45e62e486ce75ebad17de6c1 Gitweb: http://git.kernel.org/tip/b239ad28a8c9571c45e62e486ce75ebad17de6c1 Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 14 Jul 2017 11:18:41 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 18 Jul 2017 23:13:57 -0300 perf beauty open: Detach the syscall_arg agnostic bits from the flags formatter We may want to use this in other contexts, like when formatting the return of fcntl(fd, F_GETFL). Make it have the following signature, so that we can set the formatter for the return argument while processing the arguments of a syscall, as fcntl, for instance, may return fds, flags, etc, so need different return value formatters: size_t formatter(unsigned long value, char *bf, size_t size); This gets so detached from 'perf trace' internals that we may well get all these and move to a tools/lib/syscall_beauty/ library at some point and use it in other tools/ living utilities. Cc: Adrian Hunter Cc: Alexei Starovoitov Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-9aw8t22ztvnkuv26l6sw1c18@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/beauty.h | 2 ++ tools/perf/trace/beauty/open_flags.c | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index d76f903..c05bb2e 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -52,4 +52,6 @@ size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_ size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg); #define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask +size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size); + #endif /* _PERF_TRACE_BEAUTY_H */ diff --git a/tools/perf/trace/beauty/open_flags.c b/tools/perf/trace/beauty/open_flags.c index f55a459..b3c7f11 100644 --- a/tools/perf/trace/beauty/open_flags.c +++ b/tools/perf/trace/beauty/open_flags.c @@ -14,13 +14,9 @@ #define O_NOATIME 01000000 #endif -static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, - struct syscall_arg *arg) +size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size) { - int printed = 0, flags = arg->val; - - if (!(flags & O_CREAT)) - arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ + int printed = 0; if (flags == 0) return scnprintf(bf, size, "RDONLY"); @@ -68,4 +64,15 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, return printed; } +static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg) +{ + int flags = arg->val; + + if (!(flags & O_CREAT)) + arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ + + return open__scnprintf_flags(flags, bf, size); +} + + #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags