All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
@ 2018-02-26  8:46 Juergen Gross
  2018-02-26  9:46 ` Roger Pau Monné
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Juergen Gross @ 2018-02-26  8:46 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>
---
V2:
- use _GNU_SOURCE (Wei Liu)
- call __pthread_get_minstack() with parameter
- add -ldl to correct make flags
- ensure to not using smaller stack size than today
---
 tools/xenstore/Makefile |  4 ++++
 tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 2b99d2bc1b..0831be0b6f 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
+libxenstore.so.$(MAJOR).$(MINOR): 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..77700bff2b 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -16,6 +16,8 @@
     License along with this library; If not, see <http://www.gnu.org/licenses/>.
 */
 
+#define _GNU_SOURCE
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -47,6 +49,10 @@ struct xs_stored_msg {
 
 #include <pthread.h>
 
+#ifdef USE_DLSYM
+#include <dlfcn.h>
+#endif
+
 struct xs_handle {
 	/* Communications channel to xenstore daemon. */
 	int fd;
@@ -810,12 +816,25 @@ 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)(pthread_attr_t *attr);
+#endif
 
 		if (pthread_attr_init(&attr) != 0) {
 			mutex_unlock(&h->request_mutex);
 			return false;
 		}
-		if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
+		if (!stack_size) {
+#ifdef USE_DLSYM
+			getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
+			if (getsz)
+				stack_size = getsz(&attr);
+#endif
+			if (stack_size < READ_THREAD_STACKSIZE)
+				stack_size = READ_THREAD_STACKSIZE;
+		}
+		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] 18+ messages in thread

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26  8:46 [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
@ 2018-02-26  9:46 ` Roger Pau Monné
  2018-02-26 10:37   ` Wei Liu
  2018-02-26 10:38 ` Wei Liu
  2018-02-26 16:53 ` Jim Fehlig
  2 siblings, 1 reply; 18+ messages in thread
From: Roger Pau Monné @ 2018-02-26  9:46 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, jfehlig, wei.liu2, ian.jackson

On Mon, Feb 26, 2018 at 09:46:12AM +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>
> ---
> V2:
> - use _GNU_SOURCE (Wei Liu)
> - call __pthread_get_minstack() with parameter
> - add -ldl to correct make flags
> - ensure to not using smaller stack size than today
> ---
>  tools/xenstore/Makefile |  4 ++++
>  tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> index 2b99d2bc1b..0831be0b6f 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
> +libxenstore.so.$(MAJOR).$(MINOR): 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..77700bff2b 100644
> --- a/tools/xenstore/xs.c
> +++ b/tools/xenstore/xs.c
> @@ -16,6 +16,8 @@
>      License along with this library; If not, see <http://www.gnu.org/licenses/>.
>  */
>  
> +#define _GNU_SOURCE
> +
>  #include <sys/types.h>
>  #include <sys/stat.h>
>  #include <fcntl.h>
> @@ -47,6 +49,10 @@ struct xs_stored_msg {
>  
>  #include <pthread.h>
>  
> +#ifdef USE_DLSYM
> +#include <dlfcn.h>
> +#endif
> +
>  struct xs_handle {
>  	/* Communications channel to xenstore daemon. */
>  	int fd;
> @@ -810,12 +816,25 @@ 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)(pthread_attr_t *attr);
> +#endif
>  
>  		if (pthread_attr_init(&attr) != 0) {
>  			mutex_unlock(&h->request_mutex);
>  			return false;
>  		}
> -		if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
> +		if (!stack_size) {
> +#ifdef USE_DLSYM
> +			getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");

dlsym is part of libc in FreeBSD, so it can be used but there's no ldl
library (so passing -ldl to the linker is going to throw an error).

I guess it would be nice to have a configure test for this, but I'm
not going to argue over it.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26  9:46 ` Roger Pau Monné
@ 2018-02-26 10:37   ` Wei Liu
  2018-02-26 12:03     ` Ian Jackson
  0 siblings, 1 reply; 18+ messages in thread
From: Wei Liu @ 2018-02-26 10:37 UTC (permalink / raw)
  To: Roger Pau Monné
  Cc: Juergen Gross, xen-devel, jfehlig, wei.liu2, ian.jackson

On Mon, Feb 26, 2018 at 09:46:01AM +0000, Roger Pau Monné wrote:
> >  
> >  		if (pthread_attr_init(&attr) != 0) {
> >  			mutex_unlock(&h->request_mutex);
> >  			return false;
> >  		}
> > -		if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
> > +		if (!stack_size) {
> > +#ifdef USE_DLSYM
> > +			getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
> 
> dlsym is part of libc in FreeBSD, so it can be used but there's no ldl
> library (so passing -ldl to the linker is going to throw an error).
> 
> I guess it would be nice to have a configure test for this, but I'm
> not going to argue over it.

I don't think FreeBSD needs this particular workaround for glibc FWIW.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26  8:46 [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
  2018-02-26  9:46 ` Roger Pau Monné
@ 2018-02-26 10:38 ` Wei Liu
  2018-02-26 16:53 ` Jim Fehlig
  2 siblings, 0 replies; 18+ messages in thread
From: Wei Liu @ 2018-02-26 10:38 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, jfehlig, ian.jackson, wei.liu2

On Mon, Feb 26, 2018 at 09:46:12AM +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>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

I would like to give Jim a chance to test it before applying.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26 10:37   ` Wei Liu
@ 2018-02-26 12:03     ` Ian Jackson
  2018-02-26 12:04       ` Wei Liu
  0 siblings, 1 reply; 18+ messages in thread
From: Ian Jackson @ 2018-02-26 12:03 UTC (permalink / raw)
  To: Wei Liu; +Cc: Juergen Gross, xen-devel, jfehlig, Roger Pau Monné

Wei Liu writes ("Re: [Xen-devel] [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread"):
> I don't think FreeBSD needs this particular workaround for glibc FWIW.

Indeed.

Err, I guess we should have a configure test of some kind then ?

The patch looks good.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26 12:03     ` Ian Jackson
@ 2018-02-26 12:04       ` Wei Liu
  2018-02-26 12:12         ` Ian Jackson
  0 siblings, 1 reply; 18+ messages in thread
From: Wei Liu @ 2018-02-26 12:04 UTC (permalink / raw)
  To: Ian Jackson
  Cc: Juergen Gross, xen-devel, jfehlig, Wei Liu, Roger Pau Monné

On Mon, Feb 26, 2018 at 12:03:29PM +0000, Ian Jackson wrote:
> Wei Liu writes ("Re: [Xen-devel] [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread"):
> > I don't think FreeBSD needs this particular workaround for glibc FWIW.
> 
> Indeed.
> 
> Err, I guess we should have a configure test of some kind then ?
> 

It is already enclosed in CONFIG_Linux. I think that should be enough.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26 12:04       ` Wei Liu
@ 2018-02-26 12:12         ` Ian Jackson
  0 siblings, 0 replies; 18+ messages in thread
From: Ian Jackson @ 2018-02-26 12:12 UTC (permalink / raw)
  To: Wei Liu; +Cc: Juergen Gross, xen-devel, jfehlig, Roger Pau Monné

Wei Liu writes ("Re: [Xen-devel] [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread"):
> It is already enclosed in CONFIG_Linux. I think that should be enough.

Oh, I see.  I had read USE_DLSYM as CONFIG_DLSYM, ie "dlsym is
available".  A better name might be USE_DLSYM_MINSTACK_HACK but I'm
happy with the patch as is.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

I would like a test report from Jim, although the thread suggests that
Jim's *actual* problem was something else so that might not be
applicable.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26  8:46 [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
  2018-02-26  9:46 ` Roger Pau Monné
  2018-02-26 10:38 ` Wei Liu
@ 2018-02-26 16:53 ` Jim Fehlig
  2018-03-02 12:29   ` Wei Liu
  2 siblings, 1 reply; 18+ messages in thread
From: Jim Fehlig @ 2018-02-26 16:53 UTC (permalink / raw)
  To: Juergen Gross, xen-devel; +Cc: ian.jackson, wei.liu2

On 02/26/2018 01:46 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>
> ---
> V2:
> - use _GNU_SOURCE (Wei Liu)
> - call __pthread_get_minstack() with parameter
> - add -ldl to correct make flags
> - ensure to not using smaller stack size than today
> ---
>   tools/xenstore/Makefile |  4 ++++
>   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>   2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> index 2b99d2bc1b..0831be0b6f 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
> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> +endif

Dropping this patch in one of my automated builds caused a libxenstore link failure

[   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0 
-shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic 
/home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so 

[   99s] 
/home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so: 
undefined reference to `dlsym'

I hacked around it by appending '-ldl' to the end of the subsequent 
libxenstore.so rule.

>   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..77700bff2b 100644
> --- a/tools/xenstore/xs.c
> +++ b/tools/xenstore/xs.c
> @@ -16,6 +16,8 @@
>       License along with this library; If not, see <http://www.gnu.org/licenses/>.
>   */
>   
> +#define _GNU_SOURCE
> +
>   #include <sys/types.h>
>   #include <sys/stat.h>
>   #include <fcntl.h>
> @@ -47,6 +49,10 @@ struct xs_stored_msg {
>   
>   #include <pthread.h>
>   
> +#ifdef USE_DLSYM
> +#include <dlfcn.h>
> +#endif
> +
>   struct xs_handle {
>   	/* Communications channel to xenstore daemon. */
>   	int fd;
> @@ -810,12 +816,25 @@ 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)(pthread_attr_t *attr);
> +#endif
>   
>   		if (pthread_attr_init(&attr) != 0) {
>   			mutex_unlock(&h->request_mutex);
>   			return false;
>   		}
> -		if (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE) != 0) {
> +		if (!stack_size) {
> +#ifdef USE_DLSYM
> +			getsz = dlsym(RTLD_DEFAULT, "__pthread_get_minstack");
> +			if (getsz)
> +				stack_size = getsz(&attr);
> +#endif
> +			if (stack_size < READ_THREAD_STACKSIZE)
> +				stack_size = READ_THREAD_STACKSIZE;
> +		}
> +		if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
>   			pthread_attr_destroy(&attr);
>   			mutex_unlock(&h->request_mutex);
>   			return false;

This worked fine, even on the system with the buggy glibc.

Tested-by: Jim Fehlig <jfehlig@suse.com>

Regards,
Jim

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-02-26 16:53 ` Jim Fehlig
@ 2018-03-02 12:29   ` Wei Liu
  2018-03-02 12:40     ` Wei Liu
  0 siblings, 1 reply; 18+ messages in thread
From: Wei Liu @ 2018-03-02 12:29 UTC (permalink / raw)
  To: Jim Fehlig; +Cc: Juergen Gross, xen-devel, wei.liu2, ian.jackson

On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
> On 02/26/2018 01:46 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>
> > ---
> > V2:
> > - use _GNU_SOURCE (Wei Liu)
> > - call __pthread_get_minstack() with parameter
> > - add -ldl to correct make flags
> > - ensure to not using smaller stack size than today
> > ---
> >   tools/xenstore/Makefile |  4 ++++
> >   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
> >   2 files changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> > index 2b99d2bc1b..0831be0b6f 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
> > +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> > +endif
> 
> Dropping this patch in one of my automated builds caused a libxenstore link failure
> 
> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
> 
> [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
> undefined reference to `dlsym'
> 
> I hacked around it by appending '-ldl' to the end of the subsequent
> libxenstore.so rule.

Hmm... Maybe I'm a bit dense today. I know the position of -l matters
but I don't quite understand how placing -pthread before xs.opic works
but -ldl doesn't. xs.c uses both after all.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 12:29   ` Wei Liu
@ 2018-03-02 12:40     ` Wei Liu
  2018-03-02 12:45       ` Juergen Gross
                         ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Wei Liu @ 2018-03-02 12:40 UTC (permalink / raw)
  To: Jim Fehlig; +Cc: Juergen Gross, xen-devel, wei.liu2, ian.jackson

On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
> > On 02/26/2018 01:46 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>
> > > ---
> > > V2:
> > > - use _GNU_SOURCE (Wei Liu)
> > > - call __pthread_get_minstack() with parameter
> > > - add -ldl to correct make flags
> > > - ensure to not using smaller stack size than today
> > > ---
> > >   tools/xenstore/Makefile |  4 ++++
> > >   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
> > >   2 files changed, 24 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> > > index 2b99d2bc1b..0831be0b6f 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
> > > +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> > > +endif
> > 
> > Dropping this patch in one of my automated builds caused a libxenstore link failure
> > 
> > [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
> > -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
> > 
> > [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
> > undefined reference to `dlsym'
> > 
> > I hacked around it by appending '-ldl' to the end of the subsequent
> > libxenstore.so rule.
> 
> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
> but I don't quite understand how placing -pthread before xs.opic works
> but -ldl doesn't. xs.c uses both after all.

I'm indeed very dense -- -pthread is a special option that sets the
proper flags for linking pthread library for both the preprocessor and
linker.

But still, Juergen must have tested the change, so I wonder why it
doesn't work in your setup. What is your build environment? Gcc version?

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 12:40     ` Wei Liu
@ 2018-03-02 12:45       ` Juergen Gross
  2018-03-02 14:28         ` Wei Liu
  2018-03-02 17:23       ` Jim Fehlig
  2018-03-06 11:24       ` Olaf Hering
  2 siblings, 1 reply; 18+ messages in thread
From: Juergen Gross @ 2018-03-02 12:45 UTC (permalink / raw)
  To: Wei Liu, Jim Fehlig; +Cc: xen-devel, ian.jackson

On 02/03/18 13:40, Wei Liu wrote:
> On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
>> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
>>> On 02/26/2018 01:46 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>
>>>> ---
>>>> V2:
>>>> - use _GNU_SOURCE (Wei Liu)
>>>> - call __pthread_get_minstack() with parameter
>>>> - add -ldl to correct make flags
>>>> - ensure to not using smaller stack size than today
>>>> ---
>>>>   tools/xenstore/Makefile |  4 ++++
>>>>   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>>>>   2 files changed, 24 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>>>> index 2b99d2bc1b..0831be0b6f 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
>>>> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
>>>> +endif
>>>
>>> Dropping this patch in one of my automated builds caused a libxenstore link failure
>>>
>>> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
>>> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
>>>
>>> [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
>>> undefined reference to `dlsym'
>>>
>>> I hacked around it by appending '-ldl' to the end of the subsequent
>>> libxenstore.so rule.
>>
>> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
>> but I don't quite understand how placing -pthread before xs.opic works
>> but -ldl doesn't. xs.c uses both after all.
> 
> I'm indeed very dense -- -pthread is a special option that sets the
> proper flags for linking pthread library for both the preprocessor and
> linker.
> 
> But still, Juergen must have tested the change, so I wonder why it
> doesn't work in your setup. What is your build environment? Gcc version?

And why is "-lsystemd" working correctly?

I have tested with gcc 4.8.5, binutils 2.25.0


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 12:45       ` Juergen Gross
@ 2018-03-02 14:28         ` Wei Liu
  2018-03-02 14:54           ` Juergen Gross
  0 siblings, 1 reply; 18+ messages in thread
From: Wei Liu @ 2018-03-02 14:28 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Jim Fehlig, Wei Liu, ian.jackson

On Fri, Mar 02, 2018 at 01:45:14PM +0100, Juergen Gross wrote:
> On 02/03/18 13:40, Wei Liu wrote:
> > On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
> >> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
> >>> On 02/26/2018 01:46 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>
> >>>> ---
> >>>> V2:
> >>>> - use _GNU_SOURCE (Wei Liu)
> >>>> - call __pthread_get_minstack() with parameter
> >>>> - add -ldl to correct make flags
> >>>> - ensure to not using smaller stack size than today
> >>>> ---
> >>>>   tools/xenstore/Makefile |  4 ++++
> >>>>   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
> >>>>   2 files changed, 24 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> >>>> index 2b99d2bc1b..0831be0b6f 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
> >>>> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> >>>> +endif
> >>>
> >>> Dropping this patch in one of my automated builds caused a libxenstore link failure
> >>>
> >>> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
> >>> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
> >>>
> >>> [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
> >>> undefined reference to `dlsym'
> >>>
> >>> I hacked around it by appending '-ldl' to the end of the subsequent
> >>> libxenstore.so rule.
> >>
> >> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
> >> but I don't quite understand how placing -pthread before xs.opic works
> >> but -ldl doesn't. xs.c uses both after all.
> > 
> > I'm indeed very dense -- -pthread is a special option that sets the
> > proper flags for linking pthread library for both the preprocessor and
> > linker.
> > 
> > But still, Juergen must have tested the change, so I wonder why it
> > doesn't work in your setup. What is your build environment? Gcc version?
> 
> And why is "-lsystemd" working correctly?

That's red-herring because libxenstore doesn't use systemd functions.
The only place systemd is used is in xenstored_core.c -- calling
sd_notify.

But we still need to figure out why -ldl works in your setup but not
Jim's.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 14:28         ` Wei Liu
@ 2018-03-02 14:54           ` Juergen Gross
  0 siblings, 0 replies; 18+ messages in thread
From: Juergen Gross @ 2018-03-02 14:54 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Jim Fehlig, ian.jackson

On 02/03/18 15:28, Wei Liu wrote:
> On Fri, Mar 02, 2018 at 01:45:14PM +0100, Juergen Gross wrote:
>> On 02/03/18 13:40, Wei Liu wrote:
>>> On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
>>>> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
>>>>> On 02/26/2018 01:46 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>
>>>>>> ---
>>>>>> V2:
>>>>>> - use _GNU_SOURCE (Wei Liu)
>>>>>> - call __pthread_get_minstack() with parameter
>>>>>> - add -ldl to correct make flags
>>>>>> - ensure to not using smaller stack size than today
>>>>>> ---
>>>>>>   tools/xenstore/Makefile |  4 ++++
>>>>>>   tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>>>>>>   2 files changed, 24 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>>>>>> index 2b99d2bc1b..0831be0b6f 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
>>>>>> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
>>>>>> +endif
>>>>>
>>>>> Dropping this patch in one of my automated builds caused a libxenstore link failure
>>>>>
>>>>> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
>>>>> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
>>>>>
>>>>> [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
>>>>> undefined reference to `dlsym'
>>>>>
>>>>> I hacked around it by appending '-ldl' to the end of the subsequent
>>>>> libxenstore.so rule.
>>>>
>>>> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
>>>> but I don't quite understand how placing -pthread before xs.opic works
>>>> but -ldl doesn't. xs.c uses both after all.
>>>
>>> I'm indeed very dense -- -pthread is a special option that sets the
>>> proper flags for linking pthread library for both the preprocessor and
>>> linker.
>>>
>>> But still, Juergen must have tested the change, so I wonder why it
>>> doesn't work in your setup. What is your build environment? Gcc version?
>>
>> And why is "-lsystemd" working correctly?
> 
> That's red-herring because libxenstore doesn't use systemd functions.
> The only place systemd is used is in xenstored_core.c -- calling
> sd_notify.

Nevertheless it is working:

# ldd /usr/lib64/libxenstore.so.3.0
        linux-vdso.so.1 (0x00007ffdfcbc6000)
        libsystemd.so.0 => /usr/lib64/libsystemd.so.0 (0x00007f1d054cb000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f1d052c7000)
        libxentoolcore.so.1 => /usr/lib64/libxentoolcore.so.1
(0x00007f1d050c5000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1d04ea8000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f1d04b01000)
        liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f1d048db000)
        libgcrypt.so.20 => /usr/lib64/libgcrypt.so.20 (0x00007f1d045f5000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f1d043ed000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1d041d6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f1d05900000)
        libgpg-error.so.0 => /usr/lib64/libgpg-error.so.0
(0x00007f1d03fd1000)

> But we still need to figure out why -ldl works in your setup but not
> Jim's.

I just rebuilt libxenstore.so and the xenstore clients. I've verified
all components are installed from the new build and working properly.

So obviously there are some differences in tooling.

What about using SHLIB_LDFLAGS instead of LDFLAGS?


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 12:40     ` Wei Liu
  2018-03-02 12:45       ` Juergen Gross
@ 2018-03-02 17:23       ` Jim Fehlig
  2018-03-02 17:26         ` Wei Liu
  2018-03-06 11:24       ` Olaf Hering
  2 siblings, 1 reply; 18+ messages in thread
From: Jim Fehlig @ 2018-03-02 17:23 UTC (permalink / raw)
  To: Wei Liu; +Cc: Juergen Gross, xen-devel, ian.jackson

On 03/02/2018 05:40 AM, Wei Liu wrote:
> On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
>> On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
>>> On 02/26/2018 01:46 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>
>>>> ---
>>>> V2:
>>>> - use _GNU_SOURCE (Wei Liu)
>>>> - call __pthread_get_minstack() with parameter
>>>> - add -ldl to correct make flags
>>>> - ensure to not using smaller stack size than today
>>>> ---
>>>>    tools/xenstore/Makefile |  4 ++++
>>>>    tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
>>>>    2 files changed, 24 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
>>>> index 2b99d2bc1b..0831be0b6f 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
>>>> +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
>>>> +endif
>>>
>>> Dropping this patch in one of my automated builds caused a libxenstore link failure
>>>
>>> [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
>>> -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
>>>
>>> [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
>>> undefined reference to `dlsym'
>>>
>>> I hacked around it by appending '-ldl' to the end of the subsequent
>>> libxenstore.so rule.
>>
>> Hmm... Maybe I'm a bit dense today. I know the position of -l matters
>> but I don't quite understand how placing -pthread before xs.opic works
>> but -ldl doesn't. xs.c uses both after all.
> 
> I'm indeed very dense -- -pthread is a special option that sets the
> proper flags for linking pthread library for both the preprocessor and
> linker.
> 
> But still, Juergen must have tested the change, so I wonder why it
> doesn't work in your setup. What is your build environment? Gcc version?

I dropped the patch in a package build on the openSUSE build service, where gcc7 
was used. But I don't see the problem when building from sources with gcc7. 
Apparently we have a bug in our package build, so ignore this comment. Tested-by 
still stands though :-).

Regards,
Jim

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 17:23       ` Jim Fehlig
@ 2018-03-02 17:26         ` Wei Liu
  0 siblings, 0 replies; 18+ messages in thread
From: Wei Liu @ 2018-03-02 17:26 UTC (permalink / raw)
  To: Jim Fehlig; +Cc: Juergen Gross, xen-devel, Wei Liu, ian.jackson

On Fri, Mar 02, 2018 at 10:23:08AM -0700, Jim Fehlig wrote:
> On 03/02/2018 05:40 AM, Wei Liu wrote:
> > On Fri, Mar 02, 2018 at 12:29:31PM +0000, Wei Liu wrote:
> > > On Mon, Feb 26, 2018 at 09:53:38AM -0700, Jim Fehlig wrote:
> > > > On 02/26/2018 01:46 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>
> > > > > ---
> > > > > V2:
> > > > > - use _GNU_SOURCE (Wei Liu)
> > > > > - call __pthread_get_minstack() with parameter
> > > > > - add -ldl to correct make flags
> > > > > - ensure to not using smaller stack size than today
> > > > > ---
> > > > >    tools/xenstore/Makefile |  4 ++++
> > > > >    tools/xenstore/xs.c     | 21 ++++++++++++++++++++-
> > > > >    2 files changed, 24 insertions(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
> > > > > index 2b99d2bc1b..0831be0b6f 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
> > > > > +libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> > > > > +endif
> > > > 
> > > > Dropping this patch in one of my automated builds caused a libxenstore link failure
> > > > 
> > > > [   99s] gcc    -lsystemd -ldl -pthread -Wl,-soname -Wl,libxenstore.so.3.0
> > > > -shared -o libxenstore.so.3.0.3 xs.opic xs_lib.opic /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/libs/toolcore/libxentoolcore.so
> > > > 
> > > > [   99s] /home/abuild/rpmbuild/BUILD/xen-4.10.0-testing/tools/xenstore/../../tools/xenstore/libxenstore.so:
> > > > undefined reference to `dlsym'
> > > > 
> > > > I hacked around it by appending '-ldl' to the end of the subsequent
> > > > libxenstore.so rule.
> > > 
> > > Hmm... Maybe I'm a bit dense today. I know the position of -l matters
> > > but I don't quite understand how placing -pthread before xs.opic works
> > > but -ldl doesn't. xs.c uses both after all.
> > 
> > I'm indeed very dense -- -pthread is a special option that sets the
> > proper flags for linking pthread library for both the preprocessor and
> > linker.
> > 
> > But still, Juergen must have tested the change, so I wonder why it
> > doesn't work in your setup. What is your build environment? Gcc version?
> 
> I dropped the patch in a package build on the openSUSE build service, where
> gcc7 was used. But I don't see the problem when building from sources with
> gcc7. Apparently we have a bug in our package build, so ignore this comment.
> Tested-by still stands though :-).
> 

OK, thanks for the reply.

I will commit this patch soon.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-02 12:40     ` Wei Liu
  2018-03-02 12:45       ` Juergen Gross
  2018-03-02 17:23       ` Jim Fehlig
@ 2018-03-06 11:24       ` Olaf Hering
  2018-03-06 12:40         ` Juergen Gross
  2 siblings, 1 reply; 18+ messages in thread
From: Olaf Hering @ 2018-03-06 11:24 UTC (permalink / raw)
  To: Wei Liu; +Cc: Juergen Gross, xen-devel, Jim Fehlig, ian.jackson


[-- Attachment #1.1: Type: text/plain, Size: 1151 bytes --]

On Fri, Mar 02, Wei Liu wrote:

> But still, Juergen must have tested the change, so I wonder why it
> doesn't work in your setup. What is your build environment? Gcc version?

Unclear what the difference is between building in clean chroot and locally.
This change fixes it for me:

--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -148,6 +148,9 @@ SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_LIBXC)
 CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
 LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
+ifeq ($(CONFIG_Linux),y)
+LDLIBS_libxenstore += -ldl
+endif
 SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
 
 CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -103,6 +103,7 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
 xs.opic: CFLAGS += -DUSE_DLSYM
 libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
+LDLIBS_xenstored += -ldl
 endif
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic

Olaf

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-06 11:24       ` Olaf Hering
@ 2018-03-06 12:40         ` Juergen Gross
  2018-03-06 14:07           ` Ian Jackson
  0 siblings, 1 reply; 18+ messages in thread
From: Juergen Gross @ 2018-03-06 12:40 UTC (permalink / raw)
  To: Olaf Hering, Wei Liu; +Cc: xen-devel, Jim Fehlig, ian.jackson

On 06/03/18 12:24, Olaf Hering wrote:
> On Fri, Mar 02, Wei Liu wrote:
> 
>> But still, Juergen must have tested the change, so I wonder why it
>> doesn't work in your setup. What is your build environment? Gcc version?
> 
> Unclear what the difference is between building in clean chroot and locally.
> This change fixes it for me:
> 
> --- a/tools/Rules.mk
> +++ b/tools/Rules.mk
> @@ -148,6 +148,9 @@ SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_LIBXC)
>  CFLAGS_libxenstore = -I$(XEN_XENSTORE)/include $(CFLAGS_xeninclude)
>  SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
>  LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_XENSTORE)/libxenstore$(libextension)
> +ifeq ($(CONFIG_Linux),y)
> +LDLIBS_libxenstore += -ldl
> +endif

So we need to add this to xenstore.pc, right?

>  SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_XENSTORE)
>  
>  CFLAGS_libxenstat  = -I$(XEN_LIBXENSTAT)
> --- a/tools/xenstore/Makefile
> +++ b/tools/xenstore/Makefile
> @@ -103,6 +103,7 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
>  ifeq ($(CONFIG_Linux),y)
>  xs.opic: CFLAGS += -DUSE_DLSYM
>  libxenstore.so.$(MAJOR).$(MINOR): LDFLAGS += -ldl
> +LDLIBS_xenstored += -ldl

Why is this needed? xenstored doesn't need libxenstore and (at least on
my system) doesn't try to load it. The "-ldl" addition should only be
needed for programs linked against libxenstore.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread
  2018-03-06 12:40         ` Juergen Gross
@ 2018-03-06 14:07           ` Ian Jackson
  0 siblings, 0 replies; 18+ messages in thread
From: Ian Jackson @ 2018-03-06 14:07 UTC (permalink / raw)
  To: Juergen Gross; +Cc: ian.jackson, xen-devel, Olaf Hering, Wei Liu, Jim Fehlig

Juergen Gross writes ("Re: [Xen-devel] [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread"):
> On 06/03/18 12:24, Olaf Hering wrote:
> > +ifeq ($(CONFIG_Linux),y)
> > +LDLIBS_libxenstore += -ldl
> > +endif
> 
> So we need to add this to xenstore.pc, right?

Yes.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-03-06 14:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26  8:46 [PATCH v2] tools/xenstore: try to get minimum thread stack size for watch thread Juergen Gross
2018-02-26  9:46 ` Roger Pau Monné
2018-02-26 10:37   ` Wei Liu
2018-02-26 12:03     ` Ian Jackson
2018-02-26 12:04       ` Wei Liu
2018-02-26 12:12         ` Ian Jackson
2018-02-26 10:38 ` Wei Liu
2018-02-26 16:53 ` Jim Fehlig
2018-03-02 12:29   ` Wei Liu
2018-03-02 12:40     ` Wei Liu
2018-03-02 12:45       ` Juergen Gross
2018-03-02 14:28         ` Wei Liu
2018-03-02 14:54           ` Juergen Gross
2018-03-02 17:23       ` Jim Fehlig
2018-03-02 17:26         ` Wei Liu
2018-03-06 11:24       ` Olaf Hering
2018-03-06 12:40         ` Juergen Gross
2018-03-06 14:07           ` 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.