Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread-context: support new object thread-context #3726

Merged

Conversation

mcasquer
Copy link
Contributor

thread-context: support new object thread-context

Includes support in avocado-vt for a new object:
thread-context. The intention of this new object
is to be used to make NUMA aware of the memory
preallocation threads.

ID: 2224513
Signed-off-by: mcasquer [email protected]

@@ -1252,6 +1252,13 @@ def set_value(opt_string, key, fallback=None):

return secret_cmdline + " -spice %s" % (",".join(spice_opts))

def add_thread_context(devices, params):
devs = []
dev = devices.thread_context_define_by_params(params, "tc1")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the ID has been hardcoded, how should I proceed? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it configurable usually we would introduce a param to let user specify the id of the logical device(s), see the example below. And such a param is also in charge of pointing out the counts of devices, usually, from 0 up to N.

Looks we could introduce a new one for the thread context objects, and I'd suggest using vm_thread_contexts or vm_thread_context_objects as the name.

(btw, can we add multiple thread context objects to a guest?)

for group in params.objects("throttle_groups"):

throttle_groups = tg1 tg2 tg3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(btw, can we add multiple thread context objects to a guest?)

@luckyh actually it's supported by QEMU, but let me confirm if it is feasible/makes sense

@mcasquer
Copy link
Contributor Author

A 'draft' debug.log has been attached to the corresponding bug

@mcasquer
Copy link
Contributor Author

@luckyh @PaulYuuu @YongxueHong could you review this PR? Thanks!

@mcasquer mcasquer force-pushed the 2224513_thread_context branch 2 times, most recently from fcc326f to 4fbc6f3 Compare July 28, 2023 08:13
@mcasquer mcasquer marked this pull request as ready for review July 28, 2023 09:35
Comment on lines 1536 to 1537
def __init__(self, backend, params=None):
super(ThreadContext, self).__init__(backend, params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, backend, params=None):
super(ThreadContext, self).__init__(backend, params)
def __init__(self, params=None):
super(ThreadContext, self).__init__("thread-context", params)

We could specify the backend as "thread-context" if we use the new subclass to represent the thread-context object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YongxueHong updated now!


def verify_hotplug(self, monitor):
"""Verify if it is plugged into VM."""
return self._query(monitor)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see the definition of the private method _query, just see it is implemented by class QIOThread(QObject) and QThrottleGroup(QObject). Please correct me if I was wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YongxueHong updated now!

virttest/qemu_devices/qcontainer.py Show resolved Hide resolved
thread_context_params = params.object_params(thread_context)
dev = devices.thread_context_define_by_params(thread_context_params, thread_context)
set_cmdline_format_by_cfg(dev, self._get_cmdline_format_cfg(),
"vm_thread_contexts")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think renaming the type name to thread_context(s) would be better.
_get_cmdline_format_cfg is in the qemu command context, so the vm_ prefix is unnecessary.

Also, the parameter names are not uniform. I think dev type defines the format of a kind of device, so it doesn't need to be represented in the plural(like thread_contexts, nics).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, thanks!

@mcasquer
Copy link
Contributor Author

@PaulYuuu @YongxueHong could you review this PR again? Thanks!

@mcasquer
Copy link
Contributor Author

Kindly reminder, @PaulYuuu @YongxueHong could you review again this PR? Thanks!

thread_context_params = params.object_params(thread_context)
dev = devices.thread_context_define_by_params(thread_context_params, thread_context)
set_cmdline_format_by_cfg(dev, self._get_cmdline_format_cfg(),
"thread_context")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"thread_context")
"thread_contexts")

I think it should be plural to correspond to the vm_thread_contexts
CC @nickzhq

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree, here the name is device type, a type should not be plural.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree, here the name is device type, a type should not be plural.

I remember that it is not just related to a device type but relates to a vt object, like, images, monitors, mem_devs, and so on.
Here we set the cmd line format base on the object vm_thread_contexts which is defined by vt.

Hi @nickzhq
Please correct me if I was wrong since you developed this part.
Thanks.

Copy link
Contributor

@nickzhq nickzhq Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vm_thread_contexts

Hello @YongxueHong ,
in the beginning of vt json format design, the vt object is preferred instead device type. Among images, monitors, mem_devs are the concepts of vt framework.
For my opinion, use the object which is defined by vt.

Thanks!
cc @PaulYuuu @mcasquer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vm_thread_contexts

Hello @YongxueHong , in the beginning of vt json format design, the vt object is preferred instead device type. Among images, monitors, mem_devs are the concepts of vt framework. For my opinion, use the object which is defined by vt.

Thanks! cc @PaulYuuu @mcasquer

OK, if it is VT type, then this is good to me, but we still have a mix in the current VT code, like tpm vs tpms

avocado-vt/virttest/qemu_vm.py

Lines 2670 to 2677 in 7c6bf78

# Add TPM devices
for tpm in params.objects("tpms"):
tpm_params = params.object_params(tpm)
devs = devices.tpm_define_by_params("%s_%s" % (self.name, tpm),
tpm_params)
for dev in devs:
set_cmdline_format_by_cfg(dev, self._get_cmdline_format_cfg(),
"tpm")

Comment on lines 2904 to 2908
prefix = 'vm_thread_context_'
for key in list(params.keys()):
if key.startswith(prefix):
new_key = key.rsplit(prefix)[1]
tc_params[new_key] = params[key]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mcasquer
I did not get the point of this part, why do we still need to filter the parameters by the prefix vm_thread_context_ to get the related key values?
And how do we handle those params which are without the prefix vm_thread_context_? ignore them?
Would you like to provide an example cfg?

IMO, I think that the argument params of thread_context_define_by_params already represents the related parameters of the thread-context object, so we don't filter them again.
like the implementation throttle_groups

avocado-vt/virttest/qemu_vm.py

Lines 2237 to 2243 in ac53d1f

# Add object throttle group
for group in params.objects("throttle_groups"):
group_params = params.object_params(group)
dev = devices.throttle_group_define_by_params(group_params, group)
set_cmdline_format_by_cfg(dev, self._get_cmdline_format_cfg(),
"images")
devices.insert(dev)

def throttle_group_define_by_params(self, group_params, name):
props = json.loads(group_params.get("throttle_group_parameters", "{}"))
return QThrottleGroup(name, props)

Please correct me if I misunderstood, Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YongxueHong
If I skip this filtering, then all the params will compose the qemu-kvm cmd line, maybe this is related with the cfg file, what do you think?
e.g.

[stdlog]     -rf %s,indirect_image_blacklist=/dev/hda[\d]* /dev/sda[\d]* /dev/sg0 /dev/md0,inactivity_treshold=3600,inactivity_watcher=log,vfd_size=1440k,install_virtio=no,enable_libvirtd_debug_log=yes,libvirtd_debug_level=2,libvirtd_log_cleanup=yes,enable_split_libvirtd_feature=no,enable_host_sosreport=no,enable_remote_host_sosreport=no,rpmbuild_path=/root/rpmbuild/,sysprep_required=no,sysprep_options=--operations machine-id,gcov_qemu=no,gcov_qemu_reset=yes,gcov_qemu_collect_cmd_opts=--html,gcov_qemu_compress=no,stress_install_from_repo=no,stress_args=--cpu 4 \
[stdlog]     --io 4 \
[stdlog]     --vm 2 \
[stdlog]     --vm-bytes 256M,download_url_stress=stress/stress-1.0.4.tar.gz,enable_guest_sosreport=no,gluster_managed_by_test=yes,vm_monitor_exit_status=no,kickstart_reboot_bug=no,force_reset_go_down_check=qmp,qemu_stop=on,qemu_preconfig=off,vm_type=qemu,kvm_ver_cmd=uname \
[stdlog]     -r,kvm_userspace_ver_cmd=rpm \
[stdlog]     -qa | grep \
[stdlog]     -E 'qemu-kvm(-(rhev|ma|core))?-[0-9]+\.' | head \

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mcasquer
I misunderstand, you are right.

"""
tc_params = Params()
prefix = 'vm_thread_context_'
for key in list(params.keys()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for key in list(params.keys()):
for key in params:

Looks like we could call the magic method __iter__ of the params object(class Params(IterableUserDict)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated now, thanks!

Includes support in avocado-vt for a new object:
thread-context. The intention of this new object
is to be used to make NUMA aware of the memory
preallocation threads.

Signed-off-by: mcasquer <[email protected]>
@mcasquer
Copy link
Contributor Author

@YongxueHong could you review again this PR? Thanks!

@mcasquer
Copy link
Contributor Author

@YongxueHong this is a kindly reminder, could you review again this PR? Thanks!

Copy link
Contributor

@YongxueHong YongxueHong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@YongxueHong
Copy link
Contributor

Thanks all,let's merge it.

@YongxueHong YongxueHong merged commit 1f33d7f into avocado-framework:master Aug 28, 2023
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants