# Patent

## Title
Virtualization of a global interrupt queue

## Abstract

A method, system, and article of manufacture for processing virtual interrupts in a logically partitioned system are provided. An intelligent virtual global interrupt queue (virtual GIQ) that may be associated with a plurality of virtual processors running in a logical partition may be utilized. Upon receiving a virtual interrupt, the virtual GIQ may examine the operating states of the associated virtual processors. In an effort to ensure the virtual interrupt is processed as quickly as possible, the virtual GIQ may present the virtual interrupt to one of the associated virtual processors determined to be in an operating state best suited for processing the virtual interrupt.

## Background
CROSS-REFERENCE TO RELATED APPLICATIONS
The present application is related to U.S. patent application Ser. No. 10/403,158, filed Mar. 31, 2003, entitled “Apparatus and Method for Virtualizing Interrupts in a Logically Partitioned Computer System” and U.S. patent application Ser. No. 09/838,057, filed Apr. 19, 2001, entitled “Method and Apparatus for Allocating Processor Resources in a Logically Partitioned Computer System”, which is herein incorporated by reference in its entirety.
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention generally relates to logically partitioned computer systems and more particularly to processing virtual interrupts targeting a logical partition.
2. Description of the Related Art
In a computing environment, parallel processing generally refers to performing multiple computing tasks in parallel. Traditionally, parallel processing required multiple computer systems, with the resources of each computer system dedicated to a specific task, or allocated to perform a portion of a common task. However, recent advances in computer hardware and software technologies have resulted in single computer systems capable of highly complex parallel processing, by logically partitioning the system resources to different tasks. In a logically partitioned computer system, available system resources are allocated among multiple logical partitions, each designed to appear to operate independently of the other. Management of the allocation of resources among logical partitions is typically accomplished via a layer of software components, commonly referred to as a partition manager.
An objective of the partition manager is to allow each logical partition to independently run software (e.g., operating systems and operating system-specific applications), typically developed to run on a dedicated computer system, with little or no modification. For example, one logical partition may be running a first operating system, such as IBM's OS/400, a second logical partition may be running a second operating system, such as IBM's AIX, while a third logical partition may be running a third operating system, such as Linux. By providing the ability to run multiple operating systems on the same computer system, a logically partitioned system may provide a user with a greater degree of freedom in choosing application programs best suited to the user's needs with little or no regard to the operating system for which an application program was written.
The partition manager typically accomplishes the objective of allowing each of the logical partitions to independently run software by presenting each logical partition with a set of virtual resources (software components) that operate, from the perspective of the logical partition, in an identical manner to corresponding hardware components. In other words, the partition manager may allow each logical partition to, in affect, operate as an independent virtual computer system (or virtual machine) with its own set of virtual resources.
The virtual resources presented to each logical partition may include one or more virtual processors. The virtual processors for each partition may share the processing resources of one or more physical processors assigned to the partition. To provide support for other types of virtual devices and to allow multiple operating systems to share a processor on a partitioned system, the virtual processor may be able to process virtual interrupts. In other words, a virtual interrupt may be generated by a virtual device, just as an actual hardware device may generate an interrupt on a physical processor, or may be generated as a result of an actual hardware interrupt re-routed from a different partition than the one running a virtual processor receiving the virtual interrupt. Concepts of creating virtual interrupts are described in detail in the commonly owned patent application, Ser. No. 10/403,158, filed Mar. 31, 2003, entitled “Apparatus and Method for Virtualizing Interrupts in a Logically Partitioned Computer System,” which is herein incorporated by reference.
Computer systems with multiple physical processors, such as logically partitioned computer systems, may utilize an interrupt management mechanism (commonly referred to as a global interrupt queue) that essentially designates which of the physical processors in the system may be the target of an interrupt by an I/O device. Upon receiving an interrupt, global interrupt queue hardware (and/or software) may choose one of the associated physical processors for presentation of the interrupt, thereby spreading the overhead of interrupt processing among multiple processors. In some instances, a global interrupt queue may be designed to present an interrupt to a selected one of the physical processors that is in an executing state more favorable to processing the interrupt than others. For example, other physical processors may be busy processing other partition tasks or may already be processinganother interrupt (e.g., with a higher priority level).
As virtual processors are designed to behave in a similar manner to physical processors, a set of virtual processors assigned to a logical partition may also have executing states that are more favorable to processing virtual interrupts than others. To ensure an interrupt targeting the logical partition is handled as soon as possible, it would be desirable that the interrupt be presented to a virtual processor in the most favorable executing state. However, there is currently no mechanism (e.g., with functionality analogous to that of a global interrupt queue) for receiving a virtual interrupt and routing it to a virtual processor in an operating state most favorable for processing it.
Accordingly, there is a need for an improved method and system for processing virtual interrupts, for example, by implementing a virtual global interrupt queue configured to route virtual interrupts to virtual processors determined to be in operating states favorable for processing the virtual interrupts.
SUMMARY OF THE INVENTION
The present invention generally is directed to a method, article of manufacture, and system for processing a virtual interrupt.
One embodiment provides a method for processing a virtual interrupt. The method generally includes selecting one of a plurality of virtual processors for processing the virtual interrupt, based on operating states of at least one of the virtual processors and presenting the virtual interrupt to the selected virtual processor.
Another embodiment provides a method for selecting one of a plurality of virtual processors for presentation of a virtual interrupt. The method generally includes determining if any of the virtual processors is currently executing, if so, determining whether any executing virtual processor does not have a source of the virtual interrupt masked, and, if so, presenting the virtual interrupt to a virtual processor determined to be currently executing and to not have the virtual interrupt source masked.
Another embodiment provides a computer-readable medium containing a program for selecting one of a plurality of virtual processors for processing a virtual interrupt. When executed by a processor, the program performs operations generally including selecting, based on operating states of the virtual processors, one of the virtual processors for processing the virtual interrupt, and presenting the virtual interrupt to the selected virtual processor.
Another embodiment provides a logically partitioned computer system including at least one logical partition, a plurality of virtual processors associated with the logical partition, and a virtual global interrupt queue. The virtual global interrupt queue is generally configured to receive a virtual interrupt targeting the logical partition, select one of the virtual processors for processing the virtual interrupt based on operating states of at least one of the virtual processors, and present the virtual interrupt to the selected virtual processor.



BRIEF DESCRIPTION OF THE DRAWINGS
So that the manner in which the above recited features of the present invention are attained and can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to the embodiments thereof which are illustrated in the appended drawings.
It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments.
FIG. 1 is a logically partitioned computer system illustratively utilized in accordance with the present invention.
FIGS. 2A-C are a relational views of components in accordance with embodiments of the present invention.
FIG. 3 is a flow chart illustrating exemplary operations for processing a virtual interrupt in accordance with an embodiment of the present invention.
FIG. 4 is a flow chart illustrating exemplary operations for determining the operating state of a virtual processor in accordance with an embodiment of the present invention.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
The present invention generally is directed to a method, system, and article of manufacture for processing virtual interrupts in a logically partitioned system. Embodiments provide and utilize an intelligent virtual global interrupt queue (virtual GIQ) that may be associated with a plurality of virtual processors running in a logical partition. Upon receiving a virtual interrupt, the virtual GIQ may examine the operating states of the associated virtual processors. In an effort to ensure the virtual interrupt is processed as quickly as possible, the virtual GIQ may present the virtual interrupt to one of the associated virtual processors in an operating state best suited for processing the virtual interrupt.
One embodiment of the invention is implemented as a program product for use with a computer system such as, for example, the logically partitioned computer system 100 shown in FIG. 1 and described below. The program(s) of the program product defines functions of the embodiments (including the methods described herein) and can be contained on a variety of signal-bearing media. Illustrative signal-bearing media include, but are not limited to: (i) information permanently stored on non-writable storage media (e.g., read-only memory devices within a computer such as CD-ROM disks readable by a CD-ROM drive); (ii) alterable information stored on writable storage media (e.g., floppy disks within a diskette drive or hard-disk drive); or (iii) information conveyed to a computer by a communications medium, such as through a computer or telephone network, including wireless communications and the Internet.
In general, the routines executed to implement the embodiments of the invention, may be part of an operating system or a specific application, component, program, module, object, or sequence of instructions, including, for example, firmware embodied as a virtual global interrupt queue 126 that may be a component of a virtual interrupt management mechanism 124 of a partition manager 120 of the logically partitioned computer system 100 shown in FIG. 1. The software of the present invention typically is comprised of a multitude of instructions that will be translated by the native computer into a machine-readable format and hence executable instructions. Also, programs are comprised of variables and data structures that either reside locally to the program or are found in memory or on storage devices. In addition, various programs described hereinafter may be identified based upon the application for which they are implemented in a specific embodiment of the invention. However, it should be appreciated that any particular nomenclature that follows is used merely for convenience, and thus the invention should not be limited to use solely in any specific application identified or implied by such nomenclature.
AN EXEMPLARY LOGICALLY PARTITIONED SYSTEM
FIG. 1 illustrates a logically partitioned computer system 100 having one or more logical partitions 110 (shown as logical partitions 1101 through 110N to represent that any number N of logical partitions 110 may be supported). A partition manager 120 may generally control the creation and deletion of the logical partitions 110. Each logical partition 110 may have an associated operating system 112 running on one or more virtual processors 114 (which may share one or more physical processors 130). Concepts of virtual processors are described in detail in the commonly owned patent application, Ser. No. 09/838,057 filed Apr. 19, 2001, entitled “Method and Apparatus for Allocating Processor Resources in a Logically Partitioned Computer System,” which is herein incorporated by reference.
The computer system 100 may be any suitable type of computer system capable of supporting logical partitioning, such as a network server, mainframe computer, and the like. In one embodiment, the computer system 100 is an eServer iSeries computer system available from International Business Machines (IBM) of Armonk, N.Y. The computer system 100 generally includes one or more physical processors 130, coupled with memory 140. The system processors 130 may be allocated among the logical partitions 110 according to any suitable allocation arrangement.
For example, each logical partition 110 may have its own dedicated one or more of the system processors 130 or may share one or more of the system processors 130 with one or more other logical partitions 110. Each system processor 130 may run one or more of the virtual processors 114 of the logical partitions 110. The allocation of system processors 130, memory 140, as well as various other resources, such as I/O devices 152 (which may include a wide variety of I/O devices, as well as interface devices, such as I/O interfaces, storage interfaces, network interfaces, and the like) among the logical partitions 110 may be controlled by the partition manager 120.
As illustrated, the system 100 may include an interrupt controller 150 configured to receive interrupts generated by the I/O devices 152, and route the interrupts to one or more of the physical processors 130, as designated by the global interrupt queue 156. The partition manager 120 may include a virtual interrupt management mechanism 124 generally configured to receive interrupts from the physical processors 130 (e.g., as a result of I/O interrupts presented via the global interrupt queue 156) and route the interrupts to virtual processors 114 one of the logical partitions for processing.
The virtual interrupt management mechanism 124 may determine which of the logical partitions 110 is targeted by the interrupt, hiding such details from the physical processors 130. For example, the virtual interrupt management mechanism 124 may determine which logical partition 110 is targeted by the interrupt based on the interrupt source (e.g., as identified in an interrupt register 136 of the physical processors 130). In order to process the interrupt, a virtual interrupt may be presented to one of the virtual processors 114 running on the targeted logical partition 110. The virtual interrupt management mechanism 124 may also generate virtual interrupts in response to events occurring on one or more virtual devices 118.
VIRTUAL GLOBAL INTERRUPT QUEUE
In either case, the virtual processors 114 available for presentation of the virtual interrupt may be designated by a virtual GIQ 126 associated with the targeted logical partition 110. It should be noted that logical partitions 110 may be running virtual processors 114 that are not assigned to a virtual GIQ 126, with the implication that such virtual processors 114 will not receive virtual interrupts via the virtual GIQ 126. However, such virtual processors 114 may still receive virtual interrupts specifically targeting them that are not sent through the GIQ 126. As illustrated in FIGS. 2A and 2B, each logical partition 110 may have its own virtual GIQ 126 (e.g., virtual GIQs 1261-126N). Depending on the implementation, each virtual GIQ 126 may virtualize a hardware GIQ 156 dedicated to a corresponding logical partition 110, as shown in FIG. 2A, or the virtual GIQs 126 may collectively virtualize a hardware GIQ 156 shared among multiple logical partitions 110, as shown in FIG. 2B.
In either case, a virtual GIQ 126 may be generally configured to determine which of its associated virtual processors 114 is best suited to process the virtual interrupt based on their respective operating states. In making the determination, the virtual GIQ 126 may examine the operating states of its virtual processors 114 in order to establish whether one or more criteria favorable to processing a virtual interrupt have been satisfied. A variety of different operating state criteria may be applied to determine which virtual processor 114 is best suited to process a virtual interrupt, the particular details of which may vary with different embodiments.
Two examples of suitable criteria that may be applied when selecting a virtual processor for presentation of a virtual interrupt are whether the virtual processor is currently executing and whether the virtual processor has masked the source of the virtual interrupt, both of which may have an impact on how fast the virtual processor may process the virtual interrupt. For example, if a first virtual processor is not currently executing (e.g., the first processor has been preempted or yielded and a second virtual processor is executing), in order for the first virtual processor to process the virtual interrupt, the second virtual processor would have to first be preempted (e.g., its execution state saved, etc.) and there would be a delay while waiting for the second virtual processor to be dispatched. Whether a virtual processor is executing may be determined, for example, via a register in a control block (not shown) associated with the virtual processor.
Delays in processing the virtual interrupt may also be encountered if the virtual interrupt is sent to a virtual processor that has masked the source of the virtual interrupt. The exact technique for interrupt masking may vary with different processors. One common technique is to maintain a current interrupt priority level, whereby only interrupts received that have a higher interrupt priority level are processed. The concept of interrupt masking via interrupt priority levels is illustrated in FIG. 2C that shows two virtual processors, VP1 1141 and VP2 1142, having current interrupt priority levels of ‘05’ and ‘FF’ (e.g., hex ‘FF’=decimal ‘255’), respectively, with ‘FF’ being the lowest possible priority level, such that VP2 is masking no interrupts are masked. It is assumed, for this example, that both virtual processors VP1 and VP2 are executing. Upon receiving a virtual interrupt having a priority level of ‘10’ the virtual GIQ may determine that if presented to VP1, the virtual interrupt would not be processed (e.g., would be pending in VP1's interrupt queue) until VP1 has processed all currently pending interrupts having priority greater than ‘10.’ On the other hand, having a current interrupt priority level of ‘FF,’ VP2 could process the virtual interrupt immediately. Therefore, the virtual GIQ 126 presents the virtual interrupt to VP2.
AN EXEMPLARY METHOD FOR ROUTING VIRTUAL INTERRUPTS
FIG. 3 is a flow diagram that illustrates exemplary operations 300 that may be performed by a virtual GIQ 126, for example, to select a virtual processor best suited to process a virtual interrupt. The operations 300 begin at step 302, by receiving a virtual interrupt. As previously described, the virtual interrupt may be generated by a virtual device 118 on a partition (e.g., a software interrupt), or as a result of a hardware interrupt (e.g., from an I/O device 152). In either case, the virtual GIQ 126 attempts to determine which of its associated VPs are best suited to process the interrupt, for example, as previously described, by examining the operating state of each VP, in an effort to establish which VPs have satisfied of a set of criteria.
Therefore, at step 304, the virtual GIQ enters a loop of operations (306-312) to examine the operating state of each VP. At step 306, the virtual GIQ determines which operating state criteria the VP has met. For example, the virtual GIQ may call a routine that returns a value (VPCRIT) indicative of which of a predetermined set of criteria has been satisfied by the VP, based on the VPs operating state. As previously described, the criteria may include any suitable set of criteria that may be indicative of the VPs ability to process an interrupt in a timely fashion, and any suitable algorithm may be utilized to assign a value to VPCRIT based on which criteria are met.
For example, using the exemplary criteria described above, a VP may be assigned one of four values for VPCRIT shown in TABLE I, below. As shown, a value







TABLE I





EXAMPLE VP CRITERIA
















VPCRIT = 1
VP IS EXECUTING, INTERRUPT SOURCE IS NOT



MASKED


VPCRIT = 2
VP IS EXECUTING, INTERRUPT SOURCE IS MASKED


VPCRIT = 3
VP IS NOT EXECUTING, INTERRUPT SOURCE IS



NOT MASKED


VPCRIT = 4
VP IS NOT EXECUTING, INTERRUPT SOURCE IS



MASKED









of 1 for VPCRIT may correspond to the most preferred operating state, while a value of 4 for VPCRIT may correspond to the least preferred operating state. FIG. 4 illustrates a method for applying the specific set of operating state criteria listed in TABLE I above and returning the illustrated values for VPCRIT. The operations 400 begin, at step 402, by obtaining the execution status and current interrupt priority level of the selected virtual processor. For example, the virtual GIQ may read the current interrupt priority level from one of a set of virtual interrupt registers 116 associated with the virtual processor 114.

At step 404, a determination is made, as to whether the selected virtual processor is currently executing. If the selected virtual processor is executing, processing proceeds to step 403, where a determination is made as to whether the selected virtual processor has masked the virtual interrupt source. If the selected virtual processor has not masked the virtual interrupt source, a criteria level (VPCRIT) of 1 may be returned, at step 406, in this example, indicating the most favorable operating state (e.g., the selected virtual processor should be able to process the virtual interrupt immediately). On the other hand, if the selected virtual processor has masked the virtual interrupt source, a VPCRIT of 2 may be returned, at step 408. If the selected virtual processor is not executing, processing proceeds to step 410, to determine if the virtual processor has masked the virtual interrupt source. If not, a VPCRIT of 3 may be returned, at step 412, or if the virtual processor has masked the virtual interrupt source, a VPCRIT of 4 is returned, at step 414.
Referring back to FIG. 3, if a selected virtual processor has the most favored operating state (e.g., VPCRIT=1), as determined at step 308, there is no need to examine other virtual processors, as the currently selected virtual processor should be able to process the virtual interrupt immediately. Therefore, the virtual interrupt is presented to the selected virtual processor, at step 310. However, if the selected virtual processor has any operating state other than the most favorable (e.g., the virtual processor is not running or has masked the virtual interrupt source), the operating state is recorded, at step 312, for later comparisons. Processing then returns to step 304 to select the next virtual processor.
If none of the virtual processors is in the most favorable operating state, operations proceed to step 314, where the virtual interrupt is presented to the virtual processor having the most favorable operating state, relative to the other virtual processors. For example, the virtual GIQ may perform a simple routine to identify which virtual processor 114 has the lowest VPCRIT, as recorded at step 312, and present the virtual interrupt to the identified virtual processor 114. If more than one virtual processor has the same most favorable operating state (value of VPCRIT), the virtual GIQ 126 may arbitrarily present the virtual interrupt to either or perform arbitration, for example, considering other suitable criteria.
Of course, the operations 300 may be modified in various manners for different implementations. For example, rather than present the virtual interrupt to the virtual processor 114 having the most favorable operating state, the virtual GIQ 126 may require that a virtual processor 114 have met at least one of a set of criteria. For example, if none of the set of criteria are met, there may be no valid basis for predicting which of the virtual processors will be able to process the virtual interrupt first. Therefore, for some embodiments, if none of the virtual processors 114 associated with the virtual GIQ 126 have satisfied any of the criteria (e.g., none are executing and all have the virtual interrupt source masked), the virtual GIQ 126 may simply wait. For example, the virtual GIQ 126 may simply allow the virtual interrupt to remain pending until one of the associated virtual processors 114 satisfies at least one of the criteria.
CONCLUSION
Virtual interrupts are utilized to provide support for virtual devices and allow multiple operating systems to share physical processors in a logically partitioned computer system. By routing virtual interrupts to virtual processors that are in an optimal operating state for processing the virtual interrupts, embodiments of the present invention may ensure that virtual interrupts are processed in a timely manner.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.

## Claims

1. A method for selecting one of a plurality of virtual processors for presentation of a virtual interrupt, comprising:
determining if any of the virtual processors is currently executing;
if so, determining whether any executing virtual processor does not have a source of the virtual interrupt masked;
if so, presenting the virtual interrupt to a virtual processor determined to be currently executing and to not have the virtual interrupt source masked;
if none of the virtual processors is both currently executing and does not have a source of the virtual interrupt masked: determining if any of the virtual processors is currently executing and, if so, presenting the virtual interrupt to a virtual processor determined to be currently executing;
if none of the virtual processors is currently executing: determining if any of the virtual processors does not have the source of the virtual interrupt masked and, if so, presenting the virtual interrupt to a virtual processor determined to not have the source of the virtual interrupt masked; and
presenting the virtual interrupt to a virtual processor that is not currently executing and that has the source of the virtual interrupt masked only if none of the virtual processors is currently executing and each of the virtual processors have the source of the interrupt masked.

2. A logically partitioned computer system, comprising:
at least one logical partition;
a plurality of virtual processors associated with the logical partition;

a virtual global interrupt queue configured to receive a virtual interrupt targeting the logical partition, select one of the virtual processors for processing the virtual interrupt based on operating states of at least one of the virtual processors, and present the virtual interrupt to the selected virtual processor, wherein the virtual global interrupt queue is configured to present virtual interrupts to virtual processors that are not currently executing only if there are no virtual processors currently executing.

3. The logically partitioned computer system of claim 1, wherein the virtual global interrupt queue is configured to, if more than one virtual processor is executing:
present a virtual interrupt to an executing virtual processor that is masking a source of the virtual interrupt only if there are no executing virtual processors that are not masking the source of the virtual interrupt.

4. The logically partitioned computer system of claim 1, further comprising one or more virtual devices capable of generating virtual interrupts.

5. The logically partitioned computer system of claim 1, wherein the virtual global interrupt queue virtualizes a hardware global interrupt queue shared among more than one logical partition.

6. The logically partitioned computer system of claim 1, comprising:
at least one additional logical partition having a plurality of associated virtual processors; and
at least one additional virtual global interrupt queue associated with the at least one additional logical partition.