Add default subbuf sizes getter functions
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 13 Nov 2012 19:28:42 +0000 (14:28 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Fri, 7 Dec 2012 20:17:55 +0000 (15:17 -0500)
commit 8b3bd7a32e514aae56e718491a10f582b03140c3 upstream.

This patch adds functions to retrieve defaults subbuf sizes. It uses the
DEFAULT_*_SUBBUF_SIZE defines from defaults.h but also make sure that
the values are at least as big as the page size.

The functions are defined as static inline in defaults.h.

[ Edit by Christian Babeux: Resolved conflict in src/common/Makefile.am
  and src/common/defaults.h ]

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
src/common/Makefile.am
src/common/defaults.c [new file with mode: 0644]
src/common/defaults.h

index 5d79210b802819cd07e14e5b11338c16acfdca09..aec064c0459decc7fedb4e061570ef6f0817897b 100644 (file)
@@ -8,7 +8,7 @@ noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h
 
 noinst_LTLIBRARIES = libcommon.la
 
-libcommon_la_SOURCES = runas.c runas.h common.h
+libcommon_la_SOURCES = runas.c runas.h common.h defaults.c
 
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
diff --git a/src/common/defaults.c b/src/common/defaults.c
new file mode 100644 (file)
index 0000000..ccdbaf4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 - Simon Marchi <simon.marchi@polymtl.ca>
+ *
+ * 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.
+ */
+
+#include <stddef.h>
+#include <unistd.h>
+
+#include "defaults.h"
+#include "macros.h"
+
+size_t default_channel_subbuf_size;
+size_t default_metadata_subbuf_size;
+size_t default_kernel_channel_subbuf_size;
+size_t default_ust_channel_subbuf_size;
+
+static void __attribute__((constructor)) init_defaults(void)
+{
+       /*
+        * The libringbuffer won't accept subbuf sizes smaller than the page size.
+        * If the default subbuf size is smaller, replace it by the page size.
+        */
+       long page_size = sysconf(_SC_PAGESIZE);
+
+       if (page_size < 0) {
+               page_size = 0;
+       }
+
+       default_channel_subbuf_size =
+               max(DEFAULT_CHANNEL_SUBBUF_SIZE, page_size);
+       default_metadata_subbuf_size =
+               max(DEFAULT_METADATA_SUBBUF_SIZE, page_size);
+       default_kernel_channel_subbuf_size =
+               max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, page_size);
+       default_ust_channel_subbuf_size =
+               max(DEFAULT_UST_CHANNEL_SUBBUF_SIZE, page_size);
+}
index 5ee6562d91906b01b54b7909b7148a704f9dc9ce..a032ef444afd424f127595fd3d932eb8400e8081 100644 (file)
  */
 #define DEFAULT_SEM_WAIT_TIMEOUT            30    /* in seconds */
 
+extern size_t default_channel_subbuf_size;
+extern size_t default_metadata_subbuf_size;
+extern size_t default_ust_channel_subbuf_size;
+extern size_t default_kernel_channel_subbuf_size;
+
+
+/*
+ * Returns the default subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+static inline
+size_t default_get_channel_subbuf_size(void)
+{
+       return default_channel_subbuf_size;
+}
+
+/*
+ * Returns the default metadata subbuf size.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+static inline
+size_t default_get_metadata_subbuf_size(void)
+{
+       return default_metadata_subbuf_size;
+}
+
+/*
+ * Returns the default subbuf size for the kernel domain.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+static inline
+size_t default_get_kernel_channel_subbuf_size(void)
+{
+       return default_kernel_channel_subbuf_size;
+}
+
+/*
+ * Returns the default subbuf size for the UST domain.
+ *
+ * This function depends on a value that is set at constructor time, so it is
+ * unsafe to call it from another constructor.
+ */
+static inline
+size_t default_get_ust_channel_subbuf_size(void)
+{
+       return default_ust_channel_subbuf_size;
+}
+
 #endif /* _DEFAULTS_H */
This page took 0.026901 seconds and 4 git commands to generate.