[PATCH] libs/store: make build without PTHREAD_STACK_MIN

Manuel Bouyer posted 1 patch 2 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20210112181242.1570-18-bouyer@antioche.eu.org
Test gitlab-ci failed
tools/libs/store/xs.c | 4 ++++
1 file changed, 4 insertions(+)

[PATCH] libs/store: make build without PTHREAD_STACK_MIN

Posted by Manuel Bouyer 2 weeks, 1 day ago
From: Manuel Bouyer <bouyer@netbsd.org>

On NetBSD, PTHREAD_STACK_MIN is not available.
Just use DEFAULT_THREAD_STACKSIZE if PTHREAD_STACK_MIN is not available.

Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
---
 tools/libs/store/xs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
index 4ac73ec317..8e646b98d6 100644
--- a/tools/libs/store/xs.c
+++ b/tools/libs/store/xs.c
@@ -811,9 +811,13 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 
 #ifdef USE_PTHREAD
 #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
+#ifndef PTHREAD_STACK_MIN
+#define READ_THREAD_STACKSIZE DEFAULT_THREAD_STACKSIZE
+#else
 #define READ_THREAD_STACKSIZE 					\
 	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
 	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
+#endif
 
 	/* We dynamically create a reader thread on demand. */
 	mutex_lock(&h->request_mutex);
-- 
2.29.2


Re: [PATCH] libs/store: make build without PTHREAD_STACK_MIN

Posted by Andrew Cooper 1 week, 2 days ago
On 12/01/2021 18:12, Manuel Bouyer wrote:
> From: Manuel Bouyer <bouyer@netbsd.org>
>
> On NetBSD, PTHREAD_STACK_MIN is not available.
> Just use DEFAULT_THREAD_STACKSIZE if PTHREAD_STACK_MIN is not available.
>
> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
> ---
>  tools/libs/store/xs.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> index 4ac73ec317..8e646b98d6 100644
> --- a/tools/libs/store/xs.c
> +++ b/tools/libs/store/xs.c
> @@ -811,9 +811,13 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  
>  #ifdef USE_PTHREAD
>  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
> +#ifndef PTHREAD_STACK_MIN
> +#define READ_THREAD_STACKSIZE DEFAULT_THREAD_STACKSIZE
> +#else
>  #define READ_THREAD_STACKSIZE 					\
>  	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
>  	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
> +#endif

How about this:

diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
index 4ac73ec317..3fa3abdeca 100644
--- a/tools/libs/store/xs.c
+++ b/tools/libs/store/xs.c
@@ -811,9 +811,14 @@ bool xs_watch(struct xs_handle *h, const char
*path, const char *token)
 
 #ifdef USE_PTHREAD
 #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
-#define READ_THREAD_STACKSIZE                                  \
-       ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ?       \
-       PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
+
+/* NetBSD doesn't have PTHREAD_STACK_MIN. */
+#ifndef PTHREAD_STACK_MIN
+# define PTHREAD_STACK_MIN 0
+#endif
+
+#define READ_THREAD_STACKSIZE \
+       MAX(PTHREAD_STACK_MIN, DEFAULT_THREAD_STACKSIZE)
 
        /* We dynamically create a reader thread on demand. */
        mutex_lock(&h->request_mutex);

which makes things rather clearer IMO.

~Andrew

Re: [PATCH] libs/store: make build without PTHREAD_STACK_MIN

Posted by Manuel Bouyer 1 week, 2 days ago
On Mon, Jan 18, 2021 at 06:56:46PM +0000, Andrew Cooper wrote:
> On 12/01/2021 18:12, Manuel Bouyer wrote:
> > From: Manuel Bouyer <bouyer@netbsd.org>
> >
> > On NetBSD, PTHREAD_STACK_MIN is not available.
> > Just use DEFAULT_THREAD_STACKSIZE if PTHREAD_STACK_MIN is not available.
> >
> > Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>
> > ---
> >  tools/libs/store/xs.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> > index 4ac73ec317..8e646b98d6 100644
> > --- a/tools/libs/store/xs.c
> > +++ b/tools/libs/store/xs.c
> > @@ -811,9 +811,13 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
> >  
> >  #ifdef USE_PTHREAD
> >  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
> > +#ifndef PTHREAD_STACK_MIN
> > +#define READ_THREAD_STACKSIZE DEFAULT_THREAD_STACKSIZE
> > +#else
> >  #define READ_THREAD_STACKSIZE 					\
> >  	((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? 	\
> >  	PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
> > +#endif
> 
> How about this:
> 
> diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c
> index 4ac73ec317..3fa3abdeca 100644
> --- a/tools/libs/store/xs.c
> +++ b/tools/libs/store/xs.c
> @@ -811,9 +811,14 @@ bool xs_watch(struct xs_handle *h, const char
> *path, const char *token)
>  
>  #ifdef USE_PTHREAD
>  #define DEFAULT_THREAD_STACKSIZE (16 * 1024)
> -#define READ_THREAD_STACKSIZE                                  \
> -       ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ?       \
> -       PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE)
> +
> +/* NetBSD doesn't have PTHREAD_STACK_MIN. */
> +#ifndef PTHREAD_STACK_MIN
> +# define PTHREAD_STACK_MIN 0
> +#endif
> +
> +#define READ_THREAD_STACKSIZE \
> +       MAX(PTHREAD_STACK_MIN, DEFAULT_THREAD_STACKSIZE)
>  
>         /* We dynamically create a reader thread on demand. */
>         mutex_lock(&h->request_mutex);
> 
> which makes things rather clearer IMO.

fine with me too

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--

Re: [PATCH] libs/store: make build without PTHREAD_STACK_MIN

Posted by Roger Pau Monné 1 week, 2 days ago
On Tue, Jan 12, 2021 at 07:12:38PM +0100, Manuel Bouyer wrote:
> From: Manuel Bouyer <bouyer@netbsd.org>
> 
> On NetBSD, PTHREAD_STACK_MIN is not available.
> Just use DEFAULT_THREAD_STACKSIZE if PTHREAD_STACK_MIN is not available.
> 
> Signed-off-by: Manuel Bouyer <bouyer@netbsd.org>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.