# US 10,871,982 B2 · Virtual processor scheduling via memory monitoring

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,871,982 B2
- Document ID: US10871982B2
- Status: Granted
- Kind: B2
- Application number: 16/037,970
- Filed: 2018-07-17
- Published: 2018-11-29
- Granted: 2020-12-22
- Earliest claimed: 2017-02-22
- Assignees: Red Hat, Inc.
- Applicants: Red Hat, Inc.
- Inventors: Michael Tsirkin
- Web page: https://patentgrep.com/patent/US10871982B2

## CPC

- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 3/0625: {Power saving in storage systems}
- G06F 3/0653: {Monitoring storage devices or systems}
- G06F 3/0673: {Single storage device}
- G06F 9/455: Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F 9/45533: {Hypervisors; Virtual machine monitors}
- G06F 9/46: Multiprogramming arrangements
- G06F 9/461: {Saving or restoring of program or task context}
- G06F 9/48: Program initiating; Program switching, e.g. by interrupt
- G06F 9/4806: {Task transfer initiation or dispatching}
- G06F 9/4812: {by interrupt, e.g. masked}
- G06F 9/4843: {by program, e.g. task dispatcher, supervisor, operating system}
- G06F 9/485: {Task life-cycle, e.g. stopping, restarting, resuming execution (G06F9/4881 takes precedence)}
- G06F 2009/45575: {Starting, stopping, suspending or resuming virtual machine instances}
- G06F 2009/45579: {I/O management, e.g. providing access to device drivers or storage}
- G06F 2009/45583: {Memory management, e.g. access or allocation}
- G06F 2009/45591: {Monitoring or debugging support}
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

Systems and methods for scheduling virtual processors via memory monitoring are disclosed. An example method comprises: detecting, by a hypervisor of a host computer system, an event associated with a virtual processor running on a physical processor of the host computer system; testing a polling flag residing in a memory accessible by guest software running on the virtual processor, wherein a first state of the polling flag indicates that the virtual processor is monitoring modifications to a memory region comprising a waiting task flag, and wherein the waiting task flag indicates whether a task has been queued for the virtual processor; setting the polling flag to a second state, wherein testing the polling flag and setting the polling flag to the second state is performed in an atomic operation; and processing the detected event.

## Claims

### Claim 1

A method, comprising:
configuring, by a hypervisor of a host computer system, a virtual machine control structure (VMCS) associated with a virtual machine to allow the virtual machine execute memory monitoring instructions without triggering a virtual machine exit event;
detecting, by the hypervisor, an event associated with a first virtual processor associated with the virtual machine;
testing a polling flag residing in a memory accessible by guest software running on the first virtual processor, wherein a first state of the polling flag indicates that the first virtual processor is monitoring modifications to a memory region comprising a waiting task flag, and wherein the waiting task flag indicates whether a task has been queued for the first virtual processor;
setting the polling flag to a second state, wherein the second state prevents a second virtual processor associated with the virtual machine from notifying the first virtual processor via the waiting task flag, and wherein testing the polling flag and setting the polling flag to the second state is performed in an atomic operation; and
processing the detected event.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
responsive to determining that testing the polling flag indicates the first state of the polling flag, quiescing the first virtual processor.

### Claim 3 (depends on 1)

The method of claim 1, further comprising:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is in an idle state indicating that no tasks have been queued for the first virtual processor, quiescing the first virtual processor.

### Claim 4 (depends on 1)

The method of claim 1, wherein processing the detected event further comprises:
scheduling the second virtual processor to run on the physical processor.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
receiving, from a virtual machine associated with the first virtual processor, an address of a data structure comprising the polling flag.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
transmitting, to a virtual machine associated with the first virtual processor, an address of a data structure comprising the polling flag.

### Claim 7 (depends on 1)

The method of claim 1, further comprising:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is set to indicate that a task has been queued for the first virtual processor, leaving the first virtual processor in a runnable state.

### Claim 8 (depends on 1)

The method of claim 1, wherein the detected event involves preempting a processing thread implementing the first virtual processor.

### Claim 9

A computer system, comprising:
a memory to store a data structure accessible by guest software running on a first virtual processor, the data structure comprising a polling flag and a waiting task flag associated with the first virtual processor; and
a processor, operatively coupled to the memory, to:
configure a virtual machine control structure (VMCS) associated with a virtual machine to allow the virtual machine execute memory monitoring instructions without triggering a virtual machine exit event;
detect an event associated with a first virtual processor associated with the virtual machine running on the processor;
test a polling flag residing in a memory accessible by guest software running on the first virtual processor, wherein a first state of the polling flag indicates that the first virtual processor is monitoring modifications to a memory region comprising a waiting task flag, and wherein the waiting task flag indicates whether a task has been queued for the first virtual processor;
set the polling flag to a second state, wherein the second state prevents a second virtual processor associated with the virtual machine from notifying the first virtual processor via the waiting task flag, and wherein testing the polling flag and setting the polling flag to the second state is performed in an atomic operation; and
process the detected event.

### Claim 10 (depends on 9)

The computer system of claim 9, wherein the processor is further to:
responsive to determining that testing the polling flag indicates the first state of the polling flag, quiesce the first virtual processor.

### Claim 11 (depends on 9)

The computer system of claim 9, wherein the processor is further to:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is in an idle state indicating that no tasks have been queued for the first virtual processor, quiesce the first virtual processor.

### Claim 12 (depends on 9)

The computer system of claim 9, wherein processing the detected event further comprises:
scheduling the second virtual processor to run on the physical processor.

### Claim 13 (depends on 9)

The computer system of claim 9, wherein the processor is further to:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is set to indicate that a task has been queued for the first virtual processor, leave the first virtual processor in a runnable state.

### Claim 14 (depends on 9)

The computer system of claim 9, wherein the detected event involves preempting a processing thread implementing the first virtual processor.

### Claim 15

A non-transitory computer-readable storage medium comprising executable instructions that, when executed by a physical processor of a host computer system, cause the physical processor to:
configure a virtual machine control structure (VMCS) associated with a virtual machine to allow the virtual machine execute memory monitoring instructions without triggering a virtual machine exit event;
detect an event associated with a first virtual processor associated with the virtual machine running on a physical processor of the host computer system;
test a polling flag residing in a memory accessible by guest software running on the first virtual processor, wherein a first state of the polling flag indicates that the first virtual processor is monitoring modifications to a memory region comprising a waiting task flag, and wherein the waiting task flag indicates whether a task has been queued for the first virtual processor;
set the polling flag to a second state, wherein the second state prevents a second virtual processor associated with the virtual machine from notifying the first virtual processor via the waiting task flag, and wherein testing the polling flag and setting the polling flag to the second state is performed in an atomic operation; and
process the detected event.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, further comprising executable instructions to cause the physical processor to:
responsive to determining that testing the polling flag indicates the first state of the polling flag, quiesce the first virtual processor.

### Claim 17 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, further comprising executable instructions to cause the physical processor to:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is in an idle state indicating that no tasks have been queued for the first virtual processor, quiesce the first virtual processor.

### Claim 18 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein processing the detected event further comprises:
scheduling the second virtual processor to run on the physical processor.

### Claim 19 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, further comprising executable instructions to cause the physical processor to:
responsive to determining that testing the polling flag indicates the first state of the polling flag and that the waiting task flag is set to indicate that a task has been queued for the first virtual processor, leave the first virtual processor in a runnable state.

### Claim 20 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein the detected event involves preempting a processing thread implementing the first virtual processor.
