All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 3/4] perf version: Print the compiled-in status of libraries
  2018-03-28 14:57 ` [PATCH v2 3/4] perf version: Print the compiled-in status of libraries Jin Yao
@ 2018-03-28 13:10   ` Jiri Olsa
  2018-03-28 13:57     ` Jin, Yao
  0 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2018-03-28 13:10 UTC (permalink / raw)
  To: Jin Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

On Wed, Mar 28, 2018 at 10:57:07PM +0800, Jin Yao wrote:

SNIP

> +
> +static void library_status(void)
> +{
> +	STATUS(HAVE_DWARF_SUPPORT, dwarf);
> +	STATUS(HAVE_DWARF_GETLOCATIONS, 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);
> +
> +	on_off_print("on");
> +	printf(": library is compiled-in\n");
> +
> +	on_off_print("OFF");
> +	printf(": library is disabled in make configuration\n");
> +	printf("         OR library is not installed in build environment\n");

[jolsa@krava perf]$ ./perf -vv
perf version 4.16.rc6.gcc183d
                 dwarf: [ on  ]
    dwarf_getlocations: [ on  ]
                 glibc: [ on  ]
                  gtk2: [ on  ]
              libaudit: [ OFF ]
                libbfd: [ on  ]
                libelf: [ on  ]
               libnuma: [ on  ]
numa_num_possible_cpus: [ on  ]
               libperl: [ on  ]
             libpython: [ on  ]
              libslang: [ on  ]
             libcrypto: [ on  ]
             libunwind: [ on  ]
    libdw-dwarf-unwind: [ on  ]
                  zlib: [ on  ]
                  lzma: [ on  ]
             get_cpuid: [ on  ]
                   bpf: [ on  ]
[ on  ]: library is compiled-in
[ OFF ]: library is disabled in make configuration
         OR library is not installed in build environment

did anyone asked for this ^^^ help messages? I don't think they are necessary

jirka

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

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 14:57 ` [PATCH v2 4/4] perf: Support perf -vv Jin Yao
@ 2018-03-28 13:22   ` Jiri Olsa
  2018-03-28 14:00     ` Jin, Yao
  2018-03-28 15:46   ` Ingo Molnar
  1 sibling, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2018-03-28 13:22 UTC (permalink / raw)
  To: Jin Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

On Wed, Mar 28, 2018 at 10:57:08PM +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.
> 
> This patch provides a new option '-vv' which will print the
> compiled-in status of libraries.
> 
> The 'perf -vv' is equal to 'perf -version --build-options'.
> 
> For example:
> 
> $ ./perf -vv or ./perf -version --build-options
> perf version 4.13.rc5.gcb1183
>                  dwarf: [ on  ]
>     dwarf_getlocations: [ on  ]
>                  glibc: [ on  ]
>                   gtk2: [ on  ]
>               libaudit: [ OFF ]
>                 libbfd: [ on  ]
>                 libelf: [ on  ]
>                libnuma: [ on  ]
> numa_num_possible_cpus: [ on  ]
>                libperl: [ on  ]
>              libpython: [ on  ]
>               libslang: [ on  ]
>              libcrypto: [ on  ]
>              libunwind: [ on  ]
>     libdw-dwarf-unwind: [ on  ]
>                   zlib: [ on  ]
>                   lzma: [ on  ]
>              get_cpuid: [ on  ]
>                    bpf: [ on  ]
> [ on  ]: library is compiled-in
> [ OFF ]: library is disabled in make configuration
>          OR library is not installed in build environment
> 
> v2:
> ---
> Use a global variable version_verbose to count the number of 'v'.
> 
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
>  tools/perf/perf.c | 22 ++++++++++++++++++----
>  tools/perf/perf.h |  1 +
>  2 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> index 1b3fc8e..355219e 100644
> --- a/tools/perf/perf.c
> +++ b/tools/perf/perf.c
> @@ -32,7 +32,7 @@
>  #include <linux/kernel.h>
>  
>  const char perf_usage_string[] =
> -	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
> +	"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";

--build-options is 'perf version' option no?

jirka

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

* Re: [PATCH v2 3/4] perf version: Print the compiled-in status of libraries
  2018-03-28 13:10   ` Jiri Olsa
@ 2018-03-28 13:57     ` Jin, Yao
  0 siblings, 0 replies; 12+ messages in thread
From: Jin, Yao @ 2018-03-28 13:57 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin



On 3/28/2018 9:10 PM, Jiri Olsa wrote:
> On Wed, Mar 28, 2018 at 10:57:07PM +0800, Jin Yao wrote:
> 
> SNIP
> 
>> +
>> +static void library_status(void)
>> +{
>> +	STATUS(HAVE_DWARF_SUPPORT, dwarf);
>> +	STATUS(HAVE_DWARF_GETLOCATIONS, 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);
>> +
>> +	on_off_print("on");
>> +	printf(": library is compiled-in\n");
>> +
>> +	on_off_print("OFF");
>> +	printf(": library is disabled in make configuration\n");
>> +	printf("         OR library is not installed in build environment\n");
> 
> [jolsa@krava perf]$ ./perf -vv
> perf version 4.16.rc6.gcc183d
>                   dwarf: [ on  ]
>      dwarf_getlocations: [ on  ]
>                   glibc: [ on  ]
>                    gtk2: [ on  ]
>                libaudit: [ OFF ]
>                  libbfd: [ on  ]
>                  libelf: [ on  ]
>                 libnuma: [ on  ]
> numa_num_possible_cpus: [ on  ]
>                 libperl: [ on  ]
>               libpython: [ on  ]
>                libslang: [ on  ]
>               libcrypto: [ on  ]
>               libunwind: [ on  ]
>      libdw-dwarf-unwind: [ on  ]
>                    zlib: [ on  ]
>                    lzma: [ on  ]
>               get_cpuid: [ on  ]
>                     bpf: [ on  ]
> [ on  ]: library is compiled-in
> [ OFF ]: library is disabled in make configuration
>           OR library is not installed in build environment
> 
> did anyone asked for this ^^^ help messages? I don't think they are necessary
> 
> jirka
> 

No one ask for this. Since it's not very necessary, I will remove this 
message.

Thanks
Jin Yao

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

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 13:22   ` Jiri Olsa
@ 2018-03-28 14:00     ` Jin, Yao
  2018-03-28 14:19       ` Jiri Olsa
  0 siblings, 1 reply; 12+ messages in thread
From: Jin, Yao @ 2018-03-28 14:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin



On 3/28/2018 9:22 PM, Jiri Olsa wrote:
> On Wed, Mar 28, 2018 at 10:57:08PM +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.
>>
>> This patch provides a new option '-vv' which will print the
>> compiled-in status of libraries.
>>
>> The 'perf -vv' is equal to 'perf -version --build-options'.
>>
>> For example:
>>
>> $ ./perf -vv or ./perf -version --build-options
>> perf version 4.13.rc5.gcb1183
>>                   dwarf: [ on  ]
>>      dwarf_getlocations: [ on  ]
>>                   glibc: [ on  ]
>>                    gtk2: [ on  ]
>>                libaudit: [ OFF ]
>>                  libbfd: [ on  ]
>>                  libelf: [ on  ]
>>                 libnuma: [ on  ]
>> numa_num_possible_cpus: [ on  ]
>>                 libperl: [ on  ]
>>               libpython: [ on  ]
>>                libslang: [ on  ]
>>               libcrypto: [ on  ]
>>               libunwind: [ on  ]
>>      libdw-dwarf-unwind: [ on  ]
>>                    zlib: [ on  ]
>>                    lzma: [ on  ]
>>               get_cpuid: [ on  ]
>>                     bpf: [ on  ]
>> [ on  ]: library is compiled-in
>> [ OFF ]: library is disabled in make configuration
>>           OR library is not installed in build environment
>>
>> v2:
>> ---
>> Use a global variable version_verbose to count the number of 'v'.
>>
>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>> ---
>>   tools/perf/perf.c | 22 ++++++++++++++++++----
>>   tools/perf/perf.h |  1 +
>>   2 files changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
>> index 1b3fc8e..355219e 100644
>> --- a/tools/perf/perf.c
>> +++ b/tools/perf/perf.c
>> @@ -32,7 +32,7 @@
>>   #include <linux/kernel.h>
>>   
>>   const char perf_usage_string[] =
>> -	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
>> +	"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";
> 
> --build-options is 'perf version' option no?
> 
> jirka
> 

Yes. Command-line something like:

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

Is this usage string not correct? If so, I'd like to fix that.

"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";

Thanks
Jin Yao

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

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 14:00     ` Jin, Yao
@ 2018-03-28 14:19       ` Jiri Olsa
  2018-03-28 14:56         ` Jin, Yao
  0 siblings, 1 reply; 12+ messages in thread
From: Jiri Olsa @ 2018-03-28 14:19 UTC (permalink / raw)
  To: Jin, Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin

On Wed, Mar 28, 2018 at 10:00:32PM +0800, Jin, Yao wrote:
> 
> 
> On 3/28/2018 9:22 PM, Jiri Olsa wrote:
> > On Wed, Mar 28, 2018 at 10:57:08PM +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.
> > > 
> > > This patch provides a new option '-vv' which will print the
> > > compiled-in status of libraries.
> > > 
> > > The 'perf -vv' is equal to 'perf -version --build-options'.
> > > 
> > > For example:
> > > 
> > > $ ./perf -vv or ./perf -version --build-options
> > > perf version 4.13.rc5.gcb1183
> > >                   dwarf: [ on  ]
> > >      dwarf_getlocations: [ on  ]
> > >                   glibc: [ on  ]
> > >                    gtk2: [ on  ]
> > >                libaudit: [ OFF ]
> > >                  libbfd: [ on  ]
> > >                  libelf: [ on  ]
> > >                 libnuma: [ on  ]
> > > numa_num_possible_cpus: [ on  ]
> > >                 libperl: [ on  ]
> > >               libpython: [ on  ]
> > >                libslang: [ on  ]
> > >               libcrypto: [ on  ]
> > >               libunwind: [ on  ]
> > >      libdw-dwarf-unwind: [ on  ]
> > >                    zlib: [ on  ]
> > >                    lzma: [ on  ]
> > >               get_cpuid: [ on  ]
> > >                     bpf: [ on  ]
> > > [ on  ]: library is compiled-in
> > > [ OFF ]: library is disabled in make configuration
> > >           OR library is not installed in build environment
> > > 
> > > v2:
> > > ---
> > > Use a global variable version_verbose to count the number of 'v'.
> > > 
> > > Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> > > ---
> > >   tools/perf/perf.c | 22 ++++++++++++++++++----
> > >   tools/perf/perf.h |  1 +
> > >   2 files changed, 19 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/tools/perf/perf.c b/tools/perf/perf.c
> > > index 1b3fc8e..355219e 100644
> > > --- a/tools/perf/perf.c
> > > +++ b/tools/perf/perf.c
> > > @@ -32,7 +32,7 @@
> > >   #include <linux/kernel.h>
> > >   const char perf_usage_string[] =
> > > -	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
> > > +	"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";
> > 
> > --build-options is 'perf version' option no?
> > 
> > jirka
> > 
> 
> Yes. Command-line something like:
> 
> perf --version --build-options or perf -v --build-options.
> 
> Is this usage string not correct? If so, I'd like to fix that.
> 
> "perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";

ah I forgot that --version is in fact 'perf version'
now I see --build-options depends on --version.. ok ;-)

could you please also create Documentation/perf-version.txt,
now when it has option, we should document it

also please use the standard option parsing API we use in commands:

        argc = parse_options(argc, argv, record_options, record_usage,
                            PARSE_OPT_STOP_AT_NON_OPTION);

so we get standard error when the option is mangled,
unlinke now, when it's silent:

	[jolsa@krava perf]$ ./perf --version --buil
	perf version 4.16.rc6.gcc183d

thanks,
jirka

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

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 14:19       ` Jiri Olsa
@ 2018-03-28 14:56         ` Jin, Yao
  0 siblings, 0 replies; 12+ messages in thread
From: Jin, Yao @ 2018-03-28 14:56 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin



On 3/28/2018 10:19 PM, Jiri Olsa wrote:
> On Wed, Mar 28, 2018 at 10:00:32PM +0800, Jin, Yao wrote:
>>
>>
>> On 3/28/2018 9:22 PM, Jiri Olsa wrote:
>>> On Wed, Mar 28, 2018 at 10:57:08PM +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.
>>>>
>>>> This patch provides a new option '-vv' which will print the
>>>> compiled-in status of libraries.
>>>>
>>>> The 'perf -vv' is equal to 'perf -version --build-options'.
>>>>
>>>> For example:
>>>>
>>>> $ ./perf -vv or ./perf -version --build-options
>>>> perf version 4.13.rc5.gcb1183
>>>>                    dwarf: [ on  ]
>>>>       dwarf_getlocations: [ on  ]
>>>>                    glibc: [ on  ]
>>>>                     gtk2: [ on  ]
>>>>                 libaudit: [ OFF ]
>>>>                   libbfd: [ on  ]
>>>>                   libelf: [ on  ]
>>>>                  libnuma: [ on  ]
>>>> numa_num_possible_cpus: [ on  ]
>>>>                  libperl: [ on  ]
>>>>                libpython: [ on  ]
>>>>                 libslang: [ on  ]
>>>>                libcrypto: [ on  ]
>>>>                libunwind: [ on  ]
>>>>       libdw-dwarf-unwind: [ on  ]
>>>>                     zlib: [ on  ]
>>>>                     lzma: [ on  ]
>>>>                get_cpuid: [ on  ]
>>>>                      bpf: [ on  ]
>>>> [ on  ]: library is compiled-in
>>>> [ OFF ]: library is disabled in make configuration
>>>>            OR library is not installed in build environment
>>>>
>>>> v2:
>>>> ---
>>>> Use a global variable version_verbose to count the number of 'v'.
>>>>
>>>> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
>>>> ---
>>>>    tools/perf/perf.c | 22 ++++++++++++++++++----
>>>>    tools/perf/perf.h |  1 +
>>>>    2 files changed, 19 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/tools/perf/perf.c b/tools/perf/perf.c
>>>> index 1b3fc8e..355219e 100644
>>>> --- a/tools/perf/perf.c
>>>> +++ b/tools/perf/perf.c
>>>> @@ -32,7 +32,7 @@
>>>>    #include <linux/kernel.h>
>>>>    const char perf_usage_string[] =
>>>> -	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
>>>> +	"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";
>>>
>>> --build-options is 'perf version' option no?
>>>
>>> jirka
>>>
>>
>> Yes. Command-line something like:
>>
>> perf --version --build-options or perf -v --build-options.
>>
>> Is this usage string not correct? If so, I'd like to fix that.
>>
>> "perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";
> 
> ah I forgot that --version is in fact 'perf version'
> now I see --build-options depends on --version.. ok ;-)
> 
> could you please also create Documentation/perf-version.txt,
> now when it has option, we should document it
> 

That's fine. I will create the perf-version.txt.

> also please use the standard option parsing API we use in commands:
> 
>          argc = parse_options(argc, argv, record_options, record_usage,
>                              PARSE_OPT_STOP_AT_NON_OPTION);
> 
> so we get standard error when the option is mangled,
> unlinke now, when it's silent:
> 
> 	[jolsa@krava perf]$ ./perf --version --buil
> 	perf version 4.16.rc6.gcc183d
> 
> thanks,
> jirka
> 

Oh, yes. Let me check and update the code. Thanks so much for reminding 
this.

Thanks
Jin Yao

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

* [PATCH v2 0/4] Support perf -vv
@ 2018-03-28 14:57 Jin Yao
  2018-03-28 14:57 ` [PATCH v2 1/4] tools include: Add config.h header file Jin Yao
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Jin Yao @ 2018-03-28 14:57 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 'perf -vv' and 'perf -version --build-options'
which will print the compiled-in status of libraries.

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

For example:

    $ ./perf -vv or ./perf -version --build-options
    perf version 4.13.rc5.gcb1183
                     dwarf: [ on  ]
        dwarf_getlocations: [ on  ]
                     glibc: [ on  ]
                      gtk2: [ on  ]
                  libaudit: [ OFF ]
                    libbfd: [ on  ]
                    libelf: [ on  ]
                   libnuma: [ on  ]
    numa_num_possible_cpus: [ on  ]
                   libperl: [ on  ]
                 libpython: [ on  ]
                  libslang: [ on  ]
                 libcrypto: [ on  ]
                 libunwind: [ on  ]
        libdw-dwarf-unwind: [ on  ]
                      zlib: [ on  ]
                      lzma: [ on  ]
                 get_cpuid: [ on  ]
                       bpf: [ on  ]
    [ on  ]: library is compiled-in
    [ OFF ]: library is disabled in make configuration
             OR library is not installed in build environment

Jin Yao (3):
  perf config: Add some new -DHAVE_XXX to CFLAGS
  perf version: Print the compiled-in status of libraries
  perf: Support perf -vv

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

 tools/include/tools/config.h | 34 ++++++++++++++++++++++
 tools/perf/Makefile.config   | 16 +++++++++++
 tools/perf/builtin-version.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/perf.c            | 22 +++++++++++---
 tools/perf/perf.h            |  1 +
 5 files changed, 137 insertions(+), 4 deletions(-)
 create mode 100644 tools/include/tools/config.h

-- 
2.7.4

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

* [PATCH v2 1/4] tools include: Add config.h header file
  2018-03-28 14:57 [PATCH v2 0/4] Support perf -vv Jin Yao
@ 2018-03-28 14:57 ` Jin Yao
  2018-03-28 14:57 ` [PATCH v2 3/4] perf version: Print the compiled-in status of libraries Jin Yao
  2018-03-28 14:57 ` [PATCH v2 4/4] perf: Support perf -vv Jin Yao
  2 siblings, 0 replies; 12+ messages in thread
From: Jin Yao @ 2018-03-28 14:57 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] 12+ messages in thread

* [PATCH v2 3/4] perf version: Print the compiled-in status of libraries
  2018-03-28 14:57 [PATCH v2 0/4] Support perf -vv Jin Yao
  2018-03-28 14:57 ` [PATCH v2 1/4] tools include: Add config.h header file Jin Yao
@ 2018-03-28 14:57 ` Jin Yao
  2018-03-28 13:10   ` Jiri Olsa
  2018-03-28 14:57 ` [PATCH v2 4/4] perf: Support perf -vv Jin Yao
  2 siblings, 1 reply; 12+ messages in thread
From: Jin Yao @ 2018-03-28 14:57 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 print the status "OFF".

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 | 68 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 37019c5..6e2e486 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -1,11 +1,79 @@
 // 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>
+
+int version_verbose;
+
+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 *status)
+{
+	printf("%22s: ", name);
+	on_off_print(status);
+	printf("\n");
+}
+
+#define STATUS(__d, __m)			\
+do {						\
+	if (IS_BUILTIN(__d))			\
+		status_print(#__m, "on");	\
+	else					\
+		status_print(#__m, "OFF");	\
+} while (0)
+
+static void library_status(void)
+{
+	STATUS(HAVE_DWARF_SUPPORT, dwarf);
+	STATUS(HAVE_DWARF_GETLOCATIONS, 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);
+
+	on_off_print("on");
+	printf(": library is compiled-in\n");
+
+	on_off_print("OFF");
+	printf(": library is disabled in make configuration\n");
+	printf("         OR library is not installed in build environment\n");
+}
 
 int cmd_version(int argc __maybe_unused, const char **argv __maybe_unused)
 {
 	printf("perf version %s\n", perf_version_string);
+
+	if ((argc > 1 && !strcmp(argv[1], "--build-options")) ||
+	    (version_verbose == 1)) {
+		library_status();
+	}
+
 	return 0;
 }
-- 
2.7.4

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

* [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 14:57 [PATCH v2 0/4] Support perf -vv Jin Yao
  2018-03-28 14:57 ` [PATCH v2 1/4] tools include: Add config.h header file Jin Yao
  2018-03-28 14:57 ` [PATCH v2 3/4] perf version: Print the compiled-in status of libraries Jin Yao
@ 2018-03-28 14:57 ` Jin Yao
  2018-03-28 13:22   ` Jiri Olsa
  2018-03-28 15:46   ` Ingo Molnar
  2 siblings, 2 replies; 12+ messages in thread
From: Jin Yao @ 2018-03-28 14:57 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' which will print the
compiled-in status of libraries.

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

For example:

$ ./perf -vv or ./perf -version --build-options
perf version 4.13.rc5.gcb1183
                 dwarf: [ on  ]
    dwarf_getlocations: [ on  ]
                 glibc: [ on  ]
                  gtk2: [ on  ]
              libaudit: [ OFF ]
                libbfd: [ on  ]
                libelf: [ on  ]
               libnuma: [ on  ]
numa_num_possible_cpus: [ on  ]
               libperl: [ on  ]
             libpython: [ on  ]
              libslang: [ on  ]
             libcrypto: [ on  ]
             libunwind: [ on  ]
    libdw-dwarf-unwind: [ on  ]
                  zlib: [ on  ]
                  lzma: [ on  ]
             get_cpuid: [ on  ]
                   bpf: [ on  ]
[ on  ]: library is compiled-in
[ OFF ]: library is disabled in make configuration
         OR library is not installed in build environment

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

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

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 1b3fc8e..355219e 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -32,7 +32,7 @@
 #include <linux/kernel.h>
 
 const char perf_usage_string[] =
-	"perf [--version] [--help] [OPTIONS] COMMAND [ARGS]";
+	"perf [--version [--build-options]] [--help] [OPTIONS] COMMAND [ARGS]";
 
 const char perf_more_info_string[] =
 	"See 'perf help COMMAND' for more information on a specific command.";
@@ -163,6 +163,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 {
 	int handled = 0;
 
+	version_verbose = 0;
+
 	while (*argc > 0) {
 		const char *cmd = (*argv)[0];
 		if (cmd[0] != '-')
@@ -185,9 +187,21 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			break;
 		}
 
-		if (!strcmp(cmd, "-v")) {
-			(*argv)[0] = "--version";
-			break;
+		if (strstarts(cmd, "-v")) {
+			int i;
+
+			for (i = 2; cmd[i]; i++) {
+				if (cmd[i] == 'v')
+					version_verbose++;
+			}
+
+			/*
+			 * Only support -v and -vv now
+			 */
+			if (version_verbose < 2) {
+				(*argv)[0] = "--version";
+				break;
+			}
 		}
 
 		/*
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] 12+ messages in thread

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 14:57 ` [PATCH v2 4/4] perf: Support perf -vv Jin Yao
  2018-03-28 13:22   ` Jiri Olsa
@ 2018-03-28 15:46   ` Ingo Molnar
  2018-03-29  0:52     ` Jin, Yao
  1 sibling, 1 reply; 12+ messages in thread
From: Ingo Molnar @ 2018-03-28 15:46 UTC (permalink / raw)
  To: Jin Yao
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin


* Jin Yao <yao.jin@linux.intel.com> wrote:

> $ ./perf -vv or ./perf -version --build-options
> perf version 4.13.rc5.gcb1183

My suggestion was to add the 'version' subcommand like Git has, not a "-version" 
option:

  $ git version
  git version 2.14.1

Thanks,

	Ingo

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

* Re: [PATCH v2 4/4] perf: Support perf -vv
  2018-03-28 15:46   ` Ingo Molnar
@ 2018-03-29  0:52     ` Jin, Yao
  0 siblings, 0 replies; 12+ messages in thread
From: Jin, Yao @ 2018-03-29  0:52 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: acme, jolsa, peterz, mingo, alexander.shishkin, Linux-kernel, ak,
	kan.liang, yao.jin



On 3/28/2018 11:46 PM, Ingo Molnar wrote:
> 
> * Jin Yao <yao.jin@linux.intel.com> wrote:
> 
>> $ ./perf -vv or ./perf -version --build-options
>> perf version 4.13.rc5.gcb1183
> 
> My suggestion was to add the 'version' subcommand like Git has, not a "-version"
> option:
> 
>    $ git version
>    git version 2.14.1
> 
> Thanks,
> 
> 	Ingo
> 

Hi Ingo,

Sorry about that. Actually I find it's a bug in my patch. The 'perf 
-vxyz' is mapped to 'perf --version' mistakenly. So 'perf -version' will 
be mapped to 'perf --version' and 'perf -vabc' will be mapped too.

I will fix this bug.

Currently, 'perf -v', 'perf version' and 'perf --version' have the same 
behavior.

So I will let:
'perf -v --build-options',
'perf version --build-options',
'perf --version --build-options',
'perf -vv'
have same output.

For example,

$ ./perf version --build-options
perf version 4.13.rc5.gcb1183
                  dwarf: [ on  ]
     dwarf_getlocations: [ on  ]
                  glibc: [ on  ]
                   gtk2: [ on  ]
               libaudit: [ OFF ]
                 libbfd: [ on  ]
                 libelf: [ on  ]
                libnuma: [ on  ]
numa_num_possible_cpus: [ on  ]
                libperl: [ on  ]
              libpython: [ on  ]
               libslang: [ on  ]
              libcrypto: [ on  ]
              libunwind: [ on  ]
     libdw-dwarf-unwind: [ on  ]
                   zlib: [ on  ]
                   lzma: [ on  ]
              get_cpuid: [ on  ]
                    bpf: [ on  ]

Thanks
Jin Yao

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

end of thread, other threads:[~2018-03-29  0:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 14:57 [PATCH v2 0/4] Support perf -vv Jin Yao
2018-03-28 14:57 ` [PATCH v2 1/4] tools include: Add config.h header file Jin Yao
2018-03-28 14:57 ` [PATCH v2 3/4] perf version: Print the compiled-in status of libraries Jin Yao
2018-03-28 13:10   ` Jiri Olsa
2018-03-28 13:57     ` Jin, Yao
2018-03-28 14:57 ` [PATCH v2 4/4] perf: Support perf -vv Jin Yao
2018-03-28 13:22   ` Jiri Olsa
2018-03-28 14:00     ` Jin, Yao
2018-03-28 14:19       ` Jiri Olsa
2018-03-28 14:56         ` Jin, Yao
2018-03-28 15:46   ` Ingo Molnar
2018-03-29  0:52     ` Jin, Yao

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.