commit lttng-ust for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lttng-ust for openSUSE:Factory checked in at 2022-08-30 14:48:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lttng-ust (Old) and /work/SRC/openSUSE:Factory/.lttng-ust.new.2083 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "lttng-ust" Tue Aug 30 14:48:40 2022 rev:12 rq:1000074 version:2.13.4 Changes: -------- --- /work/SRC/openSUSE:Factory/lttng-ust/lttng-ust.changes 2022-08-22 11:04:46.641654911 +0200 +++ /work/SRC/openSUSE:Factory/.lttng-ust.new.2083/lttng-ust.changes 2022-08-30 14:48:51.168024399 +0200 @@ -1,0 +2,8 @@ +Mon Aug 29 10:24:41 UTC 2022 - Jan Engelhardt <jengelh@inai.de> + +- Update to release 2.13.4 + * Added missing closedir in _get_max_cpuid_from_sysfs() + * File descriptor was leaked in get_possible_cpu_mask_from_sysfs + * sessiond wait futex: handle spurious futex wakeups + +------------------------------------------------------------------- Old: ---- lttng-ust-2.13.3.tar.bz2 lttng-ust-2.13.3.tar.bz2.asc New: ---- lttng-ust-2.13.4.tar.bz2 lttng-ust-2.13.4.tar.bz2.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lttng-ust.spec ++++++ --- /var/tmp/diff_new_pack.ME6HzL/_old 2022-08-30 14:48:51.764025920 +0200 +++ /var/tmp/diff_new_pack.ME6HzL/_new 2022-08-30 14:48:51.768025930 +0200 @@ -19,7 +19,7 @@ %define sover 1 %define sover_ctl 5 Name: lttng-ust -Version: 2.13.3 +Version: 2.13.4 Release: 0 Summary: Linux Trace Toolkit Userspace Tracer library License: GPL-2.0-only @@ -75,7 +75,7 @@ This package provides the LLTng-UST Python 3 agent. -%package -n %{name}-devel +%package devel Summary: Linux Trace Toolkit Userspace Tracer library Group: Development/Languages/C and C++ Requires: liblttng-ust%{sover} = %{version} @@ -86,11 +86,11 @@ Provides: %{name} = %{version} Obsoletes: %{name} < %{version} -%description -n %{name}-devel +%description devel This library provides support for developing programs using LTTng userspace tracing. -%package -n %{name}-doc +%package doc Summary: Linux Trace Toolkit Userspace Tracer Documentation Group: Documentation/Other Requires: liblttng-ust%{sover} = %{version} @@ -99,6 +99,7 @@ # lttng-ust-docs was last used in openSUSE Leap 42.3. Provides: %{name}-docs = %{version} Obsoletes: %{name}-docs < %{version} +BuildArch: noarch %description -n %{name}-doc This package includes documentation and examples for developing @@ -158,14 +159,14 @@ %{python3_sitelib}/lttngust/ %{python3_sitelib}/lttngust-* -%files -n %{name}-devel +%files devel %{_includedir}/lttng/ %{_bindir}/lttng-gen-tp %{_mandir}/man1/lttng-gen-tp.1%{?ext_man} %{_libdir}/liblttng-ust*.so %{_libdir}/pkgconfig/lttng-ust*.pc -%files -n %{name}-doc +%files doc %doc %{_docdir}/%{name}/ %{_mandir}/man3/lttng-ust.3%{?ext_man} %{_mandir}/man3/lttng-ust-cyg-profile.3%{?ext_man} ++++++ lttng-ust-2.13.3.tar.bz2 -> lttng-ust-2.13.4.tar.bz2 ++++++ ++++ 2246 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/ChangeLog new/lttng-ust-2.13.4/ChangeLog --- old/lttng-ust-2.13.3/ChangeLog 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/ChangeLog 2022-08-19 22:23:41.000000000 +0200 @@ -1,3 +1,19 @@ +2022-08-19 (National Popato Day) lttng-ust 2.13.4 + * cleanup: remove stale comment + * Fix: disable array/sequence compile-time type check in C + * fix: add missing closedir in _get_max_cpuid_from_sysfs() + * Add more unit tests for possible_cpus_array_len + * Clarify terminology around cpu ids and array length + * fix: Unify possible CPU number fallback + * fix: removed accidental VLA in _get_num_possible_cpus() + * Fix: file descriptor leak in get_possible_cpu_mask_from_sysfs + * Add unit tests for num possible cpus + * fix: num_possible_cpus() with hot-unplugged CPUs + * fix: Disable warnings for GNU extensions on Clang + * fix: clang warning '-Wnull-pointer-subtraction' in lttng_ust_is_pointer_type + * Fix: Use negative value for error code of lttng_ust_ctl_duplicate_ust_object_data + * Fix: sessiond wait futex: handle spurious futex wakeups + 2022-06-03 (National Repeat Day) (National Repeat Day) lttng-ust 2.13.3 * Document ust lock async-signal-safety * Fix: don't use strerror() from ust lock nocheck diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/configure.ac new/lttng-ust-2.13.4/configure.ac --- old/lttng-ust-2.13.3/configure.ac 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/configure.ac 2022-08-19 22:23:47.000000000 +0200 @@ -8,7 +8,7 @@ # Project version information m4_define([ust_version_major], [2]) m4_define([ust_version_minor], [13]) -m4_define([ust_version_patch], [3]) +m4_define([ust_version_patch], [4]) m4_define([ust_version_dev_stage], []) m4_define([ust_version], ust_version_major[.]ust_version_minor[.]ust_version_patch[]ust_version_dev_stage) m4_define([ust_version_name], [[Nordicit��]]) @@ -162,6 +162,7 @@ -Wno-sign-compare dnl -Wno-missing-field-initializers dnl -Wno-null-dereference dnl + -Wno-gnu dnl Disable warnings for GNU extensions on Clang ]) # Pass -Werror as an extra flag during the test: this is needed to make the @@ -656,6 +657,7 @@ tests/regression/abi0-conflict/Makefile tests/regression/Makefile tests/unit/gcc-weak-hidden/Makefile + tests/unit/libcommon/Makefile tests/unit/libmsgpack/Makefile tests/unit/libringbuffer/Makefile tests/unit/Makefile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng-gen-tp.1 new/lttng-ust-2.13.4/doc/man/lttng-gen-tp.1 --- old/lttng-ust-2.13.3/doc/man/lttng-gen-tp.1 2022-06-03 21:59:12.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng-gen-tp.1 2022-08-19 22:24:57.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng-gen-tp .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG\-GEN\-TP" "1" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG\-GEN\-TP" "1" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng-ust-cyg-profile.3 new/lttng-ust-2.13.4/doc/man/lttng-ust-cyg-profile.3 --- old/lttng-ust-2.13.3/doc/man/lttng-ust-cyg-profile.3 2022-06-03 21:59:15.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng-ust-cyg-profile.3 2022-08-19 22:25:01.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng-ust-cyg-profile .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG\-UST\-CYG\-PRO" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG\-UST\-CYG\-PRO" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng-ust-dl.3 new/lttng-ust-2.13.4/doc/man/lttng-ust-dl.3 --- old/lttng-ust-2.13.3/doc/man/lttng-ust-dl.3 2022-06-03 21:59:14.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng-ust-dl.3 2022-08-19 22:25:00.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng-ust-dl .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG\-UST\-DL" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG\-UST\-DL" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng-ust.3 new/lttng-ust-2.13.4/doc/man/lttng-ust.3 --- old/lttng-ust-2.13.3/doc/man/lttng-ust.3 2022-06-03 21:59:14.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng-ust.3 2022-08-19 22:24:59.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng-ust .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG\-UST" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG\-UST" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -211,7 +211,7 @@ API version\ \&\fIN\fR, and all the following existing APIs, are available\&. Previous APIs are not available (not compiled)\&. .RE .sp -The following table shows the mapping from LTTng\-UST versions (up to LTTng\-UST\ \&2\&.13\&.3) to available API versions: +The following table shows the mapping from LTTng\-UST versions (up to LTTng\-UST\ \&2\&.13\&.4) to available API versions: .TS allbox tab(:); ltB ltB. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng_ust_tracef.3 new/lttng-ust-2.13.4/doc/man/lttng_ust_tracef.3 --- old/lttng-ust-2.13.3/doc/man/lttng_ust_tracef.3 2022-06-03 21:59:16.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng_ust_tracef.3 2022-08-19 22:25:02.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng_ust_tracef .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG_UST_TRACEF" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG_UST_TRACEF" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/lttng_ust_tracelog.3 new/lttng-ust-2.13.4/doc/man/lttng_ust_tracelog.3 --- old/lttng-ust-2.13.3/doc/man/lttng_ust_tracelog.3 2022-06-03 21:59:17.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/lttng_ust_tracelog.3 2022-08-19 22:25:02.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: lttng_ust_tracelog .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "LTTNG_UST_TRACELOG" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "LTTNG_UST_TRACELOG" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/tracef.3 new/lttng-ust-2.13.4/doc/man/tracef.3 --- old/lttng-ust-2.13.3/doc/man/tracef.3 2022-06-03 21:59:17.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/tracef.3 2022-08-19 22:25:03.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: tracef .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "TRACEF" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "TRACEF" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/doc/man/tracelog.3 new/lttng-ust-2.13.4/doc/man/tracelog.3 --- old/lttng-ust-2.13.3/doc/man/tracelog.3 2022-06-03 21:59:18.000000000 +0200 +++ new/lttng-ust-2.13.4/doc/man/tracelog.3 2022-08-19 22:25:03.000000000 +0200 @@ -2,12 +2,12 @@ .\" Title: tracelog .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> -.\" Date: 06/03/2022 +.\" Date: 08/19/2022 .\" Manual: LTTng Manual -.\" Source: LTTng 2.13.3 +.\" Source: LTTng 2.13.4 .\" Language: English .\" -.TH "TRACELOG" "3" "06/03/2022" "LTTng 2\&.13\&.3" "LTTng Manual" +.TH "TRACELOG" "3" "08/19/2022" "LTTng 2\&.13\&.4" "LTTng Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/include/lttng/ust-tracepoint-event.h new/lttng-ust-2.13.4/include/lttng/ust-tracepoint-event.h --- old/lttng-ust-2.13.3/include/lttng/ust-tracepoint-event.h 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/include/lttng/ust-tracepoint-event.h 2022-08-19 22:22:55.000000000 +0200 @@ -257,9 +257,16 @@ }; #include LTTNG_UST_TRACEPOINT_INCLUDE +#if defined(__cplusplus) + /* * Stage 0.9.1 - * Verifying array and sequence elements are of an integer type. + * Verifying array and sequence elements are of an integer or pointer + * type. + * + * This compile-time check is only enabled in C++, because the C + * implementation of lttng_ust_is_pointer_type does not support opaque + * pointer types. */ /* Reset all macros within LTTNG_UST_TRACEPOINT_EVENT */ @@ -288,6 +295,8 @@ #include LTTNG_UST_TRACEPOINT_INCLUDE +#endif + /* * Stage 0.9.2 of tracepoint event generation. * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/include/lttng/ust-utils.h new/lttng-ust-2.13.4/include/lttng/ust-utils.h --- old/lttng-ust-2.13.3/include/lttng/ust-utils.h 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/include/lttng/ust-utils.h 2022-08-19 22:22:55.000000000 +0200 @@ -62,13 +62,16 @@ * lttng_ust_is_pointer_type - check if type is a pointer * * Returns true if the type of @type is a pointer. + * + * Note: The C implementation of lttng_ust_is_pointer_type uses pointer + * arithmetic, which does not work on opaque pointer types. */ #if defined(__cplusplus) #define lttng_ust_is_pointer_type(type) (std::is_pointer<type>::value) #else /* The difference between two pointers is an integer. */ #define lttng_ust_is_pointer_type(type) \ - (lttng_ust_is_integer_type(typeof(((type)0 - (type)0))) && !lttng_ust_is_integer_type(type)) + (lttng_ust_is_integer_type(typeof(((type)1 - (type)1))) && !lttng_ust_is_integer_type(type)) #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/common/counter/counter.c new/lttng-ust-2.13.4/src/common/counter/counter.c --- old/lttng-ust-2.13.3/src/common/counter/counter.c 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/common/counter/counter.c 2022-08-19 22:22:55.000000000 +0200 @@ -118,7 +118,7 @@ struct lib_counter_config *config = &counter->config; struct lib_counter_layout *layout; - if (cpu < 0 || cpu >= num_possible_cpus()) + if (cpu < 0 || cpu >= get_possible_cpus_array_len()) return -EINVAL; if (!(config->alloc & COUNTER_ALLOC_PER_CPU)) @@ -171,7 +171,7 @@ int nr_counter_cpu_fds, const int *counter_cpu_fds) { - int nr_cpus = num_possible_cpus(); + int nr_cpus = get_possible_cpus_array_len(); if (CAA_BITS_PER_LONG != 64 && config->counter_size == COUNTER_SIZE_64_BIT) { WARN_ON_ONCE(1); @@ -210,7 +210,7 @@ size_t dimension, nr_elem = 1; int cpu, ret; int nr_handles = 0; - int nr_cpus = num_possible_cpus(); + int nr_cpus = get_possible_cpus_array_len(); if (validate_args(config, nr_dimensions, max_nr_elem, global_sum_step, global_counter_fd, nr_counter_cpu_fds, @@ -309,7 +309,7 @@ struct lib_counter_layout *layout; int shm_fd; - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return -1; layout = &counter->percpu_counters[cpu]; shm_fd = layout->shm_fd; @@ -335,13 +335,13 @@ switch (config->alloc) { case COUNTER_ALLOC_PER_CPU: - if (cpu < 0 || cpu >= num_possible_cpus()) + if (cpu < 0 || cpu >= get_possible_cpus_array_len()) return -EINVAL; layout = &counter->percpu_counters[cpu]; break; case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL: if (cpu >= 0) { - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return -EINVAL; layout = &counter->percpu_counters[cpu]; } else { @@ -469,13 +469,13 @@ switch (config->alloc) { case COUNTER_ALLOC_PER_CPU: - if (cpu < 0 || cpu >= num_possible_cpus()) + if (cpu < 0 || cpu >= get_possible_cpus_array_len()) return -EINVAL; layout = &counter->percpu_counters[cpu]; break; case COUNTER_ALLOC_PER_CPU | COUNTER_ALLOC_GLOBAL: if (cpu >= 0) { - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return -EINVAL; layout = &counter->percpu_counters[cpu]; } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/common/ringbuffer/ring_buffer_frontend.c new/lttng-ust-2.13.4/src/common/ringbuffer/ring_buffer_frontend.c --- old/lttng-ust-2.13.3/src/common/ringbuffer/ring_buffer_frontend.c 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/common/ringbuffer/ring_buffer_frontend.c 2022-08-19 22:22:55.000000000 +0200 @@ -982,7 +982,7 @@ int64_t blocking_timeout_ms; if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) - nr_streams = num_possible_cpus(); + nr_streams = get_possible_cpus_array_len(); else nr_streams = 1; @@ -1011,7 +1011,7 @@ return NULL; /* Allocate table for channel + per-cpu buffers */ - handle->table = shm_object_table_create(1 + num_possible_cpus()); + handle->table = shm_object_table_create(1 + get_possible_cpus_array_len()); if (!handle->table) goto error_table_alloc; @@ -1095,7 +1095,7 @@ return NULL; /* Allocate table for channel + per-cpu buffers */ - handle->table = shm_object_table_create(1 + num_possible_cpus()); + handle->table = shm_object_table_create(1 + get_possible_cpus_array_len()); if (!handle->table) goto error_table_alloc; /* Add channel object */ @@ -1190,7 +1190,7 @@ if (config->alloc == RING_BUFFER_ALLOC_GLOBAL) { cpu = 0; } else { - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return NULL; } ref = &chan->backend.buf[cpu].shmp._ref; @@ -1235,7 +1235,7 @@ if (config->alloc == RING_BUFFER_ALLOC_GLOBAL) { cpu = 0; } else { - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return -EINVAL; } ref = &chan->backend.buf[cpu].shmp._ref; @@ -1253,7 +1253,7 @@ if (config->alloc == RING_BUFFER_ALLOC_GLOBAL) { cpu = 0; } else { - if (cpu >= num_possible_cpus()) + if (cpu >= get_possible_cpus_array_len()) return -EINVAL; } ref = &chan->backend.buf[cpu].shmp._ref; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/common/smp.c new/lttng-ust-2.13.4/src/common/smp.c --- old/lttng-ust-2.13.3/src/common/smp.c 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/common/smp.c 2022-08-19 22:22:55.000000000 +0200 @@ -6,108 +6,267 @@ */ #define _LGPL_SOURCE +#include <assert.h> +#include <ctype.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> #include <unistd.h> #include <pthread.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> #include <urcu/compiler.h> +#include "common/logging.h" #include "common/smp.h" -static int num_possible_cpus_cache; - -#if (defined(__GLIBC__) || defined( __UCLIBC__)) -static void _get_num_possible_cpus(void) -{ - int result; - - /* On Linux, when some processors are offline - * _SC_NPROCESSORS_CONF counts the offline - * processors, whereas _SC_NPROCESSORS_ONLN - * does not. If we used _SC_NPROCESSORS_ONLN, - * getcpu() could return a value greater than - * this sysconf, in which case the arrays - * indexed by processor would overflow. - */ - result = sysconf(_SC_NPROCESSORS_CONF); - if (result == -1) - return; - num_possible_cpus_cache = result; -} +#define __max(a,b) ((a)>(b)?(a):(b)) -#else +static int possible_cpus_array_len_cache; /* - * The MUSL libc implementation of the _SC_NPROCESSORS_CONF sysconf does not - * return the number of configured CPUs in the system but relies on the cpu - * affinity mask of the current task. + * Get the highest CPU id from sysfs. + * + * Iterate on all the folders in "/sys/devices/system/cpu" that start with + * "cpu" followed by an integer, keep the highest CPU id encountered during + * this iteration and add 1 to get a number of CPUs. * - * So instead we use a strategy similar to GLIBC's, counting the cpu - * directories in "/sys/devices/system/cpu" and fallback on the value from - * sysconf if it fails. + * Returns the highest CPU id, or -1 on error. */ +int get_max_cpuid_from_sysfs(void) +{ + return _get_max_cpuid_from_sysfs("/sys/devices/system/cpu"); +} -#include <dirent.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - -#define __max(a,b) ((a)>(b)?(a):(b)) - -static void _get_num_possible_cpus(void) +int _get_max_cpuid_from_sysfs(const char *path) { - int result, count = 0; + long max_cpuid = -1; + DIR *cpudir; struct dirent *entry; - cpudir = opendir("/sys/devices/system/cpu"); + assert(path); + + cpudir = opendir(path); if (cpudir == NULL) goto end; /* - * Count the number of directories named "cpu" followed by and - * integer. This is the same strategy as glibc uses. + * Iterate on all directories named "cpu" followed by an integer. */ while ((entry = readdir(cpudir))) { if (entry->d_type == DT_DIR && strncmp(entry->d_name, "cpu", 3) == 0) { char *endptr; - unsigned long cpu_num; + long cpu_id; - cpu_num = strtoul(entry->d_name + 3, &endptr, 10); - if ((cpu_num < ULONG_MAX) && (endptr != entry->d_name + 3) + cpu_id = strtol(entry->d_name + 3, &endptr, 10); + if ((cpu_id < LONG_MAX) && (endptr != entry->d_name + 3) && (*endptr == '\0')) { - count++; + if (cpu_id > max_cpuid) + max_cpuid = cpu_id; } } } + if (closedir(cpudir)) + PERROR("closedir"); + + /* + * If the max CPU id is out of bound, set it to -1 so it results in a + * CPU num of 0. + */ + if (max_cpuid < 0 || max_cpuid > INT_MAX) + max_cpuid = -1; + end: + return max_cpuid; +} + +/* + * As a fallback to parsing the CPU mask in "/sys/devices/system/cpu/possible", + * iterate on all the folders in "/sys/devices/system/cpu" that start with + * "cpu" followed by an integer, keep the highest CPU id encountered during + * this iteration and add 1 to get a number of CPUs. + * + * Then get the value from sysconf(_SC_NPROCESSORS_CONF) as a fallback and + * return the highest one. + * + * On Linux, using the value from sysconf can be unreliable since the way it + * counts CPUs varies between C libraries and even between versions of the same + * library. If we used it directly, getcpu() could return a value greater than + * this sysconf, in which case the arrays indexed by processor would overflow. + * + * As another example, the MUSL libc implementation of the _SC_NPROCESSORS_CONF + * sysconf does not return the number of configured CPUs in the system but + * relies on the cpu affinity mask of the current task. + * + * Returns 0 or less on error. + */ +int get_num_possible_cpus_fallback(void) +{ /* - * Get the sysconf value as a fallback. Keep the highest number. + * Get the sysconf value as a last resort. Keep the highest number. */ - result = __max(sysconf(_SC_NPROCESSORS_CONF), count); + return __max(sysconf(_SC_NPROCESSORS_CONF), get_max_cpuid_from_sysfs() + 1); +} + +/* + * Get the CPU possible mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * + * Returns the number of bytes read or -1 on error. + */ +int get_possible_cpu_mask_from_sysfs(char *buf, size_t max_bytes) +{ + return get_cpu_mask_from_sysfs(buf, max_bytes, + "/sys/devices/system/cpu/possible"); +} + +/* + * Get a CPU mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * path: file path to read the mask from. + * + * Returns the number of bytes read or -1 on error. + */ +int get_cpu_mask_from_sysfs(char *buf, size_t max_bytes, const char *path) +{ + ssize_t bytes_read = 0; + size_t total_bytes_read = 0; + int fd = -1, ret = -1; + + assert(path); + + if (buf == NULL) + goto end; + + fd = open(path, O_RDONLY); + if (fd < 0) + goto end; + + do { + bytes_read = read(fd, buf + total_bytes_read, + max_bytes - total_bytes_read); + + if (bytes_read < 0) { + if (errno == EINTR) { + continue; /* retry operation */ + } else { + goto end; + } + } + + total_bytes_read += bytes_read; + assert(total_bytes_read <= max_bytes); + } while (max_bytes > total_bytes_read && bytes_read > 0); /* - * If both methods failed, don't store the value. + * Make sure the mask read is a null terminated string. */ - if (result < 1) + if (total_bytes_read < max_bytes) + buf[total_bytes_read] = '\0'; + else + buf[max_bytes - 1] = '\0'; + + if (total_bytes_read > INT_MAX) + goto end; + ret = (int) total_bytes_read; +end: + if (fd >= 0 && close(fd) < 0) + PERROR("close"); + return ret; +} + +/* + * Get the highest CPU id from a CPU mask. + * + * pmask: the mask to parse. + * len: the len of the mask excluding '\0'. + * + * Returns the highest CPU id from the mask or -1 on error. + */ +int get_max_cpuid_from_mask(const char *pmask, size_t len) +{ + ssize_t i; + unsigned long cpu_index; + char *endptr; + + /* We need at least one char to read */ + if (len < 1) + goto error; + + /* Start from the end to read the last CPU index. */ + for (i = len - 1; i > 0; i--) { + /* Break when we hit the first separator. */ + if ((pmask[i] == ',') || (pmask[i] == '-')) { + i++; + break; + } + } + + cpu_index = strtoul(&pmask[i], &endptr, 10); + + if ((&pmask[i] != endptr) && (cpu_index < INT_MAX)) + return (int) cpu_index; + +error: + return -1; +} + +static void update_possible_cpus_array_len_cache(void) +{ + int ret; + char buf[LTTNG_UST_CPUMASK_SIZE]; + + /* Get the possible cpu mask from sysfs, fallback to sysconf. */ + ret = get_possible_cpu_mask_from_sysfs((char *) &buf, LTTNG_UST_CPUMASK_SIZE); + if (ret <= 0) + goto fallback; + + /* Parse the possible cpu mask, on failure fallback to sysconf. */ + ret = get_max_cpuid_from_mask((char *) &buf, ret); + if (ret >= 0) { + /* Add 1 to convert from max cpuid to an array len. */ + ret++; + goto end; + } + +fallback: + /* Fallback to sysconf. */ + ret = get_num_possible_cpus_fallback(); + +end: + /* If all methods failed, don't store the value. */ + if (ret < 1) return; - num_possible_cpus_cache = result; + + possible_cpus_array_len_cache = ret; } -#endif /* - * Returns the total number of CPUs in the system. If the cache is not yet - * initialized, get the value from the system through sysconf and cache it. + * Returns the length of an array that could contain a per-CPU element for each + * possible CPU id for the lifetime of the process. + * + * We currently assume CPU ids are contiguous up the maximum CPU id. + * + * If the cache is not yet initialized, get the value from + * "/sys/devices/system/cpu/possible" or fallback to sysconf and cache it. * - * If the sysconf call fails, don't populate the cache and return 0. + * If all methods fail, don't populate the cache and return 0. */ -int num_possible_cpus(void) +int get_possible_cpus_array_len(void) { - if (caa_unlikely(!num_possible_cpus_cache)) - _get_num_possible_cpus(); + if (caa_unlikely(!possible_cpus_array_len_cache)) + update_possible_cpus_array_len_cache(); - return num_possible_cpus_cache; + return possible_cpus_array_len_cache; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/common/smp.h new/lttng-ust-2.13.4/src/common/smp.h --- old/lttng-ust-2.13.3/src/common/smp.h 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/common/smp.h 2022-08-19 22:22:55.000000000 +0200 @@ -7,16 +7,81 @@ #ifndef _UST_COMMON_SMP_H #define _UST_COMMON_SMP_H +#define LTTNG_UST_CPUMASK_SIZE 4096 + +/* + * Get a CPU mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * path: file path to read the mask from. + * + * Returns the number of bytes read or -1 on error. + */ +int get_cpu_mask_from_sysfs(char *buf, size_t max_bytes, const char *path) + __attribute__((visibility("hidden"))); + +/* + * Get the CPU possible mask string from sysfs. + * + * buf: the buffer where the mask will be read. + * max_bytes: the maximum number of bytes to write in the buffer. + * + * Returns the number of bytes read or -1 on error. + */ +int get_possible_cpu_mask_from_sysfs(char *buf, size_t max_bytes) + __attribute__((visibility("hidden"))); + +/* + * Get the highest CPU id from sysfs. + * + * Iterate on all the folders in "/sys/devices/system/cpu" that start with + * "cpu" followed by an integer, keep the highest CPU id encountered during + * this iteration and add 1 to get a number of CPUs. + * + * Returns the highest CPU id, or -1 on error. + */ +int get_max_cpuid_from_sysfs(void) + __attribute__((visibility("hidden"))); + +int _get_max_cpuid_from_sysfs(const char *path) + __attribute__((visibility("hidden"))); + +/* + * Get the number of possible CPUs in the system from either + * sysconf(_SC_NPROCESSORS_CONF) or some other mechanism depending on the libc. + * + * Returns the number of possible CPUs in the system or 0 on error. + */ +int get_num_possible_cpus_fallback(void) + __attribute__((visibility("hidden"))); + /* - * Returns the total number of CPUs in the system. If the cache is not yet - * initialized, get the value from the system through sysconf and cache it. + * Get the highest CPU id from a CPU mask. + * + * pmask: the mask to parse. + * len: the len of the mask excluding '\0'. + * + * Returns the highest CPU id from the mask or -1 on error. + */ +int get_max_cpuid_from_mask(const char *pmask, size_t len) + __attribute__((visibility("hidden"))); + +/* + * Returns the length of an array that could contain a per-CPU element for each + * possible CPU id for the lifetime of the process. + * + * We currently assume CPU ids are contiguous up the maximum CPU id. + * + * If the cache is not yet initialized, get the value from + * "/sys/devices/system/cpu/possible" or fallback to sysconf and cache it. * - * If the sysconf call fails, don't populate the cache and return 0. + * If all methods fail, don't populate the cache and return 0. */ -int num_possible_cpus(void) +int get_possible_cpus_array_len(void) __attribute__((visibility("hidden"))); #define for_each_possible_cpu(cpu) \ - for ((cpu) = 0; (cpu) < num_possible_cpus(); (cpu)++) + for ((cpu) = 0; (cpu) < get_possible_cpus_array_len(); (cpu)++) #endif /* _UST_COMMON_SMP_H */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/lib/lttng-ust/lttng-ust-comm.c new/lttng-ust-2.13.4/src/lib/lttng-ust/lttng-ust-comm.c --- old/lttng-ust-2.13.3/src/lib/lttng-ust/lttng-ust-comm.c 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/lib/lttng-ust/lttng-ust-comm.c 2022-08-19 22:22:55.000000000 +0200 @@ -1757,18 +1757,25 @@ DBG("Waiting for %s apps sessiond", sock_info->name); /* Wait for futex wakeup */ - if (uatomic_read((int32_t *) sock_info->wait_shm_mmap)) - goto end_wait; - - while (lttng_ust_futex_async((int32_t *) sock_info->wait_shm_mmap, - FUTEX_WAIT, 0, NULL, NULL, 0)) { + while (!uatomic_read((int32_t *) sock_info->wait_shm_mmap)) { + if (!lttng_ust_futex_async((int32_t *) sock_info->wait_shm_mmap, FUTEX_WAIT, 0, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * 0 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from 0. + */ + continue; + } switch (errno) { - case EWOULDBLOCK: + case EAGAIN: /* Value already changed. */ goto end_wait; case EINTR: /* Retry if interrupted by signal. */ - break; /* Get out of switch. */ + break; /* Get out of switch. Check again. */ case EFAULT: wait_poll_fallback = 1; DBG( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/src/lib/lttng-ust-ctl/ustctl.c new/lttng-ust-2.13.4/src/lib/lttng-ust-ctl/ustctl.c --- old/lttng-ust-2.13.3/src/lib/lttng-ust-ctl/ustctl.c 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/src/lib/lttng-ust-ctl/ustctl.c 2022-08-19 22:22:55.000000000 +0200 @@ -1257,7 +1257,7 @@ obj->u.channel.wakeup_fd = dup(src->u.channel.wakeup_fd); if (obj->u.channel.wakeup_fd < 0) { - ret = errno; + ret = -errno; goto chan_error_wakeup_fd; } } else { @@ -1293,7 +1293,7 @@ obj->u.stream.wakeup_fd = dup(src->u.stream.wakeup_fd); if (obj->u.stream.wakeup_fd < 0) { - ret = errno; + ret = -errno; goto stream_error_wakeup_fd; } } else { @@ -1305,7 +1305,7 @@ obj->u.stream.shm_fd = dup(src->u.stream.shm_fd); if (obj->u.stream.shm_fd < 0) { - ret = errno; + ret = -errno; goto stream_error_shm_fd; } } else { @@ -1344,7 +1344,7 @@ obj->u.counter_global.shm_fd = dup(src->u.counter_global.shm_fd); if (obj->u.counter_global.shm_fd < 0) { - ret = errno; + ret = -errno; goto error_type; } } @@ -1358,7 +1358,7 @@ obj->u.counter_cpu.shm_fd = dup(src->u.counter_cpu.shm_fd); if (obj->u.counter_cpu.shm_fd < 0) { - ret = errno; + ret = -errno; goto error_type; } } @@ -1384,7 +1384,7 @@ int lttng_ust_ctl_get_nr_stream_per_channel(void) { - return num_possible_cpus(); + return get_possible_cpus_array_len(); } struct lttng_ust_ctl_consumer_channel * @@ -2901,7 +2901,7 @@ int lttng_ust_ctl_get_nr_cpu_per_counter(void) { - return num_possible_cpus(); + return get_possible_cpus_array_len(); } struct lttng_ust_ctl_daemon_counter * diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/Makefile.am new/lttng-ust-2.13.4/tests/Makefile.am --- old/lttng-ust-2.13.3/tests/Makefile.am 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/tests/Makefile.am 2022-08-19 22:22:55.000000000 +0200 @@ -13,6 +13,10 @@ TESTS = \ unit/libringbuffer/test_shm \ unit/gcc-weak-hidden/test_gcc_weak_hidden \ + unit/libcommon/test_get_cpu_mask_from_sysfs \ + unit/libcommon/test_get_max_cpuid_from_mask \ + unit/libcommon/test_get_max_cpuid_from_sysfs \ + unit/libcommon/test_get_possible_cpus_array_len \ unit/libmsgpack/test_msgpack \ unit/pthread_name/test_pthread_name \ unit/snprintf/test_snprintf \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/Makefile.am new/lttng-ust-2.13.4/tests/unit/Makefile.am --- old/lttng-ust-2.13.3/tests/unit/Makefile.am 2022-06-03 21:58:01.000000000 +0200 +++ new/lttng-ust-2.13.4/tests/unit/Makefile.am 2022-08-19 22:22:55.000000000 +0200 @@ -2,6 +2,7 @@ SUBDIRS = \ gcc-weak-hidden \ + libcommon \ libmsgpack \ libringbuffer \ pthread_name \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/Makefile.am new/lttng-ust-2.13.4/tests/unit/libcommon/Makefile.am --- old/lttng-ust-2.13.3/tests/unit/libcommon/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/Makefile.am 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: LGPL-2.1-only + +AM_CPPFLAGS += -I$(top_srcdir)/tests/utils + +noinst_PROGRAMS = \ + get_cpu_mask_from_sysfs \ + get_max_cpuid_from_sysfs \ + test_get_max_cpuid_from_mask \ + test_get_possible_cpus_array_len + +dist_noinst_SCRIPTS = \ + test_get_cpu_mask_from_sysfs \ + test_get_max_cpuid_from_sysfs + +get_cpu_mask_from_sysfs_SOURCES = get_cpu_mask_from_sysfs.c +get_cpu_mask_from_sysfs_LDADD = \ + $(top_builddir)/src/common/libcommon.la + +get_max_cpuid_from_sysfs_SOURCES = get_max_cpuid_from_sysfs.c +get_max_cpuid_from_sysfs_LDADD = \ + $(top_builddir)/src/common/libcommon.la + +test_get_max_cpuid_from_mask_SOURCES = test_get_max_cpuid_from_mask.c +test_get_max_cpuid_from_mask_LDADD = \ + $(top_builddir)/src/common/libcommon.la \ + $(top_builddir)/tests/utils/libtap.a + +test_get_possible_cpus_array_len_SOURCES = test_get_possible_cpus_array_len.c +test_get_possible_cpus_array_len_LDADD = \ + $(top_builddir)/src/common/libcommon.la \ + $(top_builddir)/tests/utils/libtap.a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/get_cpu_mask_from_sysfs.c new/lttng-ust-2.13.4/tests/unit/libcommon/get_cpu_mask_from_sysfs.c --- old/lttng-ust-2.13.3/tests/unit/libcommon/get_cpu_mask_from_sysfs.c 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/get_cpu_mask_from_sysfs.c 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2022 Michael Jeanson <mjeanson@efficios.com> + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "common/smp.h" + +int main(int argc, char *argv[]) +{ + int ret; + char buf[LTTNG_UST_CPUMASK_SIZE]; + + if( argc < 2 ) { + fprintf(stderr, "Missing argument.\n"); + return EXIT_FAILURE; + } + + ret = get_cpu_mask_from_sysfs((char *) &buf, LTTNG_UST_CPUMASK_SIZE, argv[1]); + + printf("%s", buf); + + if (ret >= 0) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/get_max_cpuid_from_sysfs.c new/lttng-ust-2.13.4/tests/unit/libcommon/get_max_cpuid_from_sysfs.c --- old/lttng-ust-2.13.3/tests/unit/libcommon/get_max_cpuid_from_sysfs.c 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/get_max_cpuid_from_sysfs.c 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,29 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2022 Michael Jeanson <mjeanson@efficios.com> + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "common/smp.h" + +int main(int argc, char *argv[]) +{ + int ret; + + if( argc < 2 ) { + fprintf(stderr, "Missing argument.\n"); + return EXIT_FAILURE; + } + + ret = _get_max_cpuid_from_sysfs(argv[1]); + + printf("%d\n", ret); + + if (ret >= 0) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_cpu_mask_from_sysfs new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_cpu_mask_from_sysfs --- old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_cpu_mask_from_sysfs 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_cpu_mask_from_sysfs 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-only + +if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi + +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$UST_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${UST_TESTS_BUILDDIR}/unit/libcommon" + +NUM_TESTS=8 + +TESTFILE=$(mktemp) + +populate_testfile() { + local cpumask="$1" + + # shellcheck disable=SC2059 + printf "$cpumask" > "$TESTFILE" +} + +test_test_get_cpu_mask_from_sysfs() { + local cpumask="$1" + local result + + # Without '\n' + populate_testfile "$cpumask" + result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs - without '\n' expected: '$cpumask', result: '$result'" + + # With '\n' + populate_testfile "$cpumask\n" + result=$("${CURDIR}/get_cpu_mask_from_sysfs" "$TESTFILE") + test "$cpumask" == "$result" + ok $? "test_get_cpu_mask_from_sysfs - with '\n' expected: '$cpumask', result: '$result'" +} + +plan_tests $NUM_TESTS + +test_test_get_cpu_mask_from_sysfs "" +test_test_get_cpu_mask_from_sysfs "0" +test_test_get_cpu_mask_from_sysfs "0-3" +test_test_get_cpu_mask_from_sysfs "0,3-7,9" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_max_cpuid_from_mask.c new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_max_cpuid_from_mask.c --- old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_max_cpuid_from_mask.c 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_max_cpuid_from_mask.c 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,77 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2022 Michael Jeanson <mjeanson@efficios.com> + */ + +#include <string.h> + +#include "tap.h" + +#include "common/smp.h" + +struct parse_test_data { + const char *buf; + int expected; +}; + +static struct parse_test_data parse_test_data[] = { + { "", -1 }, + { "abc", -1 }, + { ",,,", -1 }, + { "--", -1 }, + { ",", -1 }, + { "-", -1 }, + { "2147483647", -1 }, + { "18446744073709551615", -1 }, + { "0-2147483647", -1 }, + { "0-18446744073709551615", -1 }, + { "0", 0 }, + { "1", 1 }, + { "0-1", 1 }, + { "1-3", 3 }, + { "0,2", 2 }, + { "1,2", 2 }, + { "0,4-6,127", 127 }, + { "0-4095", 4095 }, + + { "\n", -1 }, + { "abc\n", -1 }, + { ",,,\n", -1 }, + { "--\n", -1 }, + { ",\n", -1 }, + { "-\n", -1 }, + { "2147483647\n", -1 }, + { "18446744073709551615\n", -1 }, + { "0-2147483647\n", -1 }, + { "0-18446744073709551615\n", -1 }, + { "0\n", 0 }, + { "1\n", 1 }, + { "0-1\n", 1 }, + { "1-3\n", 3 }, + { "0,2\n", 2 }, + { "1,2\n", 2 }, + { "0,4-6,127\n", 127 }, + { "0-4095\n", 4095 }, +}; + +static int parse_test_data_len = sizeof(parse_test_data) / sizeof(parse_test_data[0]); + +int main(void) +{ + int ret, i; + + plan_tests(parse_test_data_len); + + diag("Testing smp helpers"); + + for (i = 0; i < parse_test_data_len; i++) { + ret = get_max_cpuid_from_mask(parse_test_data[i].buf, + strlen(parse_test_data[i].buf)); + ok(ret == parse_test_data[i].expected, + "get_max_cpuid_from_mask '%s', expected: '%d', result: '%d'", + parse_test_data[i].buf, parse_test_data[i].expected, ret); + } + + return exit_status(); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_max_cpuid_from_sysfs new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_max_cpuid_from_sysfs --- old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_max_cpuid_from_sysfs 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_max_cpuid_from_sysfs 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,89 @@ +#!/bin/bash +# SPDX-License-Identifier: LGPL-2.1-only + +if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then + UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh" +else + UTILSSH="$(dirname "$0")/../../utils/utils.sh" +fi + +# shellcheck source=../../utils/utils.sh +source "$UTILSSH" + +# shellcheck source=../../utils/tap.sh +source "$UST_TESTS_SRCDIR/utils/tap.sh" + +CURDIR="${UST_TESTS_BUILDDIR}/unit/libcommon" + +STD_OUTPUT="/dev/null" +STD_ERROR="/dev/null" + +NUM_TESTS=13 + +TESTDIR=$(mktemp -d) + +populate_testdir() { + local cpus=("$@") + + mkdir "$TESTDIR" + + for i in "${cpus[@]}"; do + mkdir "$TESTDIR/$i" + done +} + +test_get_max_cpuid_from_sysfs() { + local num_cpus=$1 + shift + local current_cpus=("$@") + local result + + populate_testdir "${current_cpus[@]}" >"$STD_OUTPUT" 2>"$STD_ERROR" + result=$("${CURDIR}/get_max_cpuid_from_sysfs" "$TESTDIR") + is "$result" "$num_cpus" "get_max_cpuid_from_sysfs - cpu set: '${current_cpus[*]}', expected: '$num_cpus', result: '$result'" + rm -rf "$TESTDIR" +} + +plan_tests $NUM_TESTS + +diag "get_max_cpuid_from_sysfs" + +test_data=(0 "cpu0") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(1 "cpu0" "cpu1") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(1 "cpu1" "cpu0") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(3 "cpu3") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(99 "cpu99") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(3 "cpu0" "cpu3") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(0 "cpu" "cpu0") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(5 "cpu" "cpu5") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + + +test_data=(-1 "toto") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(-1 "cpu") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(-1 "cpua" "cpud") +test_get_max_cpuid_from_sysfs "${test_data[@]}" + +test_data=(-1 "cpufreq" "cpuidle") +test_get_max_cpuid_from_sysfs "${test_data[@]}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_possible_cpus_array_len.c new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_possible_cpus_array_len.c --- old/lttng-ust-2.13.3/tests/unit/libcommon/test_get_possible_cpus_array_len.c 1970-01-01 01:00:00.000000000 +0100 +++ new/lttng-ust-2.13.4/tests/unit/libcommon/test_get_possible_cpus_array_len.c 2022-08-19 22:22:55.000000000 +0200 @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2022 Michael Jeanson <mjeanson@efficios.com> + */ + +#include <stdio.h> + +#include "tap.h" + +#include "common/smp.h" + +int main(void) +{ + int ret; + + plan_tests(2); + + ret = get_possible_cpus_array_len(); + ok(ret > 0, "get_possible_cpus_array_len (%d > 0)", ret); + + ret = get_num_possible_cpus_fallback(); + ok(ret > 0, "get_num_possible_cpus_fallback (%d > 0)", ret); + + return exit_status(); +}
participants (1)
-
Source-Sync