Commit 7e960d9d authored by Michael Jeanson's avatar Michael Jeanson

Update upstream source from tag 'upstream/2.10.4'

Update to upstream version '2.10.4'
with Debian dir 7297ed91e8179d21165a50a40c5fd71b0bf235f6
parents 69cfc51a 11113ed9
2019-05-24 (Scavenger Hunt Day) lttng-ust 2.10.4
* Cleanup: bitfields: streamline use of underscores
* Silence compiler "always false comparison" warning
* Fix: bitfield: shift undefined/implementation defined behaviors
* Fix: Update coding style link
* Fix: alignment of ring buffer shm space reservation
* ust-ctl API: clarify getter usage requirements
* Fix: don't access packet header for stream_id and stream_instance_id getters
* compat: work around broken _SC_NPROCESSORS_CONF on MUSL libc
* doc: remove repeated word in coding style
* tap-driver.sh: flush stdout after each test result
* Move wait_shm_mmap initialization to library constructor
2019-01-25 (National Opposite Day) lttng-ust 2.10.3
* Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation
* Clarify lib_ring_buffer_switch_slow() requirements
......
LTTng-UST Coding Style
The coding style used for this project follows the the Linux kernel
The coding style used for this project follows the Linux kernel
guide lines. Please refer to:
- Linux kernel Documentation/CodingStyle document for details,
......
......@@ -273,6 +273,9 @@ function report(result, details)
msg = msg " " details
# Output on console might be colorized.
print decorate_result(result) msg
# Flush stdout after each test result, this is useful when stdout
# is buffered, for example in a CI system.
fflush()
# Log the result in the log file too, to help debugging (this is
# especially true when said result is a TAP error or "Bail out!").
print result msg | "cat >&3";
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for lttng-ust 2.10.3.
# Generated by GNU Autoconf 2.69 for lttng-ust 2.10.4.
#
# Report bugs to <mathieu dot desnoyers at efficios dot com>.
#
......@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='lttng-ust'
PACKAGE_TARNAME='lttng-ust'
PACKAGE_VERSION='2.10.3'
PACKAGE_STRING='lttng-ust 2.10.3'
PACKAGE_VERSION='2.10.4'
PACKAGE_STRING='lttng-ust 2.10.4'
PACKAGE_BUGREPORT='mathieu dot desnoyers at efficios dot com'
PACKAGE_URL='https://lttng.org'
......@@ -1423,7 +1423,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures lttng-ust 2.10.3 to adapt to many kinds of systems.
\`configure' configures lttng-ust 2.10.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1495,7 +1495,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of lttng-ust 2.10.3:";;
short | recursive ) echo "Configuration of lttng-ust 2.10.4:";;
esac
cat <<\_ACEOF
......@@ -1653,7 +1653,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
lttng-ust configure 2.10.3
lttng-ust configure 2.10.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2373,7 +2373,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by lttng-ust $as_me 2.10.3, which was
It was created by lttng-ust $as_me 2.10.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2729,7 +2729,7 @@ MAJOR_VERSION=2
MINOR_VERSION=10
PATCHLEVEL_VERSION=3
PATCHLEVEL_VERSION=4
# Following the numbering scheme proposed by libtool for the library version
......@@ -3377,7 +3377,7 @@ fi
# Define the identity of the package.
PACKAGE='lttng-ust'
VERSION='2.10.3'
VERSION='2.10.4'
cat >>confdefs.h <<_ACEOF
......@@ -22377,7 +22377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by lttng-ust $as_me 2.10.3, which was
This file was extended by lttng-ust $as_me 2.10.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -22448,7 +22448,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
lttng-ust config.status 2.10.3
lttng-ust config.status 2.10.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
dnl Version infos
m4_define([V_MAJOR], [2])
m4_define([V_MINOR], [10])
m4_define([V_PATCH], [3])
m4_define([V_PATCH], [4])
dnl m4_define([V_EXTRA], [])
m4_define([V_NAME], [[KeKriek]])
m4_define([V_DESC], [[From Brasserie Dunham, a sour mashed golden wheat ale fermented with local sour cherries from Tougas orchards. Fresh sweet cherry notes with some tartness, lively carbonation with a dry finish.]])
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-gen-tp
.\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "LTTNG\-GEN\-TP" "1" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "LTTNG\-GEN\-TP" "1" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust-dl
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "LTTNG\-UST\-DL" "3" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "LTTNG\-UST\-DL" "3" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust-dl
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "LTTNG\-UST\-DL" "3" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "LTTNG\-UST\-DL" "3" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: lttng-ust
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "LTTNG\-UST" "3" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "LTTNG\-UST" "3" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: tracef
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "TRACEF" "3" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "TRACEF" "3" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
......@@ -2,12 +2,12 @@
.\" Title: tracelog
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
.\" Date: 01/25/2019
.\" Date: 05/24/2019
.\" Manual: LTTng Manual
.\" Source: LTTng 2.10.3
.\" Source: LTTng 2.10.4
.\" Language: English
.\"
.TH "TRACELOG" "3" "01/25/2019" "LTTng 2\&.10\&.3" "LTTng Manual"
.TH "TRACELOG" "3" "05/24/2019" "LTTng 2\&.10\&.4" "LTTng Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
......
This diff is collapsed.
......@@ -240,6 +240,12 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
int producer_active);
/* index */
/*
* Getters which need to be used on the current packet (between get/put
* or get_next/put_next.
*/
int ustctl_get_timestamp_begin(struct ustctl_consumer_stream *stream,
uint64_t *timestamp_begin);
int ustctl_get_timestamp_end(struct ustctl_consumer_stream *stream,
......@@ -250,15 +256,26 @@ int ustctl_get_content_size(struct ustctl_consumer_stream *stream,
uint64_t *content_size);
int ustctl_get_packet_size(struct ustctl_consumer_stream *stream,
uint64_t *packet_size);
int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
uint64_t *stream_id);
int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
uint64_t *ts);
int ustctl_get_sequence_number(struct ustctl_consumer_stream *stream,
uint64_t *seq);
/*
* Getter returning state invariant for the stream, which can be used
* without "get" operation.
*/
int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
uint64_t *stream_id);
int ustctl_get_instance_id(struct ustctl_consumer_stream *stream,
uint64_t *id);
/*
* Getter returning the current timestamp as perceived from the
* tracer.
*/
int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
uint64_t *ts);
/* returns whether UST has perf counters support. */
int ustctl_has_perf_counters(void);
......
......@@ -556,12 +556,11 @@ static int client_stream_id(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle,
uint64_t *stream_id)
{
struct packet_header *header;
struct channel *chan = shmp(handle, buf->backend.chan);
struct lttng_channel *lttng_chan = channel_get_private(chan);
*stream_id = lttng_chan->id;
header = client_packet_header(buf, handle);
if (!header)
return -1;
*stream_id = header->stream_id;
return 0;
}
......@@ -592,10 +591,8 @@ static int client_instance_id(struct lttng_ust_lib_ring_buffer *buf,
struct lttng_ust_shm_handle *handle,
uint64_t *id)
{
struct packet_header *header;
*id = buf->backend.cpu;
header = client_packet_header(buf, handle);
*id = header->stream_instance_id;
return 0;
}
......
......@@ -260,7 +260,7 @@ struct sock_info global_apps = {
.global = 1,
.root_handle = -1,
.allowed = 1,
.allowed = 0,
.thread_active = 0,
.sock_path = LTTNG_DEFAULT_RUNDIR "/" LTTNG_UST_SOCK_FILENAME,
......@@ -339,6 +339,8 @@ extern void lttng_ring_buffer_client_discard_exit(void);
extern void lttng_ring_buffer_client_discard_rt_exit(void);
extern void lttng_ring_buffer_metadata_client_exit(void);
static char *get_map_shm(struct sock_info *sock_info);
ssize_t lttng_ust_read(int fd, void *buf, size_t len)
{
ssize_t ret;
......@@ -430,25 +432,48 @@ void print_cmd(int cmd, int handle)
lttng_ust_obj_get_name(handle), handle);
}
static
int setup_global_apps(void)
{
int ret = 0;
assert(!global_apps.wait_shm_mmap);
global_apps.wait_shm_mmap = get_map_shm(&global_apps);
if (!global_apps.wait_shm_mmap) {
WARN("Unable to get map shm for global apps. Disabling LTTng-UST global tracing.");
global_apps.allowed = 0;
ret = -EIO;
goto error;
}
global_apps.allowed = 1;
error:
return ret;
}
static
int setup_local_apps(void)
{
int ret = 0;
const char *home_dir;
uid_t uid;
assert(!local_apps.wait_shm_mmap);
uid = getuid();
/*
* Disallow per-user tracing for setuid binaries.
*/
if (uid != geteuid()) {
assert(local_apps.allowed == 0);
return 0;
ret = 0;
goto end;
}
home_dir = get_lttng_home_dir();
if (!home_dir) {
WARN("HOME environment variable not set. Disabling LTTng-UST per-user tracing.");
assert(local_apps.allowed == 0);
return -ENOENT;
ret = -ENOENT;
goto end;
}
local_apps.allowed = 1;
snprintf(local_apps.sock_path, PATH_MAX, "%s/%s/%s",
......@@ -458,7 +483,16 @@ int setup_local_apps(void)
snprintf(local_apps.wait_shm_path, PATH_MAX, "/%s-%u",
LTTNG_UST_WAIT_FILENAME,
uid);
return 0;
local_apps.wait_shm_mmap = get_map_shm(&local_apps);
if (!local_apps.wait_shm_mmap) {
WARN("Unable to get map shm for local apps. Disabling LTTng-UST per-user tracing.");
local_apps.allowed = 0;
ret = -EIO;
goto end;
}
end:
return ret;
}
/*
......@@ -1301,19 +1335,17 @@ error:
static
void wait_for_sessiond(struct sock_info *sock_info)
{
/* Use ust_lock to check if we should quit. */
if (ust_lock()) {
goto quit;
}
if (wait_poll_fallback) {
goto error;
}
if (!sock_info->wait_shm_mmap) {
sock_info->wait_shm_mmap = get_map_shm(sock_info);
if (!sock_info->wait_shm_mmap)
goto error;
}
ust_unlock();
assert(sock_info->wait_shm_mmap);
DBG("Waiting for %s apps sessiond", sock_info->name);
/* Wait for futex wakeup */
if (uatomic_read((int32_t *) sock_info->wait_shm_mmap))
......@@ -1731,8 +1763,15 @@ void __attribute__((constructor)) lttng_ust_init(void)
PERROR("sem_init");
}
ret = setup_global_apps();
if (ret) {
assert(global_apps.allowed == 0);
DBG("global apps setup returned %d", ret);
}
ret = setup_local_apps();
if (ret) {
assert(local_apps.allowed == 0);
DBG("local apps setup returned %d", ret);
}
......@@ -1756,14 +1795,18 @@ void __attribute__((constructor)) lttng_ust_init(void)
ERR("pthread_attr_setdetachstate: %s", strerror(ret));
}
pthread_mutex_lock(&ust_exit_mutex);
ret = pthread_create(&global_apps.ust_listener, &thread_attr,
ust_listener_thread, &global_apps);
if (ret) {
ERR("pthread_create global: %s", strerror(ret));
if (global_apps.allowed) {
pthread_mutex_lock(&ust_exit_mutex);
ret = pthread_create(&global_apps.ust_listener, &thread_attr,
ust_listener_thread, &global_apps);
if (ret) {
ERR("pthread_create global: %s", strerror(ret));
}
global_apps.thread_active = 1;
pthread_mutex_unlock(&ust_exit_mutex);
} else {
handle_register_done(&global_apps);
}
global_apps.thread_active = 1;
pthread_mutex_unlock(&ust_exit_mutex);
if (local_apps.allowed) {
pthread_mutex_lock(&ust_exit_mutex);
......@@ -1834,6 +1877,7 @@ void lttng_ust_cleanup(int exiting)
cleanup_sock_info(&global_apps, exiting);
cleanup_sock_info(&local_apps, exiting);
local_apps.allowed = 0;
global_apps.allowed = 0;
/*
* The teardown in this function all affect data structures
* accessed under the UST lock by the listener thread. This
......
......@@ -322,6 +322,10 @@ int channel_backend_init(struct channel_backend *chanb,
/* Per-cpu buffer size: control (prior to backend) */
shmsize = offset_align(shmsize, __alignof__(struct lttng_ust_lib_ring_buffer));
shmsize += sizeof(struct lttng_ust_lib_ring_buffer);
shmsize += offset_align(shmsize, __alignof__(struct commit_counters_hot));
shmsize += sizeof(struct commit_counters_hot) * num_subbuf;
shmsize += offset_align(shmsize, __alignof__(struct commit_counters_cold));
shmsize += sizeof(struct commit_counters_cold) * num_subbuf;
/* Per-cpu buffer size: backend */
/* num_subbuf + 1 is the worse case */
......@@ -336,11 +340,6 @@ int channel_backend_init(struct channel_backend *chanb,
shmsize += sizeof(struct lttng_ust_lib_ring_buffer_backend_subbuffer) * num_subbuf;
shmsize += offset_align(shmsize, __alignof__(struct lttng_ust_lib_ring_buffer_backend_counts));
shmsize += sizeof(struct lttng_ust_lib_ring_buffer_backend_counts) * num_subbuf;
/* Per-cpu buffer size: control (after backend) */
shmsize += offset_align(shmsize, __alignof__(struct commit_counters_hot));
shmsize += sizeof(struct commit_counters_hot) * num_subbuf;
shmsize += offset_align(shmsize, __alignof__(struct commit_counters_cold));
shmsize += sizeof(struct commit_counters_cold) * num_subbuf;
if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
struct lttng_ust_lib_ring_buffer *buf;
......
......@@ -2,6 +2,7 @@
* libringbuffer/smp.c
*
* Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
* Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -26,6 +27,7 @@
int __num_possible_cpus;
#if (defined(__GLIBC__) || defined( __UCLIBC__))
void _get_num_possible_cpus(void)
{
int result;
......@@ -43,3 +45,67 @@ void _get_num_possible_cpus(void)
return;
__num_possible_cpus = result;
}
#else
/*
* 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.
*
* 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.
*/
#include <dirent.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#define __max(a,b) ((a)>(b)?(a):(b))
void _get_num_possible_cpus(void)
{
int result, count = 0;
DIR *cpudir;
struct dirent *entry;
cpudir = opendir("/sys/devices/system/cpu");
if (cpudir == NULL)
goto end;
/*
* Count the number of directories named "cpu" followed by and
* integer. This is the same strategy as glibc uses.
*/
while ((entry = readdir(cpudir))) {
if (entry->d_type == DT_DIR &&
strncmp(entry->d_name, "cpu", 3) == 0) {
char *endptr;
unsigned long cpu_num;
cpu_num = strtoul(entry->d_name + 3, &endptr, 10);
if ((cpu_num < ULONG_MAX) && (endptr != entry->d_name + 3)
&& (*endptr == '\0')) {
count++;
}
}
}
end:
/*
* Get the sysconf value as a fallback. Keep the highest number.
*/
result = __max(sysconf(_SC_NPROCESSORS_CONF), count);
/*
* If both methods failed, don't store the value.
*/
if (result < 1)
return;
__num_possible_cpus = result;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment