Skip to content

Commit 60de58a

Browse files
committed
mkcomposefs: make it cpuset aware
use sched_getaffinity to get the CPUs that can be used. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent bc4dd1a commit 60de58a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/mkcomposefs.c

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/fsverity.h>
3939
#include <linux/fs.h>
4040
#include <pthread.h>
41+
#include <sched.h>
4142
#include <sys/sysinfo.h>
4243

4344
static void oom(void)
@@ -1442,6 +1443,11 @@ static void digest_to_string(const uint8_t *csum, char *buf)
14421443

14431444
static int get_cpu_count(void)
14441445
{
1446+
cpu_set_t set;
1447+
1448+
if (sched_getaffinity(0, sizeof(set), &set) == 0)
1449+
return CPU_COUNT(&set);
1450+
14451451
return get_nprocs();
14461452
}
14471453

0 commit comments

Comments
 (0)