From 2a9eda1229c9d5d7150acdd3d8dd4908fbc784a8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 11 Feb 2017 18:14:00 +0100 Subject: [PATCH] mem: add extra mem pages for pthread stack Some archs can use even 64K pages and then lvm2 runs into trouble if the stack is 'too small' to fit extra page capturing stack overwrite. So when lvm2 limits stack - add extra mem page - be it 4K or 64K. Relates to ppc64le bug: https://bugzilla.redhat.com/1387279 --- WHATS_NEW | 1 + WHATS_NEW_DM | 1 + daemons/clvmd/clvmd.c | 2 +- daemons/dmeventd/dmeventd.c | 2 +- libdaemon/server/daemon-server.c | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e5f1ba184..b497c7eb9 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.169 - ===================================== + Add extra memory page when limiting pthread stack size in clvmd. Support striped/raid0* <-> raid10_near conversions Support shrinking of RaidLvs Support region size changes on existing RaidLVs diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 47f647a6a..f11b28c7b 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.138 - ===================================== + Add extra memory page when limiting pthread stack size in dmeventd. Avoids immediate resume when preloaded device is smaller. Do not suppress kernel key description in dmsetup table output. Support configurable command executed from dmeventd thin plugin. diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index a276c63eb..dcc986ba6 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -517,7 +517,7 @@ int main(int argc, char *argv[]) /* Initialise the LVM thread variables */ dm_list_init(&lvm_cmd_head); if (pthread_attr_init(&stack_attr) || - pthread_attr_setstacksize(&stack_attr, STACK_SIZE)) { + pthread_attr_setstacksize(&stack_attr, STACK_SIZE + getpagesize())) { log_sys_error("pthread_attr_init", ""); exit(1); } diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index 58922ac84..a2883a1ff 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -468,7 +468,7 @@ static int _pthread_create_smallstack(pthread_t *t, void *(*fun)(void *), void * /* * We use a smaller stack since it gets preallocated in its entirety */ - pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE); + pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE + getpagesize()); /* * If no-one will be waiting, we need to detach. diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c index 6af6de99b..10cc8f747 100644 --- a/libdaemon/server/daemon-server.c +++ b/libdaemon/server/daemon-server.c @@ -42,7 +42,7 @@ static int _pthread_create(pthread_t *t, void *(*fun)(void *), void *arg, int st /* * We use a smaller stack since it gets preallocated in its entirety */ - pthread_attr_setstacksize(&attr, stacksize); + pthread_attr_setstacksize(&attr, stacksize + getpagesize()); return pthread_create(t, &attr, fun, arg); } #endif