X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fdefaults.c;fp=src%2Fcommon%2Fdefaults.c;h=ccdbaf499f0719641538ae71c415c9536aa7b9cb;hp=0000000000000000000000000000000000000000;hb=8b3bd7a32e514aae56e718491a10f582b03140c3;hpb=cf3f19ae5f634bf07dcdb771e66d40f805700a17 diff --git a/src/common/defaults.c b/src/common/defaults.c new file mode 100644 index 000000000..ccdbaf499 --- /dev/null +++ b/src/common/defaults.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2012 - Simon Marchi + * + * 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 +#include + +#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); +}