1. Field of the Invention
The present invention relates generally to the data processing field, and more particularly, to a method and system for detecting and reporting an excessive period of interrupt disablement in operating system programming in a data processing system.
2. Description of the Related Art
Operating system programming must frequently disable itself for interrupts when executing a “critical section” of code. Disablement is necessary for the code to serialize itself and to guarantee correctness. If, however, the amount of time spent disabled is excessive, performance problems can arise, particularly when the disablement conflicts with real time applications or with timing sensitive device drivers. Unfortunately, excessive periods of disablement are rarely detected, enabling them to escape into the field where they often lead to difficulties at customer sites.
One way to detect excessive periods of disablement of operating system programming is to add timing code on all critical paths of the operating system, in particular, those which either disable or enable for interrupts, and thereby accurately measure the disabled periods. Such an approach, however, would add significant overhead to an operating system since interrupt disablement and re-enablement is an extremely frequent and performance critical operation. Interrupt handling is also always disabled and would need to be timed in this manner, as well.
There is, accordingly, a need for a method and system for detecting and reporting an excessive period of interrupt disablement in operating system programming in a data processing system that does not add significant overhead to the operating system.
The present invention provides a method and system for detecting and reporting an excessive period of interrupt disablement in operating system programming in a data processing system. A method for detecting and reporting an excessive period of disablement in operating system programming in a data processing system includes determining, at a plurality of scheduled times, if an operating system task is running disabled for interrupts, and reporting an excessive disablement if the operating system task runs disabled for interrupts for a predefined number of consecutive scheduled times.
The novel features believed characteristic of the invention are set forth in the appended claims. The invention itself, however, as well as a preferred mode of use, further objectives and advantages thereof, will best be understood by reference to the following detailed description of an illustrative embodiment when read in conjunction with the accompanying drawings, wherein:
With reference now to the figures,
In the depicted example, server 104 and server 106 connect to network 102 along with storage unit 108. In addition, clients 110, 112, and 114 connect to network 102. These clients 110, 112, and 114 may be, for example, personal computers or network computers. In the depicted example, server 104 provides data, such as boot files, operating system images, and applications to clients 110, 112, and 114. Clients 110, 112, and 114 are clients to server 104 in this example. Network data processing system 100 may include additional servers, clients, and other devices not shown.
In the depicted example, network data processing system 100 is the Internet with network 102 representing a worldwide collection of networks and gateways that use the Transmission Control Protocol/Internet Protocol (TCP/IP) suite of protocols to communicate with one another. At the heart of the Internet is a backbone of high-speed data communication lines between major nodes or host computers, consisting of thousands of commercial, government, educational and other computer systems that route data and messages. Of course, network data processing system 100 also may be implemented as a number of different types of networks, such as for example, an intranet, a local area network (LAN), or a wide area network (WAN).
With reference now to
In the depicted example, data processing system 200 employs a hub architecture including north bridge and memory controller hub (MCH) 202 and south bridge and input/output (I/O) controller hub (ICH) 204. Processing unit 206, main memory 208, and graphics processor 210 are connected to north bridge and memory controller hub 202. Graphics processor 210 may be connected to north bridge and memory controller hub 202 through an accelerated graphics port (AGP).
In the depicted example, local area network (LAN) adapter 212 connects to south bridge and I/O controller hub 204. Audio adapter 216, keyboard and mouse adapter 220, modem 222, read only memory (ROM) 224, hard disk drive (HDD) 226, CD-ROM drive 230, universal serial bus (USB) ports and other communications ports 232, and PCI/PCIe devices 234 connect to south bridge and I/O controller hub 204 through bus 238 and bus 240. PCI/PCIe devices may include, for example, Ethernet adapters, add-in cards and PC cards for notebook computers. PCI uses a card bus controller, while PCIe does not. ROM 224 may be, for example, a flash binary input/output system (BIOS).
Hard disk drive 226 and CD-ROM drive 230 connect to south bridge and I/O controller hub 204 through bus 240. Hard disk drive 226 and CD-ROM drive 230 may use, for example, an integrated drive electronics (IDE) or serial advanced technology attachment (SATA) interface. Super I/O (SIO) device 236 may be connected to south bridge and I/O controller hub 204.
An operating system runs on processing unit 206 and coordinates and provides control of various components within data processing system 200 in
As a server, data processing system 200 may be, for example, an IBM eServer™ pSeries® computer system, running the Advanced Interactive Executive (AIX®) operating system or LINUX operating system (eServer, pSeries and AIX are trademarks of International Business Machines Corporation in the United States, other countries, or both while Linux is a trademark of Linus Torvalds in the United States, other countries, or both). Data processing system 200 may be a symmetric multiprocessor (SMP) system including a plurality of processors in processing unit 206. Alternatively, a single processor system may be employed.
Instructions for the operating system, the object-oriented programming system, and applications or programs are located on storage devices, such as hard disk drive 226, and may be loaded into main memory 208 for execution by processing unit 206. The processes for embodiments of the present invention are performed by processing unit 206 using computer usable program code, which may be located in a memory such as, for example, main memory 208, read only memory 224, or in one or more peripheral devices 226 and 230.
Those of ordinary skill in the art will appreciate that the hardware in
In some illustrative examples, data processing system 200 may be a personal digital assistant (PDA), which is configured with flash memory to provide non-volatile memory for storing operating system files and/or user-generated data.
A bus system may be comprised of one or more buses, such as bus 238 or bus 240 as shown in
The present invention provides a method and system for detecting and reporting an excessive period of interrupt disablement in operating system programming in a data processing system. According to an exemplary embodiment of the invention, existing, regularly scheduled “timer tick” interrupts are used to profile the kernel's disablement behavior. Timer tick interrupts are typical of UNIX® systems; however, all operating systems generate periodic timer interrupts to guarantee proper time slicing behavior. Since these interrupts are relatively infrequent, for example, they occur every 10 ms on an AIX® system, the overhead added by detection code in the “tick” interrupt handling path is essentially negligible.
As each timer tick is fielded by OS 302, it interrupts another operating system task. If that task was already running partially disabled for interrupts, a tick count in a tick counter 306 is incremented in the context structure of the interrupted task. If the tick count reaches a predefined threshold indicating that the task has been disabled for an excessive period of time, that information is logged in log 308. The information in log 308 may then be used to assist a software developer or another entity in identifying problem areas that may benefit from redesign of code to prevent the excessive period of disablement.
In effect, the present invention records state information periodically (by counting ticks), and reports whenever any piece of kernel code remains disabled for more than a predefined amount of time. The present invention thus profiles disabled central processing unit (cpu) time to assist a developer in identifying problem areas in code that may need correcting.
A particular code may also be fully disabled for interrupts as opposed to being only partially disabled. In the partially disabled case, as indicated above, monitoring can be conducted as each “tick” occurs, and reported as soon as an offending code exceeds the predefined time limit. In the case of fully disabled code, however, the next regularly scheduled “tick” interrupt will be blocked (held pending in the hardware) so that any excessive period of disablement cannot be detected until the offending code re-enables for interrupts. According to an exemplary embodiment of the present invention, at that time, the interrupt is fielded and it is determined how late it is, using, for example, timing mechanism 310 in
An important advantage of the present invention is that it adds negligible overhead to an operating system. When a currently enabled code segment disables for interrupts, the tick count is merely zeroed in its machine context structure. Similarly, when a hardware interrupt is taken by the software, the tick count is initialized to zero in the interruption context. Also, as each timer tick interrupt is taken, if the interrupted code was running partially disabled, the tick count is incremented in the interrupted context, and an error is logged if the count exceeds a predefined threshold. In effect, the present invention adds one very fast operation (store a zero) to the very frequent “disable me for interrupts” path, another identical operation to the much less frequent general interrupt handler path, and the only slightly more expensive add, compare test if reporting is desired to the relatively infrequent “timer tick” path. In an AIX® system, for example, the operation would be executed only 100 times per second per cpu.
Inasmuch as the detection overhead is so small, it can be allowed to operate “live” on customer systems, not just in a special testing mode environment during development. As a result, the present invention enables problems triggered in a customer environment that might not occur on the test floor to be detected and logged before they become critical problems for the customer. Problems can also be detected in customer or vendor written kernel extensions and device drivers which are not subject to in-house testing.
According to an aspect of the present invention, because the POWER hardware will, when both an I/O (Input/Output) and a timer interrupt are pending simultaneously, always reflect the I/O interrupt to the software first, it is necessary to compare the current time of day in the first level I/O interrupt handler to that of the next expected tick interrupt. If the I/O interrupt is seen to be occurring at a time when a timer interrupt can be predicted to be pending, that I/O interrupt is used to potentially trigger logging and to suppress the normal logging that would occur when the expected timer interrupt subsequently occurs. In this way, false reporting by the timer interrupt handler that the I/O interrupt handler was what was disabled too long is avoided.
A detail in the AIX® system service that enables for interrupts can allow a pending timer (or I/O) interrupt to be deferred until after the system dispatcher has chosen a new thread to run. As described above, it is simply checked if the dispatch is occurring at a time when a timer interrupt can be predicted to be pending, and reported from the dispatcher, if necessary, in the context of the current thread. This is a relatively rare occurrence, however, caused because the enablement service has logic that may call the dispatcher to allow the running thread to be preempted before actually enabling for interrupts.
It will be appreciated that inasmuch as counting ticks is a sampling operation, absolute precision when measuring the duration of a disabled period is being sacrificed for overhead saved by not trying to be more precise. In order to minimize the chance of a false report, some minimum number of physical interrupts should be counted against a context (when partially disabled) as well as seeing it reach the threshold. On an idle cpu, the normal tick rate is usually decreased to reduce overhead. The present invention prevents such slow (long duration) ticks from being able to prematurely trigger logging.
Precision attainable with the present invention could be improved (with some increase in overhead) by generating more frequent timer interrupts. Doing so, however, could also result in a larger number of error reports for relatively harmless situations.
Interrupts can be nested. In other words, a “base level” kernel routine might be interrupted for one purpose; and, while that interrupt is being handled, another interrupt might interrupt the now running interrupt handling code, etc. The present invention provides a separate tick counter in every interruption context structure to prevent time spent in different levels of interrupt handling from being misapplied among themselves or against the base level code. Even so, with a timing granularity of 10 ms, there will be some imprecision as discussed above.
Although a principal objective of the present invention is to assist developers in redesigning code which runs disabled for too long, this may not be possible in the short term. In such circumstances, the present invention also provides a mechanism that can be used to explicitly exempt known violators to prevent error reports against known problem code that has not yet been repaired.
If the override flag is not set (No output of Step 408), a determination is made whether detection is off (Step 412). If the override flag has been set (Yes output of Step 408), missed ticks are set to zero and the override flag is reset (Step 414), and a determination is made whether detection is off (Step 412). If detection is off (Yes output of Step 412), the method ends. If detection is on (No output of Step 412), a determination is made whether the interrupted context is disabled (Step 416). If the interrupted context is disabled (Yes output of Step 416), a determination is made whether the context allows detection (Step 418). If the interrupted context is not disabled (No output of Step 416), a determination is made whether there are missed ticks (Step 420). If there are missed ticks (Yes output of Step 420), a determination is made whether the context allows detection (Step 418). If there are no missed ticks (No output of Step 420), the method ends.
If the context does not allow detection (No output of Step 418), the method ends. If the context does allow detection (Yes output of Step 418), the current context tick count is incremented by one, representing the effect of the scheduled timer tick, plus the number of missed ticks, representing that the scheduled interrupt may have been blocked for some time, (Step 422) as shown in
If the event count is less than required (Yes output of Step 428), a determination is made whether there are missed ticks (Step 432). If there are no missed ticks (No output of Step 432), the method ends. If there are missed ticks (Yes output of Step 432), the excessive disablement is logged (Step 430). The context is then disabled from future detection (Step 434), and the method ends.
The present invention thus provides a method and system for detecting and reporting an excessive period of interrupt disablement in operating system programming in a data processing system. A method for detecting and reporting an excessive period of disablement in operating system programming in a data processing system includes determining, at a plurality of scheduled times, if an operating system task is running disabled for interrupts, and reporting an excessive disablement if the operating system task runs continuously disabled for interrupts for a predefined number of consecutive scheduled times.
The invention can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both hardware and software elements. In a preferred embodiment, the invention is implemented in software, which includes but is not limited to firmware, resident software, microcode, etc.
Furthermore, the invention can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system. For the purposes of this description, a computer-usable or computer readable medium can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
The medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium. Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk and an optical disk. Current examples of optical disks include compact disk—read only memory (CD-ROM), compact disk—read/write (CD-R/W) and DVD.
A data processing system suitable for storing and/or executing program code will include at least one processor coupled directly or indirectly to memory elements through a system bus. The memory elements can include local memory employed during actual execution of the program code, bulk storage, and cache memories which provide temporary storage of at least some program code in order to reduce the number of times code must be retrieved from bulk storage during execution.
Input/output or I/O devices (including but not limited to keyboards, displays, pointing devices, etc.) can be coupled to the system either directly or through intervening I/O controllers.
Network adapters may also be coupled to the system to enable the data processing system to become coupled to other data processing systems or remote printers or storage devices through intervening private or public networks. Modems, cable modem and Ethernet cards are just a few of the currently available types of network adapters.
The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiment was chosen and described in order to best explain the principles of the invention, the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
Number | Name | Date | Kind |
---|---|---|---|
5708417 | Tallman et al. | Jan 1998 | A |