From 0baa249d8b59007913dbf7db8aa8d94e6c2b9d44 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 25 Mar 2020 20:48:02 +0100 Subject: shm: make max pool size user configurable (via a 'tweak' setting) --- config.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index 80163e2e..16831248 100644 --- a/config.c +++ b/config.c @@ -22,6 +22,7 @@ #include "wayland.h" #define ALEN(v) (sizeof(v) / sizeof(v[0])) +#define min(x, y) ((x) < (y) ? (x) : (y)) static const uint32_t default_foreground = 0xdcdccc; static const uint32_t default_background = 0x111111; @@ -621,6 +622,18 @@ parse_section_tweak( LOG_WARN("tweak: delayed-render-upper=%lu", ns); } + else if (strcmp(key, "max-shm-pool-size-mb") == 0) { + unsigned long mb; + if (!str_to_ulong(value, 10, &mb)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + + conf->tweak.max_shm_pool_size = min(mb * 1024 * 1024, INT32_MAX); + LOG_WARN("tweak: max-shm-pool-size=%lu bytes", + conf->tweak.max_shm_pool_size); + } + else { LOG_ERR("%s:%u: invalid key: %s", path, lineno, key); return false; @@ -890,6 +903,7 @@ config_load(struct config *conf, const char *conf_path) .tweak = { .delayed_render_lower_ns = 500000, /* 0.5ms */ .delayed_render_upper_ns = 16666666 / 2, /* half a frame period (60Hz) */ + .max_shm_pool_size = 512 * 1024 * 1024, }, }; -- cgit v1.3