From 80957876b66b7b666a01680a4f5f44f81a79063b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 25 May 2017 05:15:52 -0400 Subject: [PATCH] Tests: add consumer testpoint to pause data consumption MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-consumerd/Makefile.am | 2 ++ src/bin/lttng-consumerd/testpoint.h | 26 ++++++++++++++++++++++++++ src/common/consumer/consumer.c | 7 +++++++ 3 files changed, 35 insertions(+) create mode 100644 src/bin/lttng-consumerd/testpoint.h diff --git a/src/bin/lttng-consumerd/Makefile.am b/src/bin/lttng-consumerd/Makefile.am index acb8d7d44..b7401de88 100644 --- a/src/bin/lttng-consumerd/Makefile.am +++ b/src/bin/lttng-consumerd/Makefile.am @@ -15,6 +15,8 @@ lttng_consumerd_LDADD = \ $(top_builddir)/src/common/health/libhealth.la \ $(top_builddir)/src/common/testpoint/libtestpoint.la +lttng_consumerd_LDFLAGS = -rdynamic + if HAVE_LIBLTTNG_UST_CTL lttng_consumerd_LDADD += -llttng-ust-ctl endif diff --git a/src/bin/lttng-consumerd/testpoint.h b/src/bin/lttng-consumerd/testpoint.h new file mode 100644 index 000000000..5836d823c --- /dev/null +++ b/src/bin/lttng-consumerd/testpoint.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2017 - Jérémie Galarneau + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License, version 2 only, as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef CONSUMERD_TESTPOINT_H +#define CONSUMERD_TESTPOINT_H + +#include + +/* Testpoints, internal use only */ +TESTPOINT_DECL(consumerd_data_thread_poll); + +#endif /* CONSUMERD_TESTPOINT_H */ diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c index b2feb3945..d07e5b492 100644 --- a/src/common/consumer/consumer.c +++ b/src/common/consumer/consumer.c @@ -67,6 +67,7 @@ struct consumer_channel_msg { uint64_t key; /* del */ }; +/* Flag used to temporarily pause data consumption from testpoints. */ int data_consumption_paused; /* @@ -2554,6 +2555,12 @@ void *consumer_thread_data_poll(void *data) goto end; } + if (caa_unlikely(data_consumption_paused)) { + DBG("Data consumption paused, sleeping..."); + sleep(1); + goto restart; + } + /* * If the consumer_data_pipe triggered poll go directly to the * beginning of the loop to update the array. We want to prioritize -- 2.34.1