mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
Merge pull request #10334 from keszybz/nomempool
Use mempool only in progs linked to libsystemd-shared.so
This commit is contained in:
commit
960d4b29d7
@ -166,7 +166,8 @@ foreach tuple : xsltproc.found() ? [['systemd.directives', '7', systemd_directiv
|
||||
html_pages += p3
|
||||
endforeach
|
||||
|
||||
# cannot use run_target until https://github.com/mesonbuild/meson/issues/1644 is resolved
|
||||
# Cannot use run_target because those targets are used in depends
|
||||
# Also see https://github.com/mesonbuild/meson/issues/368.
|
||||
man = custom_target(
|
||||
'man',
|
||||
output : 'man',
|
||||
|
13
meson.build
13
meson.build
@ -1383,7 +1383,7 @@ libjournal_core = static_library(
|
||||
libsystemd_sym_path = '@0@/@1@'.format(meson.current_source_dir(), libsystemd_sym)
|
||||
libsystemd = shared_library(
|
||||
'systemd',
|
||||
'src/systemd/sd-id128.h', # pick a header file at random to work around old meson bug
|
||||
disable_mempool_c,
|
||||
version : libsystemd_version,
|
||||
include_directories : includes,
|
||||
link_args : ['-shared',
|
||||
@ -1465,6 +1465,7 @@ subdir('test')
|
||||
test_dlopen = executable(
|
||||
'test-dlopen',
|
||||
test_dlopen_c,
|
||||
disable_mempool_c,
|
||||
include_directories : includes,
|
||||
link_with : [libbasic],
|
||||
dependencies : [libdl],
|
||||
@ -1485,6 +1486,7 @@ foreach tuple : [['myhostname', 'ENABLE_NSS_MYHOSTNAME'],
|
||||
nss = shared_library(
|
||||
'nss_' + module,
|
||||
'src/nss-@0@/nss-@0@.c'.format(module),
|
||||
disable_mempool_c,
|
||||
version : '2',
|
||||
include_directories : includes,
|
||||
# Note that we link NSS modules with '-z nodelete' so that mempools never get orphaned
|
||||
@ -2782,12 +2784,9 @@ subdir('shell-completion/zsh')
|
||||
subdir('docs/sysvinit')
|
||||
subdir('docs/var-log')
|
||||
|
||||
# FIXME: figure out if the warning is true:
|
||||
# https://github.com/mesonbuild/meson/wiki/Reference-manual#install_subdir
|
||||
install_subdir('factory/etc',
|
||||
install_dir : factorydir)
|
||||
|
||||
|
||||
install_data('xorg/50-systemd-user.sh',
|
||||
install_dir : xinitrcdir)
|
||||
install_data('modprobe.d/systemd.conf',
|
||||
@ -2984,6 +2983,10 @@ alt_time_epoch = run_command('date', '-Is', '-u', '-d',
|
||||
status += [
|
||||
'time epoch: @0@ (@1@)'.format(time_epoch, alt_time_epoch)]
|
||||
|
||||
status += [
|
||||
'static libsystemd: @0@'.format(static_libsystemd),
|
||||
'static libudev: @0@'.format(static_libudev)]
|
||||
|
||||
# TODO:
|
||||
# CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
|
||||
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
|
||||
@ -3083,6 +3086,8 @@ foreach tuple : [
|
||||
['debug mmap cache'],
|
||||
['valgrind', conf.get('VALGRIND') == 1],
|
||||
['trace logging', conf.get('LOG_TRACE') == 1],
|
||||
['link-udev-shared', get_option('link-udev-shared')],
|
||||
['link-systemctl-shared', get_option('link-systemctl-shared')],
|
||||
]
|
||||
|
||||
if tuple.length() >= 2
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-util.h"
|
||||
#include "fileio.h"
|
||||
#include "hashmap.h"
|
||||
#include "macro.h"
|
||||
@ -767,24 +766,12 @@ static void reset_direct_storage(HashmapBase *h) {
|
||||
memset(p, DIB_RAW_INIT, sizeof(dib_raw_t) * hi->n_direct_buckets);
|
||||
}
|
||||
|
||||
static bool use_pool(void) {
|
||||
static int b = -1;
|
||||
|
||||
if (!is_main_thread())
|
||||
return false;
|
||||
|
||||
if (b < 0)
|
||||
b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static struct HashmapBase *hashmap_base_new(const struct hash_ops *hash_ops, enum HashmapType type HASHMAP_DEBUG_PARAMS) {
|
||||
HashmapBase *h;
|
||||
const struct hashmap_type_info *hi = &hashmap_type_info[type];
|
||||
bool up;
|
||||
|
||||
up = use_pool();
|
||||
up = mempool_enabled();
|
||||
|
||||
h = up ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
|
||||
if (!h)
|
||||
|
@ -3,8 +3,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "env-util.h"
|
||||
#include "macro.h"
|
||||
#include "mempool.h"
|
||||
#include "process-util.h"
|
||||
#include "util.h"
|
||||
|
||||
struct pool {
|
||||
@ -70,8 +72,21 @@ void mempool_free_tile(struct mempool *mp, void *p) {
|
||||
mp->freelist = p;
|
||||
}
|
||||
|
||||
#if VALGRIND
|
||||
bool mempool_enabled(void) {
|
||||
static int b = -1;
|
||||
|
||||
if (!is_main_thread())
|
||||
return false;
|
||||
|
||||
if (!mempool_use_allowed)
|
||||
b = false;
|
||||
if (b < 0)
|
||||
b = getenv_bool("SYSTEMD_MEMPOOL") != 0;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
#if VALGRIND
|
||||
void mempool_drop(struct mempool *mp) {
|
||||
struct pool *p = mp->first_pool;
|
||||
while (p) {
|
||||
@ -81,5 +96,4 @@ void mempool_drop(struct mempool *mp) {
|
||||
p = n;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct pool;
|
||||
@ -22,6 +23,9 @@ static struct mempool pool_name = { \
|
||||
.at_least = alloc_at_least, \
|
||||
}
|
||||
|
||||
extern const bool mempool_use_allowed;
|
||||
bool mempool_enabled(void);
|
||||
|
||||
#if VALGRIND
|
||||
void mempool_drop(struct mempool *mp);
|
||||
#endif
|
||||
|
5
src/libsystemd/disable-mempool.c
Normal file
5
src/libsystemd/disable-mempool.c
Normal file
@ -0,0 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "mempool.h"
|
||||
|
||||
const bool mempool_use_allowed = false;
|
@ -81,6 +81,8 @@ libsystemd_sources = files('''
|
||||
sd-utf8/sd-utf8.c
|
||||
'''.split()) + id128_sources + sd_daemon_c + sd_event_c + sd_login_c
|
||||
|
||||
disable_mempool_c = files('disable-mempool.c')
|
||||
|
||||
libsystemd_c_args = ['-fvisibility=default']
|
||||
|
||||
libsystemd_static = static_library(
|
||||
|
5
src/shared/enable-mempool.c
Normal file
5
src/shared/enable-mempool.c
Normal file
@ -0,0 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1+ */
|
||||
|
||||
#include "mempool.h"
|
||||
|
||||
const bool mempool_use_allowed = true;
|
@ -36,6 +36,7 @@ shared_sources = files('''
|
||||
dropin.h
|
||||
efivars.c
|
||||
efivars.h
|
||||
enable-mempool.c
|
||||
fdset.c
|
||||
fdset.h
|
||||
firewall-util.h
|
||||
|
Loading…
Reference in New Issue
Block a user