diff options
author | Ron Yorston <rmy@pobox.com> | 2024-06-23 09:35:35 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-06-23 09:44:03 +0100 |
commit | b07c177b446498ccd739b367f9e80337c3dfa55a (patch) | |
tree | 8230bce5f937e46ae1a6f18677904d2eccc4ae9e /util-linux | |
parent | 1b094d366f808a2ebc4824004f0d6f75f13c09cb (diff) | |
parent | a6ce017a8a2db09c6f23aa6abf7ce21fd00c2fdf (diff) | |
download | busybox-w32-b07c177b446498ccd739b367f9e80337c3dfa55a.tar.gz busybox-w32-b07c177b446498ccd739b367f9e80337c3dfa55a.tar.bz2 busybox-w32-b07c177b446498ccd739b367f9e80337c3dfa55a.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/taskset.c | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/util-linux/taskset.c b/util-linux/taskset.c index 55c915e8d..a3aa06119 100644 --- a/util-linux/taskset.c +++ b/util-linux/taskset.c | |||
@@ -56,7 +56,6 @@ | |||
56 | * -a/--all-tasks (affect all threads) | 56 | * -a/--all-tasks (affect all threads) |
57 | * needs to get TIDs from /proc/PID/task/ and use _them_ as "pid" in sched_setaffinity(pid) | 57 | * needs to get TIDs from /proc/PID/task/ and use _them_ as "pid" in sched_setaffinity(pid) |
58 | */ | 58 | */ |
59 | |||
60 | #include <sched.h> | 59 | #include <sched.h> |
61 | #include "libbb.h" | 60 | #include "libbb.h" |
62 | 61 | ||
@@ -96,27 +95,6 @@ static unsigned long from_mask(ul *mask, unsigned sz_in_bytes UNUSED_PARAM) | |||
96 | } | 95 | } |
97 | #endif | 96 | #endif |
98 | 97 | ||
99 | static unsigned long *get_aff(int pid, unsigned *sz) | ||
100 | { | ||
101 | int r; | ||
102 | unsigned long *mask = NULL; | ||
103 | unsigned sz_in_bytes = *sz; | ||
104 | |||
105 | for (;;) { | ||
106 | mask = xrealloc(mask, sz_in_bytes); | ||
107 | r = sched_getaffinity(pid, sz_in_bytes, (void*)mask); | ||
108 | if (r == 0) | ||
109 | break; | ||
110 | sz_in_bytes *= 2; | ||
111 | if (errno == EINVAL && (int)sz_in_bytes > 0) | ||
112 | continue; | ||
113 | bb_perror_msg_and_die("can't %cet pid %d's affinity", 'g', pid); | ||
114 | } | ||
115 | //bb_error_msg("get mask[0]:%lx sz_in_bytes:%d", mask[0], sz_in_bytes); | ||
116 | *sz = sz_in_bytes; | ||
117 | return mask; | ||
118 | } | ||
119 | |||
120 | #if ENABLE_FEATURE_TASKSET_CPULIST | 98 | #if ENABLE_FEATURE_TASKSET_CPULIST |
121 | /* | 99 | /* |
122 | * Parse the CPU list and set the mask accordingly. | 100 | * Parse the CPU list and set the mask accordingly. |
@@ -222,7 +200,7 @@ static int process_pid_str(const char *pid_str, unsigned opts, char *aff) | |||
222 | mask_size_in_bytes = SZOF_UL; | 200 | mask_size_in_bytes = SZOF_UL; |
223 | current_new = "current"; | 201 | current_new = "current"; |
224 | print_aff: | 202 | print_aff: |
225 | mask = get_aff(pid, &mask_size_in_bytes); | 203 | mask = get_malloc_cpu_affinity(pid, &mask_size_in_bytes); |
226 | if (opts & OPT_p) { | 204 | if (opts & OPT_p) { |
227 | #if ENABLE_FEATURE_TASKSET_CPULIST | 205 | #if ENABLE_FEATURE_TASKSET_CPULIST |
228 | if (opts & OPT_c) { | 206 | if (opts & OPT_c) { |