From patchwork Thu Mar 12 18:38:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11520 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2CIg0rT014092 for ; Thu, 12 Mar 2009 18:42:01 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 4D33E61A999; Thu, 12 Mar 2009 14:42:00 -0400 (EDT) Received: from int-mx2.corp.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n2CIfxE3021793 for ; Thu, 12 Mar 2009 14:41:59 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2CIfwBM021263; Thu, 12 Mar 2009 14:41:58 -0400 Received: from ether.msp.redhat.com (ether.msp.redhat.com [10.15.80.119]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2CIfvSe021026; Thu, 12 Mar 2009 14:41:57 -0400 Received: from ether.msp.redhat.com (localhost.localdomain [127.0.0.1]) by ether.msp.redhat.com (8.14.1/8.14.1) with ESMTP id n2CIcDId003019; Thu, 12 Mar 2009 13:38:13 -0500 Received: (from bmarzins@localhost) by ether.msp.redhat.com (8.14.1/8.14.1/Submit) id n2CIcD0P003018; Thu, 12 Mar 2009 13:38:13 -0500 From: Benjamin Marzinski To: dm-devel@redhat.com Date: Thu, 12 Mar 2009 13:38:12 -0500 Message-Id: <1236883093-2989-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1236883093-2989-1-git-send-email-bmarzins@redhat.com> References: <1236883093-2989-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] [PATCH 2/3] set pthread stack size to at least PTHREAD_STACK_MIN X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Attempting to set the stacksize of a pthread to below PTHREAD_STACK_MIN causes pthread_attr_setstacksize() to fail, which means that the thread will use the default stack size. This fix makes sure that multipathd never requests a stack size less than PTHREAD_STACK_MIN. Signed-off-by: Benjamin Marzinski --- libmultipath/log_pthread.c | 6 +++++- libmultipath/waiter.c | 5 ++++- multipathd/main.c | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libmultipath/log_pthread.c b/libmultipath/log_pthread.c index a1d4a10..5d2fe76 100644 --- a/libmultipath/log_pthread.c +++ b/libmultipath/log_pthread.c @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -52,6 +53,7 @@ static void * log_thread (void * et) void log_thread_start (void) { + size_t stacksize = 64 * 1024; pthread_attr_t attr; logdbg(stderr,"enter log_thread_start\n"); @@ -65,7 +67,9 @@ void log_thread_start (void) pthread_cond_init(logev_cond, NULL); pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, 64 * 1024); + if (stacksize < PTHREAD_STACK_MIN) + stacksize = PTHREAD_STACK_MIN; + pthread_attr_setstacksize(&attr, stacksize); if (log_init("multipathd", 0)) { fprintf(stderr,"can't initialize log buffer\n"); diff --git a/libmultipath/waiter.c b/libmultipath/waiter.c index 54cd19f..4d449e1 100644 --- a/libmultipath/waiter.c +++ b/libmultipath/waiter.c @@ -194,6 +194,7 @@ void *waitevent (void *et) int start_waiter_thread (struct multipath *mpp, struct vectors *vecs) { + size_t stacksize = 32 * 1024; pthread_attr_t attr; struct event_thread *wp; @@ -203,7 +204,9 @@ int start_waiter_thread (struct multipath *mpp, struct vectors *vecs) if (pthread_attr_init(&attr)) goto out; - pthread_attr_setstacksize(&attr, 32 * 1024); + if (stacksize < PTHREAD_STACK_MIN) + stacksize = PTHREAD_STACK_MIN; + pthread_attr_setstacksize(&attr, stacksize); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); wp = alloc_waiter(); diff --git a/multipathd/main.c b/multipathd/main.c index 98153df..dae9152 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1267,6 +1267,7 @@ set_oom_adj (int val) static int child (void * param) { + size_t stacksize = 64 * 1024; pthread_t check_thr, uevent_thr, uxlsnr_thr; pthread_attr_t attr; struct vectors * vecs; @@ -1347,7 +1348,9 @@ child (void * param) * start threads */ pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, 64 * 1024); + if (stacksize < PTHREAD_STACK_MIN) + stacksize = PTHREAD_STACK_MIN; + pthread_attr_setstacksize(&attr, stacksize); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_create(&check_thr, &attr, checkerloop, vecs);