Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Xen: Changelog

[xen-unstable] xenstore: set read_thread stacksize

 

 

Xen changelog RSS feed   Index | Next | Previous | View Threaded


patchbot at xen

Jun 7, 2012, 5:44 PM

Post #1 of 1 (58 views)
Permalink
[xen-unstable] xenstore: set read_thread stacksize

# HG changeset patch
# User Simon Rowe <simon.rowe [at] eu>
# Date 1339089780 -3600
# Node ID 0474a8b847622fadc20fead17c68cd3d95dc1a7f
# Parent 32a31e2cb03942f95a9453bba172e8732101761e
xenstore: set read_thread stacksize

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 [at] eu>
Acked-by: Ian Jackson <ian.jackson [at] eu>
Committed-by: Ian Jackson <ian.jackson [at] eu>
---


diff -r 32a31e2cb039 -r 0474a8b84762 tools/xenstore/xs.c
--- a/tools/xenstore/xs.c Thu Jun 07 18:22:20 2012 +0100
+++ b/tools/xenstore/xs.c Thu Jun 07 18:23:00 2012 +0100
@@ -702,21 +702,36 @@ bool xs_watch(struct xs_handle *h, const
struct iovec iov[2];

#ifdef USE_PTHREAD
+#define READ_THREAD_STACKSIZE (16 * 1024)
+
/* We dynamically create a reader thread on demand. */
mutex_lock(&h->request_mutex);
if (!h->read_thr_exists) {
sigset_t set, old_set;
+ pthread_attr_t attr;
+
+ if (pthread_attr_init(&attr) != 0) {
+ mutex_unlock(&h->request_mutex);
+ return false;
+ }
+ if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
+ pthread_attr_destroy(&attr);
+ mutex_unlock(&h->request_mutex);
+ return false;
+ }

sigfillset(&set);
pthread_sigmask(SIG_SETMASK, &set, &old_set);

- if (pthread_create(&h->read_thr, NULL, read_thread, h) != 0) {
+ if (pthread_create(&h->read_thr, &attr, read_thread, h) != 0) {
pthread_sigmask(SIG_SETMASK, &old_set, NULL);
+ pthread_attr_destroy(&attr);
mutex_unlock(&h->request_mutex);
return false;
}
h->read_thr_exists = 1;
pthread_sigmask(SIG_SETMASK, &old_set, NULL);
+ pthread_attr_destroy(&attr);
}
mutex_unlock(&h->request_mutex);
#endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog [at] lists
http://lists.xensource.com/xen-changelog

Xen changelog RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.