diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 1ab12c80f..a48c30458 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -592,7 +592,7 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma const struct spdk_vhost_dev_backend *backend) { char path[PATH_MAX]; - struct spdk_cpuset *cpumask; + struct spdk_cpuset cpumask = {}; int rc; assert(vdev); @@ -601,13 +601,7 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma return -EINVAL; } - cpumask = spdk_cpuset_alloc(); - if (!cpumask) { - SPDK_ERRLOG("spdk_cpuset_alloc failed\n"); - return -ENOMEM; - } - - if (vhost_parse_core_mask(mask_str, cpumask) != 0) { + if (vhost_parse_core_mask(mask_str, &cpumask) != 0) { SPDK_ERRLOG("cpumask %s is invalid (app mask is 0x%s)\n", mask_str, spdk_cpuset_fmt(spdk_app_get_core_mask())); rc = -EINVAL; @@ -636,7 +630,7 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma goto out; } - vdev->cpumask = cpumask; + spdk_cpuset_copy(&vdev->cpumask, &cpumask); vdev->registered = true; vdev->backend = backend; TAILQ_INIT(&vdev->vsessions); @@ -658,7 +652,6 @@ vhost_dev_register(struct spdk_vhost_dev *vdev, const char *name, const char *ma return 0; out: - spdk_cpuset_free(cpumask); return rc; } @@ -681,7 +674,6 @@ vhost_dev_unregister(struct spdk_vhost_dev *vdev) free(vdev->name); free(vdev->path); - spdk_cpuset_free(vdev->cpumask); TAILQ_REMOVE(&g_vhost_devices, vdev, tailq); return 0; } @@ -711,7 +703,7 @@ const struct spdk_cpuset * spdk_vhost_dev_get_cpumask(struct spdk_vhost_dev *vdev) { assert(vdev != NULL); - return vdev->cpumask; + return &vdev->cpumask; } struct vhost_poll_group * diff --git a/lib/vhost/vhost_blk.c b/lib/vhost/vhost_blk.c index 523ce51f1..71b3e1c84 100644 --- a/lib/vhost/vhost_blk.c +++ b/lib/vhost/vhost_blk.c @@ -792,7 +792,7 @@ vhost_blk_start(struct spdk_vhost_session *vsession) { struct vhost_poll_group *pg; - pg = vhost_get_poll_group(vsession->vdev->cpumask); + pg = vhost_get_poll_group(&vsession->vdev->cpumask); return vhost_session_send_event(pg, vsession, vhost_blk_start_cb, 3, "start session"); } @@ -891,7 +891,7 @@ vhost_blk_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write_ spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_string(w, "ctrlr", vdev->name); spdk_json_write_named_string(w, "dev_name", spdk_bdev_get_name(bvdev->bdev)); - spdk_json_write_named_string(w, "cpumask", spdk_cpuset_fmt(vdev->cpumask)); + spdk_json_write_named_string(w, "cpumask", spdk_cpuset_fmt(&vdev->cpumask)); spdk_json_write_named_bool(w, "readonly", bvdev->readonly); spdk_json_write_object_end(w); diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index 377903956..0057fc0dc 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -157,7 +157,7 @@ struct spdk_vhost_dev { char *name; char *path; - struct spdk_cpuset *cpumask; + struct spdk_cpuset cpumask; bool registered; uint64_t virtio_features; diff --git a/lib/vhost/vhost_rpc.c b/lib/vhost/vhost_rpc.c index 1b4fb2863..5eff6f165 100644 --- a/lib/vhost/vhost_rpc.c +++ b/lib/vhost/vhost_rpc.c @@ -372,7 +372,7 @@ _spdk_rpc_get_vhost_controller(struct spdk_json_write_ctx *w, struct spdk_vhost_ spdk_json_write_object_begin(w); spdk_json_write_named_string(w, "ctrlr", spdk_vhost_dev_get_name(vdev)); - spdk_json_write_named_string_fmt(w, "cpumask", "0x%s", spdk_cpuset_fmt(vdev->cpumask)); + spdk_json_write_named_string_fmt(w, "cpumask", "0x%s", spdk_cpuset_fmt(&vdev->cpumask)); spdk_json_write_named_uint32(w, "delay_base_us", delay_base_us); spdk_json_write_named_uint32(w, "iops_threshold", iops_threshold); spdk_json_write_named_string(w, "socket", vdev->path); diff --git a/lib/vhost/vhost_scsi.c b/lib/vhost/vhost_scsi.c index 2d611cb19..ef9edd09b 100644 --- a/lib/vhost/vhost_scsi.c +++ b/lib/vhost/vhost_scsi.c @@ -1367,7 +1367,7 @@ vhost_scsi_start(struct spdk_vhost_session *vsession) svsession->svdev = svdev; if (svdev->vdev.active_session_num == 0) { - svdev->poll_group = vhost_get_poll_group(svdev->vdev.cpumask); + svdev->poll_group = vhost_get_poll_group(&svdev->vdev.cpumask); } return vhost_session_send_event(svdev->poll_group, vsession, @@ -1521,7 +1521,7 @@ vhost_scsi_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_write spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_string(w, "ctrlr", vdev->name); - spdk_json_write_named_string(w, "cpumask", spdk_cpuset_fmt(vdev->cpumask)); + spdk_json_write_named_string(w, "cpumask", spdk_cpuset_fmt(&vdev->cpumask)); spdk_json_write_object_end(w); spdk_json_write_object_end(w);