cpuset: fix parse_mask
The loop here was counting the bytes in the cpus array, but the lcores are represented by bits. While here, add a unit test that exposes this bug and demonstrates it is now fixed with this patch. Fixes #1570. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I3a1fc48a8085254f41587e3b3d5d732154b90134 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3931 Community-CI: Mellanox Build Bot Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
e25747e547
commit
150339cc59
@ -293,7 +293,7 @@ parse_mask(const char *mask, struct spdk_cpuset *set, size_t len)
|
|||||||
SPDK_ERRLOG("Invalid character in core mask '%s' (%c)\n", mask, c);
|
SPDK_ERRLOG("Invalid character in core mask '%s' (%c)\n", mask, c);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (j = 0; j < 4 && lcore < sizeof(set->cpus); j++, lcore++) {
|
for (j = 0; j < 4 && lcore < SPDK_CPUSET_SIZE; j++, lcore++) {
|
||||||
if ((1 << j) & val) {
|
if ((1 << j) & val) {
|
||||||
spdk_cpuset_set_cpu(set, lcore, true);
|
spdk_cpuset_set_cpu(set, lcore, true);
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,15 @@ test_cpuset_parse(void)
|
|||||||
rc = spdk_cpuset_parse(core_mask, "[184467440737095516150]");
|
rc = spdk_cpuset_parse(core_mask, "[184467440737095516150]");
|
||||||
CU_ASSERT(rc < 0);
|
CU_ASSERT(rc < 0);
|
||||||
|
|
||||||
|
/* Test mask with cores 4-7 and 168-171 set. */
|
||||||
|
rc = spdk_cpuset_parse(core_mask, "0xF0000000000000000000000000000000000000000F0");
|
||||||
|
CU_ASSERT(rc == 0);
|
||||||
|
CU_ASSERT(cpuset_check_range(core_mask, 0, 3, false) == 0);
|
||||||
|
CU_ASSERT(cpuset_check_range(core_mask, 4, 7, true) == 0);
|
||||||
|
CU_ASSERT(cpuset_check_range(core_mask, 8, 167, false) == 0);
|
||||||
|
CU_ASSERT(cpuset_check_range(core_mask, 168, 171, true) == 0);
|
||||||
|
CU_ASSERT(cpuset_check_range(core_mask, 172, SPDK_CPUSET_SIZE - 1, false) == 0);
|
||||||
|
|
||||||
spdk_cpuset_free(core_mask);
|
spdk_cpuset_free(core_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user