All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Support perf -vv
@ 2018-03-30  9:27 Jin Yao
  2018-03-30  9:27 ` [PATCH v4 1/6] tools include: Add config.h header file Jin Yao
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

We keep having bug reports that when users build perf on their own,
but they don't install some needed libraries such as libelf,
libbfd/libibery.

The perf can build, but it is missing important functionality. And
users may complain that perf has issue or bug.

This patch-set support to print the status of compiled-in libraries.

Once users think perf missing some functionality, it should be very
easy for them to check the libraries status.

For example:

$ ./perf version --build-options
    or
  ./perf --version --build-options
    or
  ./perf -v --build-options
    or
  ./perf -vv

perf version 4.13.rc5.g6727c5
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
              libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
                libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v4:
---
1. Also print the macro name. That would make it easier
   to grep around in the source looking for where code
   related a particular features is located.

2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
   HAVE_DWARF_GETLOCATIONS_SUPPORT

Patch impacted:
---------------
  perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
  perf version: Print the compiled-in status of libraries
  others not changed

Jin Yao (5):
  perf config: Add some new -DHAVE_XXX to CFLAGS
  perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
  perf version: Print the compiled-in status of libraries
  perf: Support perf -vv
  perf Documentation: Create perf-version.txt

Jiri Olsa (1):
  tools include: Add config.h header file

 tools/include/tools/config.h              | 34 +++++++++++++
 tools/perf/Documentation/perf-version.txt | 24 +++++++++
 tools/perf/Makefile.config                |  8 ++-
 tools/perf/builtin-version.c              | 82 ++++++++++++++++++++++++++++++-
 tools/perf/perf.c                         |  6 +++
 tools/perf/perf.h                         |  1 +
 tools/perf/util/dwarf-aux.c               |  2 +-
 7 files changed, 154 insertions(+), 3 deletions(-)
 create mode 100644 tools/include/tools/config.h
 create mode 100644 tools/perf/Documentation/perf-version.txt

-- 
2.7.4

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v4 1/6] tools include: Add config.h header file
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
@ 2018-03-30  9:27 ` Jin Yao
  2018-04-04  5:30   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2018-03-30  9:27 ` [PATCH v4 3/6] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT Jin Yao
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin

From: Jiri Olsa <jolsa@kernel.org>

Adding IS_BUILTIN macro and its dependencies into
tools world.

It's taken from kernel's include/linux/kconfig.h,
which can't be taken completely due to its kconfig
dependencies.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/include/tools/config.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 tools/include/tools/config.h

diff --git a/tools/include/tools/config.h b/tools/include/tools/config.h
new file mode 100644
index 0000000..08ade7d
--- /dev/null
+++ b/tools/include/tools/config.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_CONFIG_H
+#define _TOOLS_CONFIG_H
+
+/* Subset of include/linux/kconfig.h */
+
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
+ * Getting something that works in C and CPP for an arg that may or may
+ * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
+ * we match on the placeholder define, insert the "0," for arg1 and generate
+ * the triplet (0, 1, 0).  Then the last step cherry picks the 2nd arg (a one).
+ * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
+ * the last step cherry picks the 2nd arg, we get a zero.
+ */
+#define __is_defined(x)			___is_defined(x)
+#define ___is_defined(val)		____is_defined(__ARG_PLACEHOLDER_##val)
+#define ____is_defined(arg1_or_junk)	__take_second_arg(arg1_or_junk 1, 0)
+
+/*
+ * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
+ * otherwise. For boolean options, this is equivalent to
+ * IS_ENABLED(CONFIG_FOO).
+ */
+#define IS_BUILTIN(option) __is_defined(option)
+
+#endif /* _TOOLS_CONFIG_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 3/6] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
  2018-03-30  9:27 ` [PATCH v4 1/6] tools include: Add config.h header file Jin Yao
@ 2018-03-30  9:27 ` Jin Yao
  2018-04-04  5:31   ` [tip:perf/urgent] " tip-bot for Jin Yao
  2018-03-30  9:27 ` [PATCH v4 4/6] perf version: Print the compiled-in status of libraries Jin Yao
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

In Makefile.config, to make all libraries flags have _SUPPORT suffix,
rename HAVE_DWARF_GETLOCATIONS to HAVE_DWARF_GETLOCATIONS_SUPPORT

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/Makefile.config  | 2 +-
 tools/perf/util/dwarf-aux.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index deb8fba..c7abd83 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -346,7 +346,7 @@ else
       ifneq ($(feature-dwarf_getlocations), 1)
         msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
       else
-        CFLAGS += -DHAVE_DWARF_GETLOCATIONS
+        CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
       endif # dwarf_getlocations
     endif # Dwarf support
   endif # libelf support
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index f5acda1..7eb7de5 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -979,7 +979,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
 	return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
 }
 
-#ifdef HAVE_DWARF_GETLOCATIONS
+#ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
 /**
  * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
  * @sp_die: a subprogram DIE
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 4/6] perf version: Print the compiled-in status of libraries
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
  2018-03-30  9:27 ` [PATCH v4 1/6] tools include: Add config.h header file Jin Yao
  2018-03-30  9:27 ` [PATCH v4 3/6] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT Jin Yao
@ 2018-03-30  9:27 ` Jin Yao
  2018-04-02 16:47   ` Arnaldo Carvalho de Melo
  2018-04-04  5:31   ` [tip:perf/urgent] " tip-bot for Jin Yao
  2018-03-30  9:27 ` [PATCH v4 5/6] perf: Support perf -vv Jin Yao
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
print the status of libraries.

For example, if HAVE_DWARF_SUPPORT is defined, that means the
library "dwarf" is compiled-in. The patch will print the status
"on" for this library otherwise it print the status "OFF".

A new option '--build-options' created for 'perf version' supports
the printing of library status.

For example:

$ ./perf version --build-options
    or
  ./perf --version --build-options
    or
  ./perf -v --build-options

perf version 4.13.rc5.g6727c5
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
              libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
                libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v4:
---
1. Also print the macro name. That would make it easier
   to grep around in the source looking for where code
   related a particular features is located.

2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
   HAVE_DWARF_GETLOCATIONS_SUPPORT

v3:
---
Remove following unnecessary help message.

1. [ on  ]: library is compiled-in
   [ OFF ]: library is disabled in make configuration
            OR library is not installed in build environment

2. Create '--build-options' option.

3. Use standard option parsing API 'parse_options'.

v2:
---
1. Use IS_BUILTIN macro to replace #ifdef/#endif block.

2. Print color for on/OFF.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/builtin-version.c | 82 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 37019c5..2abe391 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -1,11 +1,91 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "builtin.h"
 #include "perf.h"
+#include "color.h"
 #include <linux/compiler.h>
+#include <tools/config.h>
 #include <stdio.h>
+#include <string.h>
+#include <subcmd/parse-options.h>
 
-int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
+int version_verbose;
+
+struct version {
+	bool	build_options;
+};
+
+static struct version version;
+
+static struct option version_options[] = {
+	OPT_BOOLEAN(0, "build-options", &version.build_options,
+		    "display the build options"),
+};
+
+static const char * const version_usage[] = {
+	"perf version [<options>]",
+	NULL
+};
+
+static void on_off_print(const char *status)
+{
+	printf("[ ");
+
+	if (!strcmp(status, "OFF"))
+		color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
+	else
+		color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
+
+	printf(" ]");
+}
+
+static void status_print(const char *name, const char *macro,
+			 const char *status)
 {
+	printf("%22s: ", name);
+	on_off_print(status);
+	printf("  # %s\n", macro);
+}
+
+#define STATUS(__d, __m)				\
+do {							\
+	if (IS_BUILTIN(__d))				\
+		status_print(#__m, #__d, "on");		\
+	else						\
+		status_print(#__m, #__d, "OFF");	\
+} while (0)
+
+static void library_status(void)
+{
+	STATUS(HAVE_DWARF_SUPPORT, dwarf);
+	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
+	STATUS(HAVE_GLIBC_SUPPORT, glibc);
+	STATUS(HAVE_GTK2_SUPPORT, gtk2);
+	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
+	STATUS(HAVE_LIBBFD_SUPPORT, libbfd);
+	STATUS(HAVE_LIBELF_SUPPORT, libelf);
+	STATUS(HAVE_LIBNUMA_SUPPORT, libnuma);
+	STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus);
+	STATUS(HAVE_LIBPERL_SUPPORT, libperl);
+	STATUS(HAVE_LIBPYTHON_SUPPORT, libpython);
+	STATUS(HAVE_SLANG_SUPPORT, libslang);
+	STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto);
+	STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind);
+	STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind);
+	STATUS(HAVE_ZLIB_SUPPORT, zlib);
+	STATUS(HAVE_LZMA_SUPPORT, lzma);
+	STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
+	STATUS(HAVE_LIBBPF_SUPPORT, bpf);
+}
+
+int cmd_version(int argc, const char **argv)
+{
+	argc = parse_options(argc, argv, version_options, version_usage,
+			     PARSE_OPT_STOP_AT_NON_OPTION);
+
 	printf("perf version %s\n", perf_version_string);
+
+	if (version.build_options || version_verbose == 1)
+		library_status();
+
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 5/6] perf: Support perf -vv
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
                   ` (2 preceding siblings ...)
  2018-03-30  9:27 ` [PATCH v4 4/6] perf version: Print the compiled-in status of libraries Jin Yao
@ 2018-03-30  9:27 ` Jin Yao
  2018-04-04  5:32   ` [tip:perf/urgent] perf tools: Add 'perf -vv' as an alias to 'perf version --build-options' tip-bot for Jin Yao
  2018-03-30  9:27 ` [PATCH v4 6/6] perf Documentation: Create perf-version.txt Jin Yao
  2018-03-30  9:34 ` [PATCH v4 0/6] Support perf -vv Jiri Olsa
  5 siblings, 1 reply; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

We keep having bug reports that when users build perf on their own,
but they don't install some needed libraries such as libelf,
libbfd/libibery.

The perf can build, but it is missing important functionality.

This patch provides a new option '-vv' for perf which will
print the compiled-in status of libraries.

The 'perf -vv' is mapped to 'perf version --build-options'.

For example:

$ ./perf -vv

perf version 4.13.rc5.g6727c5
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
              libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
                libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v3:
---
One bug is found in v2. It didn't process the option like '-vabc'
correctly. Fix this bug.

v2:
---
Use a global variable version_verbose to record the number of 'v'.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/perf.c | 6 ++++++
 tools/perf/perf.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1b3fc8e..1659029 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			break;
 		}
 
+		if (!strcmp(cmd, "-vv")) {
+			(*argv)[0] = "version";
+			version_verbose = 1;
+			break;
+		}
+
 		/*
 		 * Check remaining flags.
 		 */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8fec1ab..a1a9795 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -84,6 +84,7 @@ struct record_opts {
 struct option;
 extern const char * const *record_usage;
 extern struct option *record_options;
+extern int version_verbose;
 
 int record__parse_freq(const struct option *opt, const char *str, int unset);
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4 6/6] perf Documentation: Create perf-version.txt
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
                   ` (3 preceding siblings ...)
  2018-03-30  9:27 ` [PATCH v4 5/6] perf: Support perf -vv Jin Yao
@ 2018-03-30  9:27 ` Jin Yao
  2018-04-04  5:32   ` [tip:perf/urgent] perf version: Add man page tip-bot for Jin Yao
  2018-03-30  9:34 ` [PATCH v4 0/6] Support perf -vv Jiri Olsa
  5 siblings, 1 reply; 14+ messages in thread
From: Jin Yao @ 2018-03-30  9:27 UTC (permalink / raw)
  To: acme, jolsa, peterz, mingo, alexander.shishkin
  Cc: Linux-kernel, ak, kan.liang, yao.jin, Jin Yao

Since a new option '--build-options' is created for 'perf version',
so we need to document it.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
 tools/perf/Documentation/perf-version.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 tools/perf/Documentation/perf-version.txt

diff --git a/tools/perf/Documentation/perf-version.txt b/tools/perf/Documentation/perf-version.txt
new file mode 100644
index 0000000..e207b7c
--- /dev/null
+++ b/tools/perf/Documentation/perf-version.txt
@@ -0,0 +1,24 @@
+perf-version(1)
+===============
+
+NAME
+----
+perf-version - display the version of perf binary
+
+SYNOPSIS
+--------
+'perf version' [--build-options]
+
+DESCRIPTION
+-----------
+With no options given, the 'perf version' prints the perf version
+on the standard output.
+
+If the option '--build-options' is given, then the status of
+compiled-in libraries are printed on the standard output.
+
+OPTIONS
+-------
+--build-options::
+        Prints the status of compiled-in libraries on the
+        standard output.
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 0/6] Support perf -vv
  2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
                   ` (4 preceding siblings ...)
  2018-03-30  9:27 ` [PATCH v4 6/6] perf Documentation: Create perf-version.txt Jin Yao
@ 2018-03-30  9:34 ` Jiri Olsa
  5 siblings, 0 replies; 14+ messages in thread
From: Jiri Olsa @ 2018-03-30  9:34 UTC (permalink / raw)
  To: Jin Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

On Fri, Mar 30, 2018 at 05:27:10PM +0800, Jin Yao wrote:
> We keep having bug reports that when users build perf on their own,
> but they don't install some needed libraries such as libelf,
> libbfd/libibery.
> 
> The perf can build, but it is missing important functionality. And
> users may complain that perf has issue or bug.
> 
> This patch-set support to print the status of compiled-in libraries.
> 
> Once users think perf missing some functionality, it should be very
> easy for them to check the libraries status.
> 
> For example:
> 
> $ ./perf version --build-options
>     or
>   ./perf --version --build-options
>     or
>   ./perf -v --build-options
>     or
>   ./perf -vv
> 
> perf version 4.13.rc5.g6727c5
>                  dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
>     dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
>                  glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
>                   gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
>               libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
>                 libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
>                 libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
>                libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
> numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
>                libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
>              libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
>               libslang: [ on  ]  # HAVE_SLANG_SUPPORT
>              libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
>              libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
>     libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
>                   zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
>                   lzma: [ on  ]  # HAVE_LZMA_SUPPORT
>              get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
>                    bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
> 
> v4:
> ---
> 1. Also print the macro name. That would make it easier
>    to grep around in the source looking for where code
>    related a particular features is located.
> 
> 2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
>    HAVE_DWARF_GETLOCATIONS_SUPPORT

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 4/6] perf version: Print the compiled-in status of libraries
  2018-03-30  9:27 ` [PATCH v4 4/6] perf version: Print the compiled-in status of libraries Jin Yao
@ 2018-04-02 16:47   ` Arnaldo Carvalho de Melo
  2018-04-03  1:24     ` Jin, Yao
  2018-04-04  5:31   ` [tip:perf/urgent] " tip-bot for Jin Yao
  1 sibling, 1 reply; 14+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-04-02 16:47 UTC (permalink / raw)
  To: Jin Yao
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

Em Fri, Mar 30, 2018 at 05:27:14PM +0800, Jin Yao escreveu:
> This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
> print the status of libraries.
> 
> For example, if HAVE_DWARF_SUPPORT is defined, that means the
> library "dwarf" is compiled-in. The patch will print the status
> "on" for this library otherwise it print the status "OFF".
> 
> A new option '--build-options' created for 'perf version' supports
> the printing of library status.
> 
> For example:
> 
> $ ./perf version --build-options
>     or
>   ./perf --version --build-options
>     or
>   ./perf -v --build-options
> 
> perf version 4.13.rc5.g6727c5
>                  dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
>     dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
>                  glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
>                   gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
>               libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT

Ok, while testing this I noticed the above, which may be distracting,
i.e. on x86-64 and s/390 not having libaudit means nothing, it is not
needed for anything.

It is only needed for architectures where HAVE_SYSCALL_TABLE is not
defined, that, btw, is not listed here, so I suggest that we stop
printing this "libaudit [ OFF ]" line if HAVE_SYSCALL_TABLE is
available, and also add a line for HAVE_SYSCALL_TABLE.

Anyways, this can be done on top of this series, but please do a grep
looking for other HAVE_* to fix, and we need to rename
HAVE_SYSCALL_TABLE to HAVE_SYSCALL_TABLE_SUPPORT...

- Arnaldo

>                 libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
>                 libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
>                libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
> numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
>                libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
>              libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
>               libslang: [ on  ]  # HAVE_SLANG_SUPPORT
>              libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
>              libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
>     libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
>                   zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
>                   lzma: [ on  ]  # HAVE_LZMA_SUPPORT
>              get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
>                    bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
> 
> v4:
> ---
> 1. Also print the macro name. That would make it easier
>    to grep around in the source looking for where code
>    related a particular features is located.
> 
> 2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
>    HAVE_DWARF_GETLOCATIONS_SUPPORT
> 
> v3:
> ---
> Remove following unnecessary help message.
> 
> 1. [ on  ]: library is compiled-in
>    [ OFF ]: library is disabled in make configuration
>             OR library is not installed in build environment
> 
> 2. Create '--build-options' option.
> 
> 3. Use standard option parsing API 'parse_options'.
> 
> v2:
> ---
> 1. Use IS_BUILTIN macro to replace #ifdef/#endif block.
> 
> 2. Print color for on/OFF.
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  tools/perf/builtin-version.c | 82 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 81 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
> index 37019c5..2abe391 100644
> --- a/tools/perf/builtin-version.c
> +++ b/tools/perf/builtin-version.c
> @@ -1,11 +1,91 @@
>  // SPDX-License-Identifier: GPL-2.0
>  #include "builtin.h"
>  #include "perf.h"
> +#include "color.h"
>  #include <linux/compiler.h>
> +#include <tools/config.h>
>  #include <stdio.h>
> +#include <string.h>
> +#include <subcmd/parse-options.h>
>  
> -int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
> +int version_verbose;
> +
> +struct version {
> +	bool	build_options;
> +};
> +
> +static struct version version;
> +
> +static struct option version_options[] = {
> +	OPT_BOOLEAN(0, "build-options", &version.build_options,
> +		    "display the build options"),
> +};
> +
> +static const char * const version_usage[] = {
> +	"perf version [<options>]",
> +	NULL
> +};
> +
> +static void on_off_print(const char *status)
> +{
> +	printf("[ ");
> +
> +	if (!strcmp(status, "OFF"))
> +		color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
> +	else
> +		color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
> +
> +	printf(" ]");
> +}
> +
> +static void status_print(const char *name, const char *macro,
> +			 const char *status)
>  {
> +	printf("%22s: ", name);
> +	on_off_print(status);
> +	printf("  # %s\n", macro);
> +}
> +
> +#define STATUS(__d, __m)				\
> +do {							\
> +	if (IS_BUILTIN(__d))				\
> +		status_print(#__m, #__d, "on");		\
> +	else						\
> +		status_print(#__m, #__d, "OFF");	\
> +} while (0)
> +
> +static void library_status(void)
> +{
> +	STATUS(HAVE_DWARF_SUPPORT, dwarf);
> +	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
> +	STATUS(HAVE_GLIBC_SUPPORT, glibc);
> +	STATUS(HAVE_GTK2_SUPPORT, gtk2);
> +	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
> +	STATUS(HAVE_LIBBFD_SUPPORT, libbfd);
> +	STATUS(HAVE_LIBELF_SUPPORT, libelf);
> +	STATUS(HAVE_LIBNUMA_SUPPORT, libnuma);
> +	STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus);
> +	STATUS(HAVE_LIBPERL_SUPPORT, libperl);
> +	STATUS(HAVE_LIBPYTHON_SUPPORT, libpython);
> +	STATUS(HAVE_SLANG_SUPPORT, libslang);
> +	STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto);
> +	STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind);
> +	STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind);
> +	STATUS(HAVE_ZLIB_SUPPORT, zlib);
> +	STATUS(HAVE_LZMA_SUPPORT, lzma);
> +	STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
> +	STATUS(HAVE_LIBBPF_SUPPORT, bpf);
> +}
> +
> +int cmd_version(int argc, const char **argv)
> +{
> +	argc = parse_options(argc, argv, version_options, version_usage,
> +			     PARSE_OPT_STOP_AT_NON_OPTION);
> +
>  	printf("perf version %s\n", perf_version_string);
> +
> +	if (version.build_options || version_verbose == 1)
> +		library_status();
> +
>  	return 0;
>  }
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4 4/6] perf version: Print the compiled-in status of libraries
  2018-04-02 16:47   ` Arnaldo Carvalho de Melo
@ 2018-04-03  1:24     ` Jin, Yao
  0 siblings, 0 replies; 14+ messages in thread
From: Jin, Yao @ 2018-04-03  1:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin



On 4/3/2018 12:47 AM, Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 30, 2018 at 05:27:14PM +0800, Jin Yao escreveu:
>> This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
>> print the status of libraries.
>>
>> For example, if HAVE_DWARF_SUPPORT is defined, that means the
>> library "dwarf" is compiled-in. The patch will print the status
>> "on" for this library otherwise it print the status "OFF".
>>
>> A new option '--build-options' created for 'perf version' supports
>> the printing of library status.
>>
>> For example:
>>
>> $ ./perf version --build-options
>>      or
>>    ./perf --version --build-options
>>      or
>>    ./perf -v --build-options
>>
>> perf version 4.13.rc5.g6727c5
>>                   dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
>>      dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
>>                   glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
>>                    gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
>>                libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
> 
> Ok, while testing this I noticed the above, which may be distracting,
> i.e. on x86-64 and s/390 not having libaudit means nothing, it is not
> needed for anything.
> 
> It is only needed for architectures where HAVE_SYSCALL_TABLE is not
> defined, that, btw, is not listed here, so I suggest that we stop
> printing this "libaudit [ OFF ]" line if HAVE_SYSCALL_TABLE is
> available, and also add a line for HAVE_SYSCALL_TABLE.
> 
> Anyways, this can be done on top of this series, but please do a grep
> looking for other HAVE_* to fix, and we need to rename
> HAVE_SYSCALL_TABLE to HAVE_SYSCALL_TABLE_SUPPORT...
> 
> - Arnaldo
> 

Hi Arnaldo,

Thanks for the suggestions. Yes, some follow-up patches are needed.

1. Remove -DNO_LIBPERL and use -DHAVE_LIBPERL_SUPPORT in C code.

2. Remove -DNO_LIBPYTHON and use -DHAVE_LIBPYTHON_SUPPORT in C code.

3. Rename HAVE_SYSCALL_TABLE to HAVE_SYSCALL_TABLE_SUPPORT.

4. Don't print "libaudit [ OFF ]" line if HAVE_SYSCALL_TABLE_SUPPORT is 
available and add a line for HAVE_SYSCALL_TABLE_SUPPORT.

I will do it in follow-up patch.

Thanks
Jin Yao

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [tip:perf/urgent] tools include: Add config.h header file
  2018-03-30  9:27 ` [PATCH v4 1/6] tools include: Add config.h header file Jin Yao
@ 2018-04-04  5:30   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2018-04-04  5:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, alexander.shishkin, jolsa, kan.liang, ak, mingo,
	tglx, acme, yao.jin, peterz, hpa

Commit-ID:  6b416ebcc32c5753214d53c18ac5719c93bc340e
Gitweb:     https://git.kernel.org/tip/6b416ebcc32c5753214d53c18ac5719c93bc340e
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Fri, 30 Mar 2018 17:27:11 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 13:31:38 -0300

tools include: Add config.h header file

Adding IS_BUILTIN macro and its dependencies into tools world.

It's taken from kernel's include/linux/kconfig.h, which can't be taken
completely due to its kconfig dependencies.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1522402036-22915-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/include/tools/config.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/tools/include/tools/config.h b/tools/include/tools/config.h
new file mode 100644
index 000000000000..08ade7df8132
--- /dev/null
+++ b/tools/include/tools/config.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _TOOLS_CONFIG_H
+#define _TOOLS_CONFIG_H
+
+/* Subset of include/linux/kconfig.h */
+
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
+ * Getting something that works in C and CPP for an arg that may or may
+ * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
+ * we match on the placeholder define, insert the "0," for arg1 and generate
+ * the triplet (0, 1, 0).  Then the last step cherry picks the 2nd arg (a one).
+ * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
+ * the last step cherry picks the 2nd arg, we get a zero.
+ */
+#define __is_defined(x)			___is_defined(x)
+#define ___is_defined(val)		____is_defined(__ARG_PLACEHOLDER_##val)
+#define ____is_defined(arg1_or_junk)	__take_second_arg(arg1_or_junk 1, 0)
+
+/*
+ * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
+ * otherwise. For boolean options, this is equivalent to
+ * IS_ENABLED(CONFIG_FOO).
+ */
+#define IS_BUILTIN(option) __is_defined(option)
+
+#endif /* _TOOLS_CONFIG_H */

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/urgent] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT
  2018-03-30  9:27 ` [PATCH v4 3/6] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT Jin Yao
@ 2018-04-04  5:31   ` tip-bot for Jin Yao
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jin Yao @ 2018-04-04  5:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, kan.liang, ak, yao.jin, peterz, jolsa, acme,
	alexander.shishkin, hpa, mingo, yao.jin, linux-kernel

Commit-ID:  a36ebe4e242a2f6818f424b03a5e8dae3964e458
Gitweb:     https://git.kernel.org/tip/a36ebe4e242a2f6818f424b03a5e8dae3964e458
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 30 Mar 2018 17:27:13 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 13:50:24 -0300

perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT

In Makefile.config, to make all libraries flags have _SUPPORT suffix,
rename HAVE_DWARF_GETLOCATIONS to HAVE_DWARF_GETLOCATIONS_SUPPORT

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Suggested-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1522402036-22915-4-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config  | 2 +-
 tools/perf/util/dwarf-aux.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index deb8fba2f4f1..c7abd83a8e19 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -346,7 +346,7 @@ else
       ifneq ($(feature-dwarf_getlocations), 1)
         msg := $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157);
       else
-        CFLAGS += -DHAVE_DWARF_GETLOCATIONS
+        CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT
       endif # dwarf_getlocations
     endif # Dwarf support
   endif # libelf support
diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
index f5acda13dcfa..7eb7de5aee44 100644
--- a/tools/perf/util/dwarf-aux.c
+++ b/tools/perf/util/dwarf-aux.c
@@ -979,7 +979,7 @@ int die_get_varname(Dwarf_Die *vr_die, struct strbuf *buf)
 	return ret < 0 ? ret : strbuf_addf(buf, "\t%s", dwarf_diename(vr_die));
 }
 
-#ifdef HAVE_DWARF_GETLOCATIONS
+#ifdef HAVE_DWARF_GETLOCATIONS_SUPPORT
 /**
  * die_get_var_innermost_scope - Get innermost scope range of given variable DIE
  * @sp_die: a subprogram DIE

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/urgent] perf version: Print the compiled-in status of libraries
  2018-03-30  9:27 ` [PATCH v4 4/6] perf version: Print the compiled-in status of libraries Jin Yao
  2018-04-02 16:47   ` Arnaldo Carvalho de Melo
@ 2018-04-04  5:31   ` tip-bot for Jin Yao
  1 sibling, 0 replies; 14+ messages in thread
From: tip-bot for Jin Yao @ 2018-04-04  5:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, yao.jin, ak, jolsa, hpa, tglx, alexander.shishkin, acme,
	kan.liang, linux-kernel, mingo, yao.jin

Commit-ID:  9ff2a64708a642b3dee867d0a083171077663b0a
Gitweb:     https://git.kernel.org/tip/9ff2a64708a642b3dee867d0a083171077663b0a
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 30 Mar 2018 17:27:14 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 13:50:30 -0300

perf version: Print the compiled-in status of libraries

This patch checks the values passed by CFLAGS (-DHAVE_XXX) and then
print the status of libraries.

For example, if HAVE_DWARF_SUPPORT is defined, that means the library
"dwarf" is compiled-in. The patch will print the status "on" for this
library otherwise it print the status "OFF".

A new option '--build-options' created for 'perf version' supports the
printing of library status.

For example:

$ ./perf version --build-options
    or
  ./perf --version --build-options
    or
  ./perf -v --build-options

perf version 4.13.rc5.g6727c5
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
              libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
                libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v4:

1. Also print the macro name. That would make it easier
   to grep around in the source looking for where code
   related a particular features is located.

2. Update since HAVE_DWARF_GETLOCATIONS is renamed to
   HAVE_DWARF_GETLOCATIONS_SUPPORT

v3:

Remove following unnecessary help message.

1. [ on  ]: library is compiled-in
   [ OFF ]: library is disabled in make configuration
            OR library is not installed in build environment

2. Create '--build-options' option.

3. Use standard option parsing API 'parse_options'.

v2:

1. Use IS_BUILTIN macro to replace #ifdef/#endif block.

2. Print color for on/OFF.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Suggested-by: Ingo Molnar <mingo@kernel.org>
Suggested-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1522402036-22915-5-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-version.c | 82 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 81 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 37019c5d675f..2abe3910d6b6 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -1,11 +1,91 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "builtin.h"
 #include "perf.h"
+#include "color.h"
 #include <linux/compiler.h>
+#include <tools/config.h>
 #include <stdio.h>
+#include <string.h>
+#include <subcmd/parse-options.h>
 
-int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
+int version_verbose;
+
+struct version {
+	bool	build_options;
+};
+
+static struct version version;
+
+static struct option version_options[] = {
+	OPT_BOOLEAN(0, "build-options", &version.build_options,
+		    "display the build options"),
+};
+
+static const char * const version_usage[] = {
+	"perf version [<options>]",
+	NULL
+};
+
+static void on_off_print(const char *status)
+{
+	printf("[ ");
+
+	if (!strcmp(status, "OFF"))
+		color_fprintf(stdout, PERF_COLOR_RED, "%-3s", status);
+	else
+		color_fprintf(stdout, PERF_COLOR_GREEN, "%-3s", status);
+
+	printf(" ]");
+}
+
+static void status_print(const char *name, const char *macro,
+			 const char *status)
 {
+	printf("%22s: ", name);
+	on_off_print(status);
+	printf("  # %s\n", macro);
+}
+
+#define STATUS(__d, __m)				\
+do {							\
+	if (IS_BUILTIN(__d))				\
+		status_print(#__m, #__d, "on");		\
+	else						\
+		status_print(#__m, #__d, "OFF");	\
+} while (0)
+
+static void library_status(void)
+{
+	STATUS(HAVE_DWARF_SUPPORT, dwarf);
+	STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT, dwarf_getlocations);
+	STATUS(HAVE_GLIBC_SUPPORT, glibc);
+	STATUS(HAVE_GTK2_SUPPORT, gtk2);
+	STATUS(HAVE_LIBAUDIT_SUPPORT, libaudit);
+	STATUS(HAVE_LIBBFD_SUPPORT, libbfd);
+	STATUS(HAVE_LIBELF_SUPPORT, libelf);
+	STATUS(HAVE_LIBNUMA_SUPPORT, libnuma);
+	STATUS(HAVE_LIBNUMA_SUPPORT, numa_num_possible_cpus);
+	STATUS(HAVE_LIBPERL_SUPPORT, libperl);
+	STATUS(HAVE_LIBPYTHON_SUPPORT, libpython);
+	STATUS(HAVE_SLANG_SUPPORT, libslang);
+	STATUS(HAVE_LIBCRYPTO_SUPPORT, libcrypto);
+	STATUS(HAVE_LIBUNWIND_SUPPORT, libunwind);
+	STATUS(HAVE_DWARF_SUPPORT, libdw-dwarf-unwind);
+	STATUS(HAVE_ZLIB_SUPPORT, zlib);
+	STATUS(HAVE_LZMA_SUPPORT, lzma);
+	STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
+	STATUS(HAVE_LIBBPF_SUPPORT, bpf);
+}
+
+int cmd_version(int argc, const char **argv)
+{
+	argc = parse_options(argc, argv, version_options, version_usage,
+			     PARSE_OPT_STOP_AT_NON_OPTION);
+
 	printf("perf version %s\n", perf_version_string);
+
+	if (version.build_options || version_verbose == 1)
+		library_status();
+
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/urgent] perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'
  2018-03-30  9:27 ` [PATCH v4 5/6] perf: Support perf -vv Jin Yao
@ 2018-04-04  5:32   ` tip-bot for Jin Yao
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jin Yao @ 2018-04-04  5:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, tglx, peterz, ak, kan.liang, alexander.shishkin, hpa,
	yao.jin, yao.jin, jolsa, mingo, linux-kernel

Commit-ID:  3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Gitweb:     https://git.kernel.org/tip/3aa94b10ab0a818ed9fa2dc06c40812c136f9a5a
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 30 Mar 2018 17:27:15 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 13:50:35 -0300

perf tools: Add 'perf -vv' as an alias to 'perf version --build-options'

We keep having bug reports that when users build perf on their own, but
they don't install some needed libraries such as libelf,
libbfd/libibery.

The perf can build, but it is missing important functionality.

This patch provides a new option '-vv' for perf which will print the
compiled-in status of libraries.

The 'perf -vv' is mapped to 'perf version --build-options'.

For example:

$ ./perf -vv

perf version 4.13.rc5.g6727c5
                 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
    dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
              libaudit: [ OFF ]  # HAVE_LIBAUDIT_SUPPORT
                libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
               libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
               libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
             libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
              libslang: [ on  ]  # HAVE_SLANG_SUPPORT
             libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
             libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
    libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                  zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                  lzma: [ on  ]  # HAVE_LZMA_SUPPORT
             get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                   bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT

v3:

One bug is found in v2. It didn't process the option like '-vabc'
correctly. Fix this bug.

v2:

Use a global variable version_verbose to record the number of 'v'.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1522402036-22915-6-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/perf.c | 6 ++++++
 tools/perf/perf.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1b3fc8ec0fa2..1659029d03fc 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -190,6 +190,12 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			break;
 		}
 
+		if (!strcmp(cmd, "-vv")) {
+			(*argv)[0] = "version";
+			version_verbose = 1;
+			break;
+		}
+
 		/*
 		 * Check remaining flags.
 		 */
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 8fec1abd0f1f..a1a97956136f 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -84,6 +84,7 @@ struct record_opts {
 struct option;
 extern const char * const *record_usage;
 extern struct option *record_options;
+extern int version_verbose;
 
 int record__parse_freq(const struct option *opt, const char *str, int unset);
 #endif

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [tip:perf/urgent] perf version: Add man page
  2018-03-30  9:27 ` [PATCH v4 6/6] perf Documentation: Create perf-version.txt Jin Yao
@ 2018-04-04  5:32   ` tip-bot for Jin Yao
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jin Yao @ 2018-04-04  5:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, acme, yao.jin, linux-kernel, tglx, jolsa, peterz, yao.jin,
	alexander.shishkin, kan.liang, ak, mingo

Commit-ID:  709846725673a944ee38da1c275a6dfbf0576d0f
Gitweb:     https://git.kernel.org/tip/709846725673a944ee38da1c275a6dfbf0576d0f
Author:     Jin Yao <yao.jin@linux.intel.com>
AuthorDate: Fri, 30 Mar 2018 17:27:16 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 2 Apr 2018 13:52:23 -0300

perf version: Add man page

Since a new option '--build-options' is created for 'perf version', so
we need to document it.

Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1522402036-22915-7-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-version.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tools/perf/Documentation/perf-version.txt b/tools/perf/Documentation/perf-version.txt
new file mode 100644
index 000000000000..e207b7cfca26
--- /dev/null
+++ b/tools/perf/Documentation/perf-version.txt
@@ -0,0 +1,24 @@
+perf-version(1)
+===============
+
+NAME
+----
+perf-version - display the version of perf binary
+
+SYNOPSIS
+--------
+'perf version' [--build-options]
+
+DESCRIPTION
+-----------
+With no options given, the 'perf version' prints the perf version
+on the standard output.
+
+If the option '--build-options' is given, then the status of
+compiled-in libraries are printed on the standard output.
+
+OPTIONS
+-------
+--build-options::
+        Prints the status of compiled-in libraries on the
+        standard output.

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-04-04  5:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-30  9:27 [PATCH v4 0/6] Support perf -vv Jin Yao
2018-03-30  9:27 ` [PATCH v4 1/6] tools include: Add config.h header file Jin Yao
2018-04-04  5:30   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-03-30  9:27 ` [PATCH v4 3/6] perf config: Rename to HAVE_DWARF_GETLOCATIONS_SUPPORT Jin Yao
2018-04-04  5:31   ` [tip:perf/urgent] " tip-bot for Jin Yao
2018-03-30  9:27 ` [PATCH v4 4/6] perf version: Print the compiled-in status of libraries Jin Yao
2018-04-02 16:47   ` Arnaldo Carvalho de Melo
2018-04-03  1:24     ` Jin, Yao
2018-04-04  5:31   ` [tip:perf/urgent] " tip-bot for Jin Yao
2018-03-30  9:27 ` [PATCH v4 5/6] perf: Support perf -vv Jin Yao
2018-04-04  5:32   ` [tip:perf/urgent] perf tools: Add 'perf -vv' as an alias to 'perf version --build-options' tip-bot for Jin Yao
2018-03-30  9:27 ` [PATCH v4 6/6] perf Documentation: Create perf-version.txt Jin Yao
2018-04-04  5:32   ` [tip:perf/urgent] perf version: Add man page tip-bot for Jin Yao
2018-03-30  9:34 ` [PATCH v4 0/6] Support perf -vv Jiri Olsa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.