X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fdefaults.c;h=2550784cf1b01cf834f695e51e16c3cadf58d7a7;hb=3afa94aeca5a0daae40fd7b6cc96b7e4c150c7d8;hp=a39f1885c73f31c75770bd4dae69eb08cbd286f0;hpb=b38afa27d40eaec3c632cbcd3a9f8421f8cea65d;p=lttng-tools.git diff --git a/src/common/defaults.c b/src/common/defaults.c index a39f1885c..2550784cf 100644 --- a/src/common/defaults.c +++ b/src/common/defaults.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2012 - Simon Marchi + * 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. + * SPDX-License-Identifier: GPL-2.0-only * - * 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. */ #define _LGPL_SOURCE @@ -24,43 +14,51 @@ #include "defaults.h" #include "macros.h" -#include "align.h" #include "error.h" static int pthread_attr_init_done; static pthread_attr_t tattr; -LTTNG_HIDDEN +static size_t get_page_size(void) +{ + const long ret = sysconf(_SC_PAGE_SIZE); + + if (ret < 0) { + /* + * Fatal error since there is no safe way to recover from this. + */ + PERROR("Failed to get system page size using sysconf(_SC_PAGE_SIZE)"); + abort(); + } + + return (size_t) ret; +} + size_t default_get_channel_subbuf_size(void) { - return max(_DEFAULT_CHANNEL_SUBBUF_SIZE, PAGE_SIZE); + return max(_DEFAULT_CHANNEL_SUBBUF_SIZE, get_page_size()); } -LTTNG_HIDDEN size_t default_get_metadata_subbuf_size(void) { - return max(DEFAULT_METADATA_SUBBUF_SIZE, PAGE_SIZE); + return max(DEFAULT_METADATA_SUBBUF_SIZE, get_page_size()); } -LTTNG_HIDDEN size_t default_get_kernel_channel_subbuf_size(void) { - return max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, PAGE_SIZE); + return max(DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE, get_page_size()); } -LTTNG_HIDDEN size_t default_get_ust_pid_channel_subbuf_size(void) { - return max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, PAGE_SIZE); + return max(DEFAULT_UST_PID_CHANNEL_SUBBUF_SIZE, get_page_size()); } -LTTNG_HIDDEN size_t default_get_ust_uid_channel_subbuf_size(void) { - return max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, PAGE_SIZE); + return max(DEFAULT_UST_UID_CHANNEL_SUBBUF_SIZE, get_page_size()); } -LTTNG_HIDDEN pthread_attr_t *default_pthread_attr(void) { if (pthread_attr_init_done) { @@ -117,8 +115,8 @@ static void __attribute__((constructor)) init_default_pthread_attr(void) selected_ss = DEFAULT_LTTNG_THREAD_STACK_SIZE; } - if (rlim.rlim_max >= 0 && selected_ss > rlim.rlim_max) { - WARN("Your system's stack size restrictions (%zu bytes) may be too low for the LTTng daemons to function properly, please set the stack size limit to at leat %zu bytes to ensure reliable operation", + if (rlim.rlim_max > 0 && selected_ss > rlim.rlim_max) { + WARN("Your system's stack size restrictions (%zu bytes) may be too low for the LTTng daemons to function properly, please set the stack size limit to at least %zu bytes to ensure reliable operation", (size_t) rlim.rlim_max, (size_t) DEFAULT_LTTNG_THREAD_STACK_SIZE); selected_ss = (size_t) rlim.rlim_max; }