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

Enhance support for real time workloads #6182

Merged
merged 3 commits into from Oct 6, 2021

Conversation

jordigilh
Copy link
Contributor

@jordigilh jordigilh commented Aug 3, 2021

What this PR does / why we need it:

This PR aims to improve the support for real-time workloads and tune the libvirt's XML for low CPU latency. The motivation for this change is to make kubevirt aware of realtime workloads and tune libvirt's XML to reduce the CPU latency, following libvirt's recommendation. It archieves this goal by implementing the following changes:

  • Extends the VMI schema to add a new knob structure inside spec.domain.cpu named realtime. This new knob is on itself a new structure that so far only contains the field mask. The mask field allows the user to define the range of vcpus to pin in the vcpusched xml field for scheduling type as fifo priority 1. If this field is left undefined, the logic will pin all allocated vcpus for real-time workload.

Example when enabling the realtime knob without defining the mask:

    spec:
      domain:
        cpu:
          realtime: {}
  • When the realtime knob is enabled, the virt-launcher will add the following libvirt XML elements:
  • When huge pages is supported
    • <nosharepages/>
    • virt-handler will set the memory lock limits for the qemu-kvm process.
  • Disable the Performance Monitoring Unit in the Features section:
    • <pmu state="off"/>
  • Add the vcpusched element in the CPUTune section:
    • <vcpusched scheduler="fifo" priority="1" vcpus="<pinned vcpus>">
  • Nodes that support realtime workloads (kernel setting kernel.sched_rt_runtime_us=-1 to allow unlimited runtime of processes running with realtime scheduling) will be labeled with kubevirt.io/realtime.
  • When deploying a VMI that has the realtime knob enabled in its manifest, the generated pod manifest will be mutated to include the node label selector kubevirt.io/realtime, so that the pod is scheduled to run in a node that supports realtime workloads.
  • In short, a VMI with the realtime knob enabled will require a node that is capable of running realtime workloads ( kubevirt.io/realtime label), is able to isolate CPUs (cpumanager=true label) and has been configured with hugepages.
  • It also includes a commit for a test that will run a realtime cpu latency tool (cyclictest) to measure the CPU latency in the VM. There is another PR in the project-infra that will trigger the job periodically.

Example of a complete VM manifest:

---
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  labels:
    kubevirt.io/vm: vm-realtime
  name: vm-realtime
  namespace: poc
spec:
  running: true
  template:
    metadata:
      labels:
        kubevirt.io/vm: vm-realtime
    spec:
      domain:
        devices:
          autoattachSerialConsole: true
          autoattachMemBalloon: false
          autoattachGraphicsDevice: false
          disks:
          - disk:
              bus: virtio
            name: containerdisk      
        machine:
          type: ""
        resources:
          requests:
            memory: 4Gi
            cpu: 2
          limits:
            memory: 4Gi
            cpu: 2
        cpu:
          model: host-passthrough
          cores: 2
          sockets: 1
          threads: 1
          dedicatedCpuPlacement: true
          isolateEmulatorThread: true
          ioThreadsPolicy: auto
          features:
            - name: tsc-deadline
              policy: require
          numa:
            guestMappingPassthrough: {}
          realtime: {}
        memory:
          hugepages:
            pageSize: 1Gi
          guest: 3Gi
      terminationGracePeriodSeconds: 0
      volumes:
      - containerDisk:
          image: quay.io/jordigilh/centos8-realtime:latest
        name: containerdisk

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

TBD

Special notes for your reviewer:

/cc @rmohr @vladikr @davidvossel
/cc @pkliczewski @fabiand

Release note:

adds support for real time workloads

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: no Indicates the PR's author has not DCO signed all their commits. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 3, 2021
@kubevirt-bot kubevirt-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Aug 3, 2021
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2021
@jordigilh jordigilh force-pushed the poc_cnv_rt_locked_field branch 2 times, most recently from 31512e3 to 2f30de5 Compare August 6, 2021 00:43
@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Aug 6, 2021
@jordigilh jordigilh force-pushed the poc_cnv_rt_locked_field branch 4 times, most recently from 1caaa4a to 5c62642 Compare August 6, 2021 19:20
@jordigilh jordigilh changed the title [WIP] Enhance support for real time workloads Enhance support for real time workloads Aug 6, 2021
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 6, 2021
@jordigilh
Copy link
Contributor Author

@vladikr @davidvossel @rmohr I've finished implementing the changes for the real-time enhancements. Can you take a look whenever you have time?

Thanks!

/Jordi

Copy link
Member

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

any thoughts on how to approach functional testing? I don't think it's realistic to actually test realtime consistency or anything with the way our CI is set up. However, there should be some basic validations we can test to ensure realtime guests bootup properly.

hack/builder/Dockerfile Outdated Show resolved Hide resolved
staging/src/kubevirt.io/client-go/api/v1/schema.go Outdated Show resolved Hide resolved
staging/src/kubevirt.io/client-go/api/v1/schema.go Outdated Show resolved Hide resolved
api/api-rule-violations.list Outdated Show resolved Hide resolved
staging/src/kubevirt.io/client-go/api/v1/schema.go Outdated Show resolved Hide resolved
pkg/virt-launcher/virtwrap/converter/numa_placement.go Outdated Show resolved Hide resolved
@kubevirt-bot kubevirt-bot added dco-signoff: no Indicates the PR's author has not DCO signed all their commits. size/L and removed dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XL labels Aug 10, 2021
@jordigilh
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.22-sig-compute-realtime

@jordigilh
Copy link
Contributor Author

/test pull-kubevirt-e2e-kind-1.19-sriov

@jordigilh
Copy link
Contributor Author

@davidvossel @rmohr @vladikr @fabiand Development for this PR is completed. When you have time, can you take a look and let me know what you think? Thanks!

Signed-off-by: Jordi Gil <jgil@redhat.com>
@jordigilh
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.22-sig-compute-realtime

@jordigilh
Copy link
Contributor Author

/retest

Signed-off-by: Jordi Gil <jgil@redhat.com>
@jordigilh
Copy link
Contributor Author

/retest

@jordigilh
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.22-sig-compute-realtime

@vladikr
Copy link
Member

vladikr commented Oct 6, 2021

/approve
This looks very good to me. Thank you @jordigilh for this effort!

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vladikr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 6, 2021
@vladikr
Copy link
Member

vladikr commented Oct 6, 2021

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2021
@jordigilh
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.20-sig-compute-nonroot

@vladikr
Copy link
Member

vladikr commented Oct 6, 2021

@jordigilh perhaps you could also add a user-guide section about this.

@jordigilh
Copy link
Contributor Author

/retest

1 similar comment
@jordigilh
Copy link
Contributor Author

/retest

@kubevirt-bot kubevirt-bot merged commit d64731b into kubevirt:main Oct 6, 2021
@fabiand
Copy link
Member

fabiand commented Oct 7, 2021

I can just second Vladik - Thank you very much for this contribution! And all the work that specifically went into testing it.

@fabiand
Copy link
Member

fabiand commented Oct 7, 2021

@jordigilh did you also add a user-guide section for this new feature?
And a blog might also be a good thing to close this topic a little more

@jordigilh
Copy link
Contributor Author

I can just second Vladik - Thank you very much for this contribution! And all the work that specifically went into testing it.

Thanks! it was a pleasure working in this project 😄

@jordigilh
Copy link
Contributor Author

@jordigilh did you also add a user-guide section for this new feature? And a blog might also be a good thing to close this topic a little more

I plan to write a user-guide. I can also do the blog post as well 😄 . I'll PM you about it.

@jordigilh
Copy link
Contributor Author

@jordigilh perhaps you could also add a user-guide section about this.

Yep, I'll work on that as soon as the other related PRs in project-infra and kubevirtci are merged 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/monitoring dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants