Re: [PATCH v4 01/10] feature: implement libzstd check, LIBZSTD_DIR and NO_LIBZSTD defines

2019-02-28 Thread Alexey Budankov


On 28.02.2019 23:11, Alexey Budankov wrote:
> 
> On 28.02.2019 21:46, Arnaldo Carvalho de Melo wrote:
>> Em Thu, Feb 28, 2019 at 11:59:01AM +0300, Alexey Budankov escreveu:
>>> +++ b/tools/build/Makefile.feature
>>> @@ -66,7 +66,8 @@ FEATURE_TESTS_BASIC :=  \
>>>  sched_getcpu   \
>>>  sdt\
>>>  setns  \
>>> -libaio
>>> +libaio \
>>> +libzstd
>>
>> Since you added this as a basic feature to test, add this when you
>> resubmit, so that 'perf -vv' tells us that this basic feature is indeed
>> present.
> 
> Yes, will do. Actually came to similar idea when 
> observed your test report in pull requests:
> 
> # perf version --build-options
>   perf version 5.0.rc5.gde667c
>dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
>   dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
>glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
> gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
>syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_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
> 
> and it misses HAVE_ZSTD_SUPPORT define.

implemented this:

tools/perf/perf -vv
perf version 4.13.rc5.g20492c
 dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
 glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
  gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
 syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_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
   aio: [ on  ]  # HAVE_AIO_SUPPORT <=
  zstd: [ on  ]  # HAVE_ZSTD_SUPPORT<=

~Alexey

> 
> Thanks,
> Alexey
> 
>>
>>
>> diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
>> index 50df168be326..d41197fc8cef 100644
>> --- a/tools/perf/builtin-version.c
>> +++ b/tools/perf/builtin-version.c
>> @@ -78,6 +78,7 @@ static void library_status(void)
>>  STATUS(HAVE_LZMA_SUPPORT, lzma);
>>  STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
>>  STATUS(HAVE_LIBBPF_SUPPORT, bpf);
>> +STATUS(HAVE_ZSTD_SUPPORT, bpf);
>>  }
>>  
>>  int cmd_version(int argc, const char **argv)
>>
> 


Re: [PATCH v4 01/10] feature: implement libzstd check, LIBZSTD_DIR and NO_LIBZSTD defines

2019-02-28 Thread Alexey Budankov


On 28.02.2019 21:46, Arnaldo Carvalho de Melo wrote:
> Em Thu, Feb 28, 2019 at 11:59:01AM +0300, Alexey Budankov escreveu:
>> +++ b/tools/build/Makefile.feature
>> @@ -66,7 +66,8 @@ FEATURE_TESTS_BASIC :=  \
>>  sched_getcpu\
>>  sdt \
>>  setns   \
>> -libaio
>> +libaio  \
>> +libzstd
> 
> Since you added this as a basic feature to test, add this when you
> resubmit, so that 'perf -vv' tells us that this basic feature is indeed
> present.

Yes, will do. Actually came to similar idea when 
observed your test report in pull requests:

# perf version --build-options
  perf version 5.0.rc5.gde667c
   dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
  dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
   glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
   syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_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

and it misses HAVE_ZSTD_SUPPORT define.

Thanks,
Alexey

> 
> 
> diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
> index 50df168be326..d41197fc8cef 100644
> --- a/tools/perf/builtin-version.c
> +++ b/tools/perf/builtin-version.c
> @@ -78,6 +78,7 @@ static void library_status(void)
>   STATUS(HAVE_LZMA_SUPPORT, lzma);
>   STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
>   STATUS(HAVE_LIBBPF_SUPPORT, bpf);
> + STATUS(HAVE_ZSTD_SUPPORT, bpf);
>  }
>  
>  int cmd_version(int argc, const char **argv)
> 


Re: [PATCH v4 01/10] feature: implement libzstd check, LIBZSTD_DIR and NO_LIBZSTD defines

2019-02-28 Thread Arnaldo Carvalho de Melo
Em Thu, Feb 28, 2019 at 11:59:01AM +0300, Alexey Budankov escreveu:
> +++ b/tools/build/Makefile.feature
> @@ -66,7 +66,8 @@ FEATURE_TESTS_BASIC :=  \
>  sched_getcpu \
>  sdt  \
>  setns\
> -libaio
> +libaio   \
> +libzstd

Since you added this as a basic feature to test, add this when you
resubmit, so that 'perf -vv' tells us that this basic feature is indeed
present.


diff --git a/tools/perf/builtin-version.c b/tools/perf/builtin-version.c
index 50df168be326..d41197fc8cef 100644
--- a/tools/perf/builtin-version.c
+++ b/tools/perf/builtin-version.c
@@ -78,6 +78,7 @@ static void library_status(void)
STATUS(HAVE_LZMA_SUPPORT, lzma);
STATUS(HAVE_AUXTRACE_SUPPORT, get_cpuid);
STATUS(HAVE_LIBBPF_SUPPORT, bpf);
+   STATUS(HAVE_ZSTD_SUPPORT, bpf);
 }
 
 int cmd_version(int argc, const char **argv)


[PATCH v4 01/10] feature: implement libzstd check, LIBZSTD_DIR and NO_LIBZSTD defines

2019-02-28 Thread Alexey Budankov


Implement libzstd feature check, NO_LIBZSTD and LIBZSTD_DIR defines
to override Zstd library sources or disable the feature from the
command line:

  $ make -C tools/perf LIBZSTD_DIR=/path/to/zstd/sources/ clean all
  $ make -C tools/perf NO_LIBZSTD=1 clean all

Auto detection feature status is reported just before compilation starts.
If your system has some version of the zstd library preinstalled then
the build system finds and uses it during the build.

If you still prefer to compile with some other version of zstd library
that is not preinstalled you have capability to refer the compilation
to that version using LIBZSTD_DIR define.

Signed-off-by: Alexey Budankov 
---
 tools/build/Makefile.feature   |  6 --
 tools/build/feature/Makefile   |  6 +-
 tools/build/feature/test-all.c |  5 +
 tools/build/feature/test-libzstd.c | 12 
 tools/perf/Makefile.config | 20 
 tools/perf/Makefile.perf   |  3 +++
 6 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 tools/build/feature/test-libzstd.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 61e46d54a67c..adf791cbd726 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -66,7 +66,8 @@ FEATURE_TESTS_BASIC :=  \
 sched_getcpu   \
 sdt\
 setns  \
-libaio
+libaio \
+libzstd
 
 # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
 # of all feature tests
@@ -118,7 +119,8 @@ FEATURE_DISPLAY ?=  \
  lzma   \
  get_cpuid  \
  bpf   \
- libaio
+ libaio\
+ libzstd
 
 # Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
 # If in the future we need per-feature checks/flags for features not
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 7ceb4441b627..4b8244ee65ce 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -62,7 +62,8 @@ FILES=  \
  test-clang.bin\
  test-llvm.bin \
  test-llvm-version.bin \
- test-libaio.bin
+ test-libaio.bin   \
+ test-libzstd.bin
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
@@ -301,6 +302,9 @@ $(OUTPUT)test-clang.bin:
 $(OUTPUT)test-libaio.bin:
$(BUILD) -lrt
 
+$(OUTPUT)test-libzstd.bin:
+   $(BUILD) -lzstd
+
 ###
 
 clean:
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
index e903b86b742f..b0dda7db2a17 100644
--- a/tools/build/feature/test-all.c
+++ b/tools/build/feature/test-all.c
@@ -178,6 +178,10 @@
 # include "test-reallocarray.c"
 #undef main
 
+#define main main_test_zstd
+# include "test-libzstd.c"
+#undef main
+
 int main(int argc, char *argv[])
 {
main_test_libpython();
@@ -219,6 +223,7 @@ int main(int argc, char *argv[])
main_test_setns();
main_test_libaio();
main_test_reallocarray();
+   main_test_libzstd();
 
return 0;
 }
diff --git a/tools/build/feature/test-libzstd.c 
b/tools/build/feature/test-libzstd.c
new file mode 100644
index ..55268c01b84d
--- /dev/null
+++ b/tools/build/feature/test-libzstd.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
+#include 
+
+int main(void)
+{
+   ZSTD_CStream*cstream;
+
+   cstream = ZSTD_createCStream();
+   ZSTD_freeCStream(cstream);
+
+   return 0;
+}
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 0f11d5891301..4949bdb16a66 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -152,6 +152,13 @@ endif
 FEATURE_CHECK_CFLAGS-libbabeltrace := $(LIBBABELTRACE_CFLAGS)
 FEATURE_CHECK_LDFLAGS-libbabeltrace := $(LIBBABELTRACE_LDFLAGS) 
-lbabeltrace-ctf
 
+ifdef LIBZSTD_DIR
+  LIBZSTD_CFLAGS  := -I$(LIBZSTD_DIR)/lib
+  LIBZSTD_LDFLAGS := -L$(LIBZSTD_DIR)/lib
+endif
+FEATURE_CHECK_CFLAGS-libzstd := $(LIBZSTD_CFLAGS)
+FEATURE_CHECK_LDFLAGS-libzstd := $(LIBZSTD_LDFLAGS)
+
 FEATURE_CHECK_CFLAGS-bpf = -I. -I$(srctree)/tools/include 
-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi -I$(srctree)/tools/include/uapi
 # include ARCH specific config
 -include $(src-perf)/arch/$(SRCARCH)/Makefile
@@ -782,6 +789,19 @@ ifndef NO_LZMA
   endif
 endif
 
+ifndef NO_LIBZSTD
+  ifeq ($(feature-libzstd), 1)
+CFLAGS += -DHAVE_ZSTD_SUPPORT
+CFLAGS += $(LIBZSTD_CFLAGS)
+LDFLAGS += $(LIBZSTD_LDFLAGS)
+EXTLIBS += -lzstd
+$(call detected,CONFIG_ZSTD)
+  else
+msg := $(warning No libzstd found, disables trace compression, please 
install libzstd-dev[el] and/or set LIBZSTD_DIR);
+NO_LIBZSTD := 1
+  endif
+endif
+
 ifndef