All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xs: set read_thread stacksize
@ 2012-05-29 15:56 Simon Rowe
  2012-05-29 16:39 ` David Vrabel
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Rowe @ 2012-05-29 15:56 UTC (permalink / raw)
  To: xen-devel; +Cc: simon.rowe

xs_watch() creates a thread to wake watchers using default attributes. The
stacksize can be quite large (8 MB on Linux), applications that link against
xenstore end up having a larger memory footprint than necessary.

Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>

diff -r 53e0571f94e4 -r 0cf61ed6ce86 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c	Fri May 25 08:21:25 2012 +0100
+++ b/tools/xenstore/xs.c	Tue May 29 16:45:03 2012 +0100
@@ -705,11 +705,31 @@ bool xs_watch(struct xs_handle *h, const
 	/* We dynamically create a reader thread on demand. */
 	mutex_lock(&h->request_mutex);
 	if (!h->read_thr_exists) {
+#if _POSIX_THREAD_ATTR_STACKSIZE > 0
+		pthread_attr_t attr;
+
+		if (pthread_attr_init(&attr) != 0) {
+			mutex_unlock(&h->request_mutex);
+			return false;
+		}
+		if (pthread_attr_setstacksize(&attr, 16 * 1024) != 0) {
+			pthread_attr_destroy(&attr);
+			mutex_unlock(&h->request_mutex);
+			return false;
+		}
+
+		if (pthread_create(&h->read_thr, &attr, read_thread, h) != 0) {
+			pthread_attr_destroy(&attr);
+#else
 		if (pthread_create(&h->read_thr, NULL, read_thread, h) != 0) {
+#endif
 			mutex_unlock(&h->request_mutex);
 			return false;
 		}
 		h->read_thr_exists = 1;
+#if _POSIX_THREAD_ATTR_STACKSIZE > 0
+		pthread_attr_destroy(&attr);
+#endif
 	}
 	mutex_unlock(&h->request_mutex);
 #endif

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-06-21 17:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-29 15:56 [PATCH] xs: set read_thread stacksize Simon Rowe
2012-05-29 16:39 ` David Vrabel
2012-05-29 19:39   ` Ian Campbell
2012-05-30  7:56     ` Simon Rowe
2012-05-30  9:40       ` Ian Campbell
2012-05-30 12:10         ` Simon Rowe
2012-05-31  7:32           ` Ian Campbell
2012-06-21  9:09             ` Roger Pau Monne
2012-06-21  9:18               ` Ian Campbell
2012-06-21  9:39                 ` Roger Pau Monne
2012-06-21 10:18                   ` Ian Campbell
2012-06-21 10:27                     ` Roger Pau Monne
2012-06-21 10:32                       ` Ian Campbell
2012-06-21 17:19               ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.