* [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
@ 2018-02-22 13:53 Juergen Gross
2018-02-22 17:28 ` Wei Liu
2018-02-24 1:22 ` Jim Fehlig
0 siblings, 2 replies; 8+ messages in thread
From: Juergen Gross @ 2018-02-22 13:53 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, wei.liu2, jfehlig, ian.jackson
When creating a pthread in xs_watch() try to get the minimal needed
size of the thread from glibc instead of using a constant. This avoids
problems when the library is used in programs with large per-thread
memory.
Use dlsym() to get the pointer to __pthread_get_minstack() in order to
avoid linkage problems and fall back to the current constant size if
not found.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
Only compile tested. Jim, can you please verify this patch is solving
your original problem?
---
tools/xenstore/Makefile | 4 ++++
tools/xenstore/xs.c | 19 ++++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 2b99d2bc1b..fb6c73e297 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
ln -sf $< $@
xs.opic: CFLAGS += -DUSE_PTHREAD
+ifeq ($(CONFIG_Linux),y)
+xs.opic: CFLAGS += -DUSE_DLSYM
+xs.opic: LDFLAGS += -ldl
+endif
libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index abffd9cd80..8372f5b1a4 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -47,6 +47,11 @@ struct xs_stored_msg {
#include <pthread.h>
+#ifdef USE_DLSYM
+#define __USE_GNU
+#include <dlfcn.h>
+#endif
+
struct xs_handle {
/* Communications channel to xenstore daemon. */
int fd;
@@ -810,12 +815,24 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
if (!h->read_thr_exists) {
sigset_t set, old_set;
pthread_attr_t attr;
+ static size_t stack_size;
+#ifdef USE_DLSYM
+ size_t (*getsz)(void);
+#endif
+ if (!stack_size) {
+#ifdef USE_DLSYM
+ getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
+ stack_size = getsz ? getsz() : READ_THREAD_STACKSIZE;
+#else
+ stack_size = READ_THREAD_STACKSIZE;
+#endif
+ }
if (pthread_attr_init(&attr) != 0) {
mutex_unlock(&h->request_mutex);
return false;
}
- if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
+ if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
pthread_attr_destroy(&attr);
mutex_unlock(&h->request_mutex);
return false;
--
2.13.6
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 13:53 [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
@ 2018-02-22 17:28 ` Wei Liu
2018-02-22 18:44 ` Juergen Gross
2018-02-24 1:22 ` Jim Fehlig
1 sibling, 1 reply; 8+ messages in thread
From: Wei Liu @ 2018-02-22 17:28 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, jfehlig, ian.jackson, wei.liu2
On Thu, Feb 22, 2018 at 02:53:35PM +0100, Juergen Gross wrote:
> When creating a pthread in xs_watch() try to get the minimal needed
> size of the thread from glibc instead of using a constant. This avoids
> problems when the library is used in programs with large per-thread
> memory.
>
> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
> avoid linkage problems and fall back to the current constant size if
> not found.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> Only compile tested. Jim, can you please verify this patch is solving
> your original problem?
> ---
> tools/xenstore/Makefile | 4 ++++
> tools/xenstore/xs.c | 19 ++++++++++++++++++-
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> index 2b99d2bc1b..fb6c73e297 100644
> --- a/tools/xenstore/Makefile
> +++ b/tools/xenstore/Makefile
> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
> ln -sf $< $@
>
> xs.opic: CFLAGS += -DUSE_PTHREAD
> +ifeq ($(CONFIG_Linux),y)
> +xs.opic: CFLAGS += -DUSE_DLSYM
> +xs.opic: LDFLAGS += -ldl
> +endif
>
> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
> index abffd9cd80..8372f5b1a4 100644
> --- a/tools/xenstore/xs.c
> +++ b/tools/xenstore/xs.c
> @@ -47,6 +47,11 @@ struct xs_stored_msg {
>
> #include <pthread.h>
>
> +#ifdef USE_DLSYM
> +#define __USE_GNU
Where does this come from? DLSYM(3) says _GNU_SOURCE (which we already
have).
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 17:28 ` Wei Liu
@ 2018-02-22 18:44 ` Juergen Gross
2018-02-22 18:53 ` Wei Liu
0 siblings, 1 reply; 8+ messages in thread
From: Juergen Gross @ 2018-02-22 18:44 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, jfehlig, ian.jackson
On 22/02/18 18:28, Wei Liu wrote:
> On Thu, Feb 22, 2018 at 02:53:35PM +0100, Juergen Gross wrote:
>> When creating a pthread in xs_watch() try to get the minimal needed
>> size of the thread from glibc instead of using a constant. This avoids
>> problems when the library is used in programs with large per-thread
>> memory.
>>
>> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
>> avoid linkage problems and fall back to the current constant size if
>> not found.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> Only compile tested. Jim, can you please verify this patch is solving
>> your original problem?
>> ---
>> tools/xenstore/Makefile | 4 ++++
>> tools/xenstore/xs.c | 19 ++++++++++++++++++-
>> 2 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>> index 2b99d2bc1b..fb6c73e297 100644
>> --- a/tools/xenstore/Makefile
>> +++ b/tools/xenstore/Makefile
>> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
>> ln -sf $< $@
>>
>> xs.opic: CFLAGS += -DUSE_PTHREAD
>> +ifeq ($(CONFIG_Linux),y)
>> +xs.opic: CFLAGS += -DUSE_DLSYM
>> +xs.opic: LDFLAGS += -ldl
>> +endif
>>
>> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
>> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
>> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
>> index abffd9cd80..8372f5b1a4 100644
>> --- a/tools/xenstore/xs.c
>> +++ b/tools/xenstore/xs.c
>> @@ -47,6 +47,11 @@ struct xs_stored_msg {
>>
>> #include <pthread.h>
>>
>> +#ifdef USE_DLSYM
>> +#define __USE_GNU
>
> Where does this come from? DLSYM(3) says _GNU_SOURCE (which we already
> have).
On my machine build failed, so I looked into the header...
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 18:44 ` Juergen Gross
@ 2018-02-22 18:53 ` Wei Liu
2018-02-22 18:55 ` Wei Liu
0 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2018-02-22 18:53 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, jfehlig, Wei Liu, ian.jackson
On Thu, Feb 22, 2018 at 07:44:22PM +0100, Juergen Gross wrote:
> On 22/02/18 18:28, Wei Liu wrote:
> > On Thu, Feb 22, 2018 at 02:53:35PM +0100, Juergen Gross wrote:
> >> When creating a pthread in xs_watch() try to get the minimal needed
> >> size of the thread from glibc instead of using a constant. This avoids
> >> problems when the library is used in programs with large per-thread
> >> memory.
> >>
> >> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
> >> avoid linkage problems and fall back to the current constant size if
> >> not found.
> >>
> >> Signed-off-by: Juergen Gross <jgross@suse.com>
> >> ---
> >> Only compile tested. Jim, can you please verify this patch is solving
> >> your original problem?
> >> ---
> >> tools/xenstore/Makefile | 4 ++++
> >> tools/xenstore/xs.c | 19 ++++++++++++++++++-
> >> 2 files changed, 22 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> >> index 2b99d2bc1b..fb6c73e297 100644
> >> --- a/tools/xenstore/Makefile
> >> +++ b/tools/xenstore/Makefile
> >> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
> >> ln -sf $< $@
> >>
> >> xs.opic: CFLAGS += -DUSE_PTHREAD
> >> +ifeq ($(CONFIG_Linux),y)
> >> +xs.opic: CFLAGS += -DUSE_DLSYM
> >> +xs.opic: LDFLAGS += -ldl
> >> +endif
> >>
> >> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
> >> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
> >> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
> >> index abffd9cd80..8372f5b1a4 100644
> >> --- a/tools/xenstore/xs.c
> >> +++ b/tools/xenstore/xs.c
> >> @@ -47,6 +47,11 @@ struct xs_stored_msg {
> >>
> >> #include <pthread.h>
> >>
> >> +#ifdef USE_DLSYM
> >> +#define __USE_GNU
> >
> > Where does this come from? DLSYM(3) says _GNU_SOURCE (which we already
> > have).
>
> On my machine build failed, so I looked into the header...
>
Does putting _GNU_SOURCE at the beginning of that file before all
headers solve the issue? I don't think we want to use an internal
definition.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 18:53 ` Wei Liu
@ 2018-02-22 18:55 ` Wei Liu
2018-02-22 19:12 ` Juergen Gross
0 siblings, 1 reply; 8+ messages in thread
From: Wei Liu @ 2018-02-22 18:55 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, jfehlig, Wei Liu, ian.jackson
On Thu, Feb 22, 2018 at 06:53:28PM +0000, Wei Liu wrote:
> On Thu, Feb 22, 2018 at 07:44:22PM +0100, Juergen Gross wrote:
> > On 22/02/18 18:28, Wei Liu wrote:
> > > On Thu, Feb 22, 2018 at 02:53:35PM +0100, Juergen Gross wrote:
> > >> When creating a pthread in xs_watch() try to get the minimal needed
> > >> size of the thread from glibc instead of using a constant. This avoids
> > >> problems when the library is used in programs with large per-thread
> > >> memory.
> > >>
> > >> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
> > >> avoid linkage problems and fall back to the current constant size if
> > >> not found.
> > >>
> > >> Signed-off-by: Juergen Gross <jgross@suse.com>
> > >> ---
> > >> Only compile tested. Jim, can you please verify this patch is solving
> > >> your original problem?
> > >> ---
> > >> tools/xenstore/Makefile | 4 ++++
> > >> tools/xenstore/xs.c | 19 ++++++++++++++++++-
> > >> 2 files changed, 22 insertions(+), 1 deletion(-)
> > >>
> > >> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> > >> index 2b99d2bc1b..fb6c73e297 100644
> > >> --- a/tools/xenstore/Makefile
> > >> +++ b/tools/xenstore/Makefile
> > >> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
> > >> ln -sf $< $@
> > >>
> > >> xs.opic: CFLAGS += -DUSE_PTHREAD
> > >> +ifeq ($(CONFIG_Linux),y)
> > >> +xs.opic: CFLAGS += -DUSE_DLSYM
> > >> +xs.opic: LDFLAGS += -ldl
> > >> +endif
> > >>
> > >> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
> > >> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
> > >> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
> > >> index abffd9cd80..8372f5b1a4 100644
> > >> --- a/tools/xenstore/xs.c
> > >> +++ b/tools/xenstore/xs.c
> > >> @@ -47,6 +47,11 @@ struct xs_stored_msg {
> > >>
> > >> #include <pthread.h>
> > >>
> > >> +#ifdef USE_DLSYM
> > >> +#define __USE_GNU
> > >
> > > Where does this come from? DLSYM(3) says _GNU_SOURCE (which we already
> > > have).
> >
> > On my machine build failed, so I looked into the header...
> >
>
> Does putting _GNU_SOURCE at the beginning of that file before all
> headers solve the issue? I don't think we want to use an internal
> definition.
And I was wrong about "we already have _GNU_SOURCE" bit in my previous
email. At least not in the file you modified.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 18:55 ` Wei Liu
@ 2018-02-22 19:12 ` Juergen Gross
0 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2018-02-22 19:12 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, jfehlig, ian.jackson
On 22/02/18 19:55, Wei Liu wrote:
> On Thu, Feb 22, 2018 at 06:53:28PM +0000, Wei Liu wrote:
>> On Thu, Feb 22, 2018 at 07:44:22PM +0100, Juergen Gross wrote:
>>> On 22/02/18 18:28, Wei Liu wrote:
>>>> On Thu, Feb 22, 2018 at 02:53:35PM +0100, Juergen Gross wrote:
>>>>> When creating a pthread in xs_watch() try to get the minimal needed
>>>>> size of the thread from glibc instead of using a constant. This avoids
>>>>> problems when the library is used in programs with large per-thread
>>>>> memory.
>>>>>
>>>>> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
>>>>> avoid linkage problems and fall back to the current constant size if
>>>>> not found.
>>>>>
>>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>>> ---
>>>>> Only compile tested. Jim, can you please verify this patch is solving
>>>>> your original problem?
>>>>> ---
>>>>> tools/xenstore/Makefile | 4 ++++
>>>>> tools/xenstore/xs.c | 19 ++++++++++++++++++-
>>>>> 2 files changed, 22 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>>>>> index 2b99d2bc1b..fb6c73e297 100644
>>>>> --- a/tools/xenstore/Makefile
>>>>> +++ b/tools/xenstore/Makefile
>>>>> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
>>>>> ln -sf $< $@
>>>>>
>>>>> xs.opic: CFLAGS += -DUSE_PTHREAD
>>>>> +ifeq ($(CONFIG_Linux),y)
>>>>> +xs.opic: CFLAGS += -DUSE_DLSYM
>>>>> +xs.opic: LDFLAGS += -ldl
>>>>> +endif
>>>>>
>>>>> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
>>>>> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
>>>>> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
>>>>> index abffd9cd80..8372f5b1a4 100644
>>>>> --- a/tools/xenstore/xs.c
>>>>> +++ b/tools/xenstore/xs.c
>>>>> @@ -47,6 +47,11 @@ struct xs_stored_msg {
>>>>>
>>>>> #include <pthread.h>
>>>>>
>>>>> +#ifdef USE_DLSYM
>>>>> +#define __USE_GNU
>>>>
>>>> Where does this come from? DLSYM(3) says _GNU_SOURCE (which we already
>>>> have).
>>>
>>> On my machine build failed, so I looked into the header...
>>>
>>
>> Does putting _GNU_SOURCE at the beginning of that file before all
>> headers solve the issue? I don't think we want to use an internal
>> definition.
Aah, I put it just before including dlfcn.h and it didn't work. Putting
it at the beginning solves the problem.
I'll send V2 after waiting a bit for other comments.
> And I was wrong about "we already have _GNU_SOURCE" bit in my previous
> email. At least not in the file you modified.
Xenstore uses it already, too.
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-22 13:53 [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
2018-02-22 17:28 ` Wei Liu
@ 2018-02-24 1:22 ` Jim Fehlig
2018-02-26 7:25 ` Juergen Gross
1 sibling, 1 reply; 8+ messages in thread
From: Jim Fehlig @ 2018-02-24 1:22 UTC (permalink / raw)
To: Juergen Gross, xen-devel; +Cc: ian.jackson, wei.liu2
On 02/22/2018 06:53 AM, Juergen Gross wrote:
> When creating a pthread in xs_watch() try to get the minimal needed
> size of the thread from glibc instead of using a constant. This avoids
> problems when the library is used in programs with large per-thread
> memory.
>
> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
> avoid linkage problems and fall back to the current constant size if
> not found.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> Only compile tested. Jim, can you please verify this patch is solving
> your original problem?
It didn't help, but it could be due to my buggy glibc
# gdb xl
...
(gdb) r create test-hvm.xl
Starting program: /usr/sbin/xl create test-hvm.xl
Parsing config from test-hvm.xl
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff72d51c2 in __pthread_get_minstack () from /lib64/libpthread.so.0
(gdb) thr a a bt
Thread 1 (Thread 0x7ffff7fd8780 (LWP 2568)):
#0 0x00007ffff72d51c2 in __pthread_get_minstack () from /lib64/libpthread.so.0
#1 0x00007ffff66ae259 in xs_watch (h=0x55555578fc90,
path=path@entry=0x555555798fa0 "/local/domain/0/device-model/2/state",
token=token@entry=0x5555557990b0 "3/0") at xs.c:826
#2 0x00007ffff79476f4 in libxl__ev_xswatch_register (gc=gc@entry=0x5555557955f0,
w=w@entry=0x555555797468, func=func@entry=0x7ffff793dd10
<xswait_xswatch_callback>,
path=0x555555798fa0 "/local/domain/0/device-model/2/state") at
libxl_event.c:638
#3 0x00007ffff793deb0 in libxl__xswait_start (gc=gc@entry=0x5555557955f0,
xswa=xswa@entry=0x5555557973e0) at libxl_aoutils.c:53
#4 0x00007ffff79326b0 in libxl__spawn_spawn (egc=egc@entry=0x7fffffffd950,
ss=ss@entry=0x555555797370) at libxl_exec.c:292
#5 0x00007ffff79258d3 in libxl__spawn_local_dm (egc=0x7fffffffd950,
dmss=<optimized out>)
at libxl_dm.c:2400
#6 0x00007ffff791d3a7 in domcreate_launch_dm (egc=0x7fffffffd950,
multidev=0x555555798168,
ret=<optimized out>) at libxl_create.c:1379
#7 0x00007ffff7967275 in libxl__bootloader_run (egc=egc@entry=0x7fffffffd950,
bl=bl@entry=0x555555796cc0) at libxl_bootloader.c:403
#8 0x00007ffff791ffe3 in initiate_domain_create (egc=egc@entry=0x7fffffffd950,
dcs=dcs@entry=0x555555796610) at libxl_create.c:997
#9 0x00007ffff79201a1 in do_domain_create (ctx=ctx@entry=0x55555578f2a0,
d_config=d_config@entry=0x7fffffffdb70, domid=domid@entry=0x7fffffffdaa8,
restore_fd=restore_fd@entry=-1, send_back_fd=send_back_fd@entry=-1,
params=params@entry=0x0,
ao_how=0x0, aop_console_how=0x0) at libxl_create.c:1682
#10 0x00007ffff79204b6 in libxl_domain_create_new (ctx=0x55555578f2a0,
d_config=d_config@entry=0x7fffffffdb70, domid=domid@entry=0x7fffffffdaa8,
ao_how=ao_how@entry=0x0, aop_console_how=aop_console_how@entry=0x0) at
libxl_create.c:1885
#11 0x00005555555780b4 in create_domain (dom_info=dom_info@entry=0x7fffffffe0b0)
at xl_vmcontrol.c:902
#12 0x00005555555790c4 in main_create (argc=1, argv=0x7fffffffe378) at
xl_vmcontrol.c:1207
#13 0x0000555555560c5b in main (argc=2, argv=0x7fffffffe370) at xl.c:384
If you like, I can try a patched glibc after the weekend :-).
Regards,
Jim
> ---
> tools/xenstore/Makefile | 4 ++++
> tools/xenstore/xs.c | 19 ++++++++++++++++++-
> 2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> index 2b99d2bc1b..fb6c73e297 100644
> --- a/tools/xenstore/Makefile
> +++ b/tools/xenstore/Makefile
> @@ -100,6 +100,10 @@ libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
> ln -sf $< $@
>
> xs.opic: CFLAGS += -DUSE_PTHREAD
> +ifeq ($(CONFIG_Linux),y)
> +xs.opic: CFLAGS += -DUSE_DLSYM
> +xs.opic: LDFLAGS += -ldl
> +endif
>
> libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
> $(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
> diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
> index abffd9cd80..8372f5b1a4 100644
> --- a/tools/xenstore/xs.c
> +++ b/tools/xenstore/xs.c
> @@ -47,6 +47,11 @@ struct xs_stored_msg {
>
> #include <pthread.h>
>
> +#ifdef USE_DLSYM
> +#define __USE_GNU
> +#include <dlfcn.h>
> +#endif
> +
> struct xs_handle {
> /* Communications channel to xenstore daemon. */
> int fd;
> @@ -810,12 +815,24 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
> if (!h->read_thr_exists) {
> sigset_t set, old_set;
> pthread_attr_t attr;
> + static size_t stack_size;
> +#ifdef USE_DLSYM
> + size_t (*getsz)(void);
> +#endif
>
> + if (!stack_size) {
> +#ifdef USE_DLSYM
> + getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
> + stack_size = getsz ? getsz() : READ_THREAD_STACKSIZE;
> +#else
> + stack_size = READ_THREAD_STACKSIZE;
> +#endif
> + }
> if (pthread_attr_init(&attr) != 0) {
> mutex_unlock(&h->request_mutex);
> return false;
> }
> - if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
> + if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
> pthread_attr_destroy(&attr);
> mutex_unlock(&h->request_mutex);
> return false;
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread
2018-02-24 1:22 ` Jim Fehlig
@ 2018-02-26 7:25 ` Juergen Gross
0 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2018-02-26 7:25 UTC (permalink / raw)
To: Jim Fehlig, xen-devel; +Cc: ian.jackson, wei.liu2
On 24/02/18 02:22, Jim Fehlig wrote:
> On 02/22/2018 06:53 AM, Juergen Gross wrote:
>> When creating a pthread in xs_watch() try to get the minimal needed
>> size of the thread from glibc instead of using a constant. This avoids
>> problems when the library is used in programs with large per-thread
>> memory.
>>
>> Use dlsym() to get the pointer to __pthread_get_minstack() in order to
>> avoid linkage problems and fall back to the current constant size if
>> not found.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> Only compile tested. Jim, can you please verify this patch is solving
>> your original problem?
>
> It didn't help, but it could be due to my buggy glibc
No, it was just a silly mistake in my patch.
Sending V2 soon...
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-02-26 7:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 13:53 [PATCH] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
2018-02-22 17:28 ` Wei Liu
2018-02-22 18:44 ` Juergen Gross
2018-02-22 18:53 ` Wei Liu
2018-02-22 18:55 ` Wei Liu
2018-02-22 19:12 ` Juergen Gross
2018-02-24 1:22 ` Jim Fehlig
2018-02-26 7:25 ` Juergen Gross
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).