diff options
author | Khem Raj <raj.khem@gmail.com> | 2021-07-31 12:11:37 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-02 15:44:11 +0100 |
commit | ccd83269b7cbe27270c10c7a4fa0ea5498a1a624 (patch) | |
tree | 5ccf70cd2b844558fa99843c774698b3d7ac7036 | |
parent | 55a37651acff13e5485eab85e3a160ea75030078 (diff) | |
download | poky-ccd83269b7cbe27270c10c7a4fa0ea5498a1a624.tar.gz |
stress-ng: Detemine minimal stack size via sysconf
This helps it compile with glibc 2.34+
(From OE-Core rev: 9150933dc524b6cedc42b063b7a2092e202f3672)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-extended/stress-ng/stress-ng/0001-Detemine-minimal-stack-size-via-sysconf-then-PTHREAD.patch | 103 | ||||
-rw-r--r-- | meta/recipes-extended/stress-ng/stress-ng_0.12.12.bb | 1 |
2 files changed, 104 insertions, 0 deletions
diff --git a/meta/recipes-extended/stress-ng/stress-ng/0001-Detemine-minimal-stack-size-via-sysconf-then-PTHREAD.patch b/meta/recipes-extended/stress-ng/stress-ng/0001-Detemine-minimal-stack-size-via-sysconf-then-PTHREAD.patch new file mode 100644 index 0000000000..d275e3d7f9 --- /dev/null +++ b/meta/recipes-extended/stress-ng/stress-ng/0001-Detemine-minimal-stack-size-via-sysconf-then-PTHREAD.patch | |||
@@ -0,0 +1,103 @@ | |||
1 | From f839de283c44ffe46a2d14bfdf854c145abd8ed6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Colin Ian King <colin.king@canonical.com> | ||
3 | Date: Mon, 19 Jul 2021 20:49:34 +0100 | ||
4 | Subject: [PATCH] Detemine minimal stack size via sysconf, then PTHREAD_STACK_MIN then guess | ||
5 | |||
6 | Don't rely on PTHREAD_STACK_MIN being defined, use sysconf, then | ||
7 | PTHREAD_STACK_MIN if it is defined, then 8K default. | ||
8 | |||
9 | Upstream-Status: Backport [https://kernel.ubuntu.com/git/cking/stress-ng.git/commit/?id=f839de283c44ffe46a2d14bfdf854c145abd8ed6] | ||
10 | Signed-off-by: Colin Ian King <colin.king@canonical.com> | ||
11 | --- | ||
12 | core-helper.c | 31 +++++++++++++++++++++++++++++++ | ||
13 | stress-ng.h | 1 + | ||
14 | stress-pthread.c | 13 ++----------- | ||
15 | 3 files changed, 34 insertions(+), 11 deletions(-) | ||
16 | |||
17 | diff --git a/core-helper.c b/core-helper.c | ||
18 | index 508627f2..97a3b869 100644 | ||
19 | --- a/core-helper.c | ||
20 | +++ b/core-helper.c | ||
21 | @@ -2494,6 +2494,37 @@ size_t stress_min_sig_stack_size(void) | ||
22 | return (size_t)sz; | ||
23 | } | ||
24 | |||
25 | +size_t stress_min_pthread_stack_size(void) | ||
26 | +{ | ||
27 | + static long sz = -1, min; | ||
28 | + | ||
29 | + /* return cached copy */ | ||
30 | + if (sz > 0) | ||
31 | + return sz; | ||
32 | + | ||
33 | + min = stress_min_aux_sig_stack_size(); | ||
34 | +#if defined(__SC_THREAD_STACK_MIN_VALUE) | ||
35 | + sz = sysconf(__SC_THREAD_STACK_MIN_VALUE); | ||
36 | + if (sz > min) | ||
37 | + min = sz; | ||
38 | +#endif | ||
39 | +#if defined(_SC_THREAD_STACK_MIN_VALUE) | ||
40 | + sz = sysconf(_SC_THREAD_STACK_MIN_VALUE); | ||
41 | + if (sz > min) | ||
42 | + min = sz; | ||
43 | +#endif | ||
44 | +#if defined(PTHREAD_STACK_MIN) | ||
45 | + if (PTHREAD_STACK_MIN > min) | ||
46 | + min = PTHREAD_STACK_MIN; | ||
47 | +#endif | ||
48 | + if (8192 > min) | ||
49 | + min = 8192; | ||
50 | + | ||
51 | + sz = min; | ||
52 | + | ||
53 | + return (size_t)sz; | ||
54 | +} | ||
55 | + | ||
56 | /* | ||
57 | * stress_sig_handler_exit() | ||
58 | * signal handler that exits a process via _exit(0) for | ||
59 | diff --git a/stress-ng.h b/stress-ng.h | ||
60 | index 8a8b17ae..cd744756 100644 | ||
61 | --- a/stress-ng.h | ||
62 | +++ b/stress-ng.h | ||
63 | @@ -4056,6 +4056,7 @@ extern WARN_UNUSED int32_t stress_get_opt_ionice_class(const char *const str); | ||
64 | /* Misc helper funcs */ | ||
65 | extern WARN_UNUSED size_t stress_sig_stack_size(void); | ||
66 | extern WARN_UNUSED size_t stress_min_sig_stack_size(void); | ||
67 | +extern WARN_UNUSED size_t stress_min_pthread_stack_size(void); | ||
68 | |||
69 | #define STRESS_SIGSTKSZ (stress_sig_stack_size()) | ||
70 | #define STRESS_MINSIGSTKSZ (stress_min_sig_stack_size()) | ||
71 | diff --git a/stress-pthread.c b/stress-pthread.c | ||
72 | index 0da3aeec..27777af8 100644 | ||
73 | --- a/stress-pthread.c | ||
74 | +++ b/stress-pthread.c | ||
75 | @@ -69,12 +69,7 @@ static const stress_opt_set_func_t opt_set_funcs[] = { | ||
76 | |||
77 | #if defined(HAVE_LIB_PTHREAD) | ||
78 | |||
79 | -/* Some systems such as GNU/HURD don't define PTHREAD_STACK_MIN */ | ||
80 | -#if !defined(PTHREAD_STACK_MIN) | ||
81 | -#define PTHREAD_STACK_MIN (16 * KB) | ||
82 | -#endif | ||
83 | - | ||
84 | -#define DEFAULT_STACK_MIN (16 * KB) | ||
85 | +#define DEFAULT_STACK_MIN (8 * KB) | ||
86 | |||
87 | #if defined(HAVE_GET_ROBUST_LIST) && \ | ||
88 | defined(HAVE_LINUX_FUTEX_H) | ||
89 | @@ -404,11 +399,7 @@ static int stress_pthread(const stress_args_t *args) | ||
90 | stress_pthread_args_t pargs = { args, NULL, 0 }; | ||
91 | sigset_t set; | ||
92 | #if defined(HAVE_PTHREAD_ATTR_SETSTACK) | ||
93 | -#if DEFAULT_STACK_MIN == PTHREAD_STACK_MIN | ||
94 | - const size_t stack_size = PTHREAD_STACK_MIN; | ||
95 | -#else | ||
96 | - const size_t stack_size = STRESS_MAXIMUM(DEFAULT_STACK_MIN, PTHREAD_STACK_MIN); | ||
97 | -#endif | ||
98 | + const size_t stack_size = STRESS_MAXIMUM(DEFAULT_STACK_MIN, stress_min_pthread_stack_size()); | ||
99 | #endif | ||
100 | |||
101 | keep_running_flag = true; | ||
102 | -- | ||
103 | 2.32.0 | ||
diff --git a/meta/recipes-extended/stress-ng/stress-ng_0.12.12.bb b/meta/recipes-extended/stress-ng/stress-ng_0.12.12.bb index 32c2d2b6a7..afc9ddf96c 100644 --- a/meta/recipes-extended/stress-ng/stress-ng_0.12.12.bb +++ b/meta/recipes-extended/stress-ng/stress-ng_0.12.12.bb | |||
@@ -7,6 +7,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" | |||
7 | 7 | ||
8 | SRC_URI = "https://kernel.ubuntu.com/~cking/tarballs/${BPN}/${BP}.tar.xz \ | 8 | SRC_URI = "https://kernel.ubuntu.com/~cking/tarballs/${BPN}/${BP}.tar.xz \ |
9 | file://0001-Do-not-preserve-ownership-when-installing-example-jo.patch \ | 9 | file://0001-Do-not-preserve-ownership-when-installing-example-jo.patch \ |
10 | file://0001-Detemine-minimal-stack-size-via-sysconf-then-PTHREAD.patch \ | ||
10 | " | 11 | " |
11 | SRC_URI[sha256sum] = "f27af50f6f2308e707fef927674bdd209a046b116734281b792aeca35a4e4499" | 12 | SRC_URI[sha256sum] = "f27af50f6f2308e707fef927674bdd209a046b116734281b792aeca35a4e4499" |
12 | 13 | ||