From f73bcf5eafdc10b2bbb32de0bcef709de0f8f5e5 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 22 Apr 2021 20:39:28 -0400 Subject: [PATCH] Move the getcpu plugin implementation to liblttn-ust-common The getcpu plugin is used by both liblttng-ust and liblttng-ust-ctl, move it to liblttng-ust-common. Change-Id: Ifdef881188e744ffd2c19670959612aaca8d73d9 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- src/common/Makefile.am | 1 + src/common/counter/counter-api.h | 2 +- src/{lib/lttng-ust => common}/getcpu.h | 18 +++++++----------- src/common/ringbuffer/frontend_api.h | 2 +- src/lib/lttng-ust-common/Makefile.am | 2 ++ .../{lttng-ust => lttng-ust-common}/getcpu.c | 6 ++++-- src/lib/lttng-ust-common/getcpu.h | 17 +++++++++++++++++ src/lib/lttng-ust-common/ust-common.c | 6 ++++++ src/lib/lttng-ust/Makefile.am | 3 +-- src/lib/lttng-ust/lttng-context-cpu-id.c | 3 ++- src/lib/lttng-ust/lttng-ust-comm.c | 2 -- 11 files changed, 42 insertions(+), 20 deletions(-) rename src/{lib/lttng-ust => common}/getcpu.h (88%) rename src/lib/{lttng-ust => lttng-ust-common}/getcpu.c (96%) create mode 100644 src/lib/lttng-ust-common/getcpu.h diff --git a/src/common/Makefile.am b/src/common/Makefile.am index f4c134a7..4692e24c 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -14,6 +14,7 @@ noinst_HEADERS = \ creds.h \ err-ptr.h \ events.h \ + getcpu.h \ hash.h \ jhash.h \ logging.h \ diff --git a/src/common/counter/counter-api.h b/src/common/counter/counter-api.h index 3465d5dc..404ec9b5 100644 --- a/src/common/counter/counter-api.h +++ b/src/common/counter/counter-api.h @@ -16,7 +16,7 @@ #include #include #include "common/bitmap.h" -#include "lib/lttng-ust/getcpu.h" +#include "common/getcpu.h" /* * Using unsigned arithmetic because overflow is defined. diff --git a/src/lib/lttng-ust/getcpu.h b/src/common/getcpu.h similarity index 88% rename from src/lib/lttng-ust/getcpu.h rename to src/common/getcpu.h index cac34017..3bf9076a 100644 --- a/src/lib/lttng-ust/getcpu.h +++ b/src/common/getcpu.h @@ -4,8 +4,8 @@ * Copyright (C) 2011 Mathieu Desnoyers */ -#ifndef _LTTNG_GETCPU_H -#define _LTTNG_GETCPU_H +#ifndef _UST_COMMON_GETCPU_H +#define _UST_COMMON_GETCPU_H #include #include @@ -13,20 +13,16 @@ #include - -/* - * Initialize the getcpu plugin if it's present. - */ -void lttng_ust_getcpu_plugin_init(void) - __attribute__((visibility("hidden"))); - /* * Function pointer to the user provided getcpu callback, can be set at library * initialization by a dlopened plugin or at runtime by a user by calling * lttng_ust_getcpu_override() from the public API. + * + * This is an ABI symbol of liblttng-ust-common accessed by other libraries + * through the static inline function in this file. It is initialised in the + * liblttng-ust-common constructor. */ -extern int (*lttng_ust_get_cpu_sym)(void) - __attribute__((visibility("hidden"))); +extern int (*lttng_ust_get_cpu_sym)(void); #ifdef LTTNG_UST_DEBUG_VALGRIND diff --git a/src/common/ringbuffer/frontend_api.h b/src/common/ringbuffer/frontend_api.h index 36370042..879461f3 100644 --- a/src/common/ringbuffer/frontend_api.h +++ b/src/common/ringbuffer/frontend_api.h @@ -15,7 +15,7 @@ #include -#include "lib/lttng-ust/getcpu.h" +#include "common/getcpu.h" #include "frontend.h" /** diff --git a/src/lib/lttng-ust-common/Makefile.am b/src/lib/lttng-ust-common/Makefile.am index 334fc0d1..caeea2be 100644 --- a/src/lib/lttng-ust-common/Makefile.am +++ b/src/lib/lttng-ust-common/Makefile.am @@ -7,6 +7,8 @@ liblttng_ust_common_la_SOURCES = \ clock.h \ fd-tracker.c \ fd-tracker.h \ + getcpu.c \ + getcpu.h \ ust-common.c \ lttng-ust-urcu.c \ lttng-ust-urcu-pointer.c diff --git a/src/lib/lttng-ust/getcpu.c b/src/lib/lttng-ust-common/getcpu.c similarity index 96% rename from src/lib/lttng-ust/getcpu.c rename to src/lib/lttng-ust-common/getcpu.c index 149491ce..e80bcf1f 100644 --- a/src/lib/lttng-ust/getcpu.c +++ b/src/lib/lttng-ust-common/getcpu.c @@ -7,12 +7,14 @@ #define _LGPL_SOURCE #include #include -#include "common/logging.h" #include #include +#include "common/getcpu.h" #include "common/getenv.h" -#include "lib/lttng-ust/getcpu.h" +#include "common/logging.h" + +#include "lib/lttng-ust-common/getcpu.h" /* Function pointer to the current getcpu callback. */ int (*lttng_ust_get_cpu_sym)(void); diff --git a/src/lib/lttng-ust-common/getcpu.h b/src/lib/lttng-ust-common/getcpu.h new file mode 100644 index 00000000..de1d6108 --- /dev/null +++ b/src/lib/lttng-ust-common/getcpu.h @@ -0,0 +1,17 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2011 Mathieu Desnoyers + */ + +#ifndef _LTTNG_UST_COMMON_GETCPU_H +#define _LTTNG_UST_COMMON_GETCPU_H + +/* + * Initialize the getcpu plugin if it's present. + */ +void lttng_ust_getcpu_plugin_init(void) + __attribute__((visibility("hidden"))); + + +#endif /* _LTTNG_UST_COMMON_GETCPU_H */ diff --git a/src/lib/lttng-ust-common/ust-common.c b/src/lib/lttng-ust-common/ust-common.c index e6c81ba6..1aee7ac7 100644 --- a/src/lib/lttng-ust-common/ust-common.c +++ b/src/lib/lttng-ust-common/ust-common.c @@ -12,6 +12,7 @@ #include "lib/lttng-ust-common/fd-tracker.h" #include "lib/lttng-ust-common/clock.h" +#include "lib/lttng-ust-common/getcpu.h" /* * The liblttng-ust-common constructor, initialize the internal shared state. @@ -30,6 +31,11 @@ void lttng_ust_common_ctor(void) * Initialize the potential user-provided clock plugin. */ lttng_ust_clock_init(); + + /* + * Initialize the potential user-provided getcpu plugin. + */ + lttng_ust_getcpu_plugin_init(); } void lttng_ust_common_alloc_tls(void) diff --git a/src/lib/lttng-ust/Makefile.am b/src/lib/lttng-ust/Makefile.am index 752b5177..b101a81e 100644 --- a/src/lib/lttng-ust/Makefile.am +++ b/src/lib/lttng-ust/Makefile.am @@ -84,8 +84,7 @@ liblttng_ust_support_la_SOURCES = \ lttng-ring-buffer-metadata-client.c \ lttng-counter-client.h \ lttng-counter-client-percpu-32-modular.c \ - lttng-counter-client-percpu-64-modular.c \ - getcpu.c getcpu.h + lttng-counter-client-percpu-64-modular.c liblttng_ust_la_SOURCES = diff --git a/src/lib/lttng-ust/lttng-context-cpu-id.c b/src/lib/lttng-ust/lttng-context-cpu-id.c index 37e8327f..554e2c9b 100644 --- a/src/lib/lttng-ust/lttng-context-cpu-id.c +++ b/src/lib/lttng-ust/lttng-context-cpu-id.c @@ -19,9 +19,10 @@ #include #include #include -#include "lib/lttng-ust/getcpu.h" #include +#include "common/getcpu.h" + #include "context-internal.h" static diff --git a/src/lib/lttng-ust/lttng-ust-comm.c b/src/lib/lttng-ust/lttng-ust-comm.c index db9fa8d9..ff7b5939 100644 --- a/src/lib/lttng-ust/lttng-ust-comm.c +++ b/src/lib/lttng-ust/lttng-ust-comm.c @@ -51,7 +51,6 @@ #include "common/ringbuffer/rb-init.h" #include "lttng-ust-statedump.h" #include "common/clock.h" -#include "lib/lttng-ust/getcpu.h" #include "common/getenv.h" #include "lib/lttng-ust/events.h" #include "context-internal.h" @@ -2118,7 +2117,6 @@ void lttng_ust_ctor(void) lttng_ust_common_ctor(); lttng_ust_tp_init(); - lttng_ust_getcpu_plugin_init(); lttng_ust_statedump_init(); lttng_ust_ring_buffer_clients_init(); lttng_ust_counter_clients_init(); -- 2.34.1