vhost: Allow set cpumask more than active cores for vhost
The latest change for the portal group is applied to the vhost. The following comment is quoted from it. Currently the cpumask must be a subset of the reactor mask. However, this is different from sched_setaffinity() function and taskset command of FreeBSD and Linux. The latter will be familier for more people. Hence the later is adopted. The following is quoted from the FreeBSD Man Page of taskset: The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Not all CPUs may exist on a given system but a mask may specify more CPUs than are present. A retrieved mask will reflect only the bits that correspond to CPUs physically on the system. If an invalid mask is given (i.e., one that corresponds to no valid CPUs on the current system) an error is returned. The masks are typically given in hexadecimal. Change-Id: Idcd72a12ef52e4ccec8476e7d54fab82867cf936 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/392587 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1c54773979
commit
14797d839d
@ -472,18 +472,28 @@ spdk_vhost_dev_find(const char *ctrlr_name)
|
||||
static int
|
||||
spdk_vhost_parse_core_mask(const char *mask, uint64_t *cpumask)
|
||||
{
|
||||
char *end;
|
||||
int rc;
|
||||
|
||||
if (cpumask == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mask == NULL) {
|
||||
*cpumask = spdk_app_get_core_mask();
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
*cpumask = strtoull(mask, &end, 16);
|
||||
*cpumask = 0;
|
||||
|
||||
if (*end != '\0' || errno || !*cpumask ||
|
||||
((*cpumask & spdk_app_get_core_mask()) != *cpumask)) {
|
||||
rc = spdk_app_parse_core_mask(mask, cpumask);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("invalid cpumask %s\n", mask);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (*cpumask == 0) {
|
||||
SPDK_ERRLOG("no cpu is selected among reactor mask(=%jx)\n",
|
||||
spdk_app_get_core_mask());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -508,7 +518,7 @@ spdk_vhost_dev_construct(struct spdk_vhost_dev *vdev, const char *name, const ch
|
||||
}
|
||||
|
||||
if (spdk_vhost_parse_core_mask(mask_str, &cpumask) != 0) {
|
||||
SPDK_ERRLOG("cpumask %s not a subset of app mask 0x%jx\n",
|
||||
SPDK_ERRLOG("cpumask %s is invalid (app mask is 0x%jx)\n",
|
||||
mask_str, spdk_app_get_core_mask());
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ DEFINE_STUB(spdk_event_allocate, struct spdk_event *,
|
||||
DEFINE_STUB(spdk_mem_register, int, (void *vaddr, size_t len), 0);
|
||||
DEFINE_STUB(spdk_mem_unregister, int, (void *vaddr, size_t len), 0);
|
||||
DEFINE_STUB(spdk_app_get_core_mask, uint64_t, (void), 0);
|
||||
DEFINE_STUB(spdk_app_parse_core_mask, int, (const char *mask, uint64_t *cpumask), 0);
|
||||
DEFINE_STUB_V(spdk_app_stop, (int rc));
|
||||
DEFINE_STUB_V(spdk_event_call, (struct spdk_event *event));
|
||||
DEFINE_STUB(spdk_poller_register, struct spdk_poller *, (spdk_poller_fn fn, void *arg,
|
||||
|
Loading…
Reference in New Issue
Block a user