# US 2012/0254893 A1 · Epoll optimisations

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

- Number: US 2012/0254893 A1
- Document ID: US20120254893A1
- Status: Published application
- Kind: A1
- Application number: 13/158,176
- Filed: 2011-06-10
- Published: 2012-10-04
- Earliest claimed: 2011-03-31
- Assignees: Solarflare Communications, Inc.
- Inventors: STEVEN L. POPE; DAVID J. RIDDOCH
- Web page: https://patentgrep.com/patent/US20120254893A1

## CPC

- G06F 9/545: {where tasks reside in different layers, e.g. user- and kernel-space}
- G06F 9/48: Program initiating; Program switching, e.g. by interrupt
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for managing I/O event notifications in a data processing system, the data processing system comprising a plurality of applications and an operating system having a kernel and an I/O event notification mechanism operable to maintain a plurality of I/O event notification objects each handling a set of file descriptors associated with one or more I/O resources, the method comprising: for each of a plurality of application-level configuration calls: intercepting at a user-level interface a configuration call from an application to the I/O event notification mechanism for configuring an I/O event notification object; and storing a set of parameters of the configuration call at a data structure, each set of parameters representing an operation on the set of file descriptors handled by the I/O event notification object; and subsequently, on a predetermined criterion being met: the user-level interface causing the plurality of configuration calls to be effected by means of a first system call to the kernel.

## Claims

### Claim 1

A method for managing I/O event notifications in a data processing system, the data processing system comprising a plurality of applications and an operating system having a kernel and an I/O event notification mechanism operable to maintain a plurality of I/O event notification objects each handling a set of file descriptors associated with one or more I/O resources, the method comprising:
for each of a plurality of application-level configuration calls:
intercepting at a user-level interface a configuration call from an application to the I/O event notification mechanism for configuring an I/O event notification object; and
storing a set of parameters of the configuration call at a data structure, each set of parameters representing an operation on the set of file descriptors handled by the I/O event notification object;
and subsequently, on a predetermined criterion being met:
the user-level interface causing the plurality of configuration calls to be effected by means of a first system call to the kernel.

### Claim 2 (depends on 1)

A method as claimed in claim 1, further comprising, subsequent to each intercepting step, returning processing to the application that made the respective configuration call.

### Claim 3 (depends on 1)

A method as claimed in claim 1, wherein the intercepting and storing steps are performed without invoking any system calls.

### Claim 4 (depends on 1)

A method as claimed in claim 1, wherein the I/O event notification mechanism is configured such that each file descriptor of an I/O event notification object is individually configurable by means of a configuration call from the application to the I/O event notification mechanism.

### Claim 5 (depends on 1)

A method as claimed in claim 1, wherein the step of causing the plurality of configuration calls to be effected comprises:
the user-level interface making the first system call to the kernel so as to pass the data structure to a kernel library; and
the kernel library invoking a configuration routine of the I/O event notification mechanism for each set of parameters stored in the data structure so as to configure the I/O event notification object in accordance with the configuration calls.

### Claim 6 (depends on 5)

A method as claimed in claim 5, wherein the data structure is passed to the kernel library by one of: passing a reference to the data structure, passing a copy of at least part of the data structure, and passing a representation of the data structure into the kernel context.

### Claim 7 (depends on 5)

A method as claimed in claim 5, wherein the I/O event notification mechanism is epoll and the configuration routine is epoll_ctl( ).

### Claim 8 (depends on 1)

A method as claimed in claim 1, wherein each operation on the set of file descriptors held by the I/O event notification object is an operation to add a file descriptor to the set, modify an event type to be monitored by the I/O event notification object in respect of a file descriptor of the set, or delete a file descriptor from the set of file descriptors.

### Claim 9 (depends on 1)

A method as claimed in claim 1, further comprising, prior to the invoking step:
combining into a single operation those operations represented by the sets of parameters stored at the data structure that are associated with the same file descriptor of the I/O event notification object; and
replacing the operations represented by those sets of parameters with the single operation in the invoking step.

### Claim 10 (depends on 9)

A method as claimed in claim 9, wherein the single operation is do nothing if the operations represented by the sets of parameters stored at the data structure cancel each other out.

### Claim 11 (depends on 9)

A method as claimed in claim 9, wherein the combining step is performed by the user-level interface or the kernel library.

### Claim 12 (depends on 1)

A method as claimed in claim 1, further comprising intercepting at the user-level interface a wait call from the application to the I/O event notification mechanism for causing the I/O event notification object to wait for an event associated with one or more of its file descriptors, and the predetermined criterion being the reception of a wait call from the application at the user-level interface.

### Claim 13 (depends on 12)

A method as claimed in claim 12, wherein the predetermined criterion is additionally met if no wait call is received at the user-level interface but one of the following occurs:
a predetermined time period expires; or
the storage space required at the data structure for storing the sets of parameters representing operations to be performed on the set of file descriptors handled by the I/O event notification object exceeds a predetermined size.

### Claim 14 (depends on 1)

A method as claimed in claim 1, further comprising, subsequent to the step of causing the plurality of configuration calls to be effected, the user-level interface causing the I/O event notification object to wait for an event associated with one or more of the file descriptors of the I/O event notification object by means of a second system call to the kernel.

### Claim 15 (depends on 14)

A method as claimed in claim 14, wherein the second system call is to the kernel library and the step of causing the I/O event notification object to wait for an event comprises invoking a wait routine of the I/O event notification mechanism.

### Claim 16 (depends on 15)

A method as claimed in claim 15, wherein the I/O event notification mechanism is epoll and the wait routine is epoll_wait( ) or epoll_pwait( ).

### Claim 17 (depends on 14)

A method as claimed in claim 14, wherein the first and second system calls are made by means of a single unified system call from the user-level interface to the kernel library.

### Claim 18 (depends on 1)

A method as claimed in claim 1, wherein the operating system comprises a plurality of I/O event notification objects and the user-level interface relates to a single I/O event notification object.

### Claim 19 (depends on 1)

A method as claimed in claim 1, wherein the I/O event notification object handles a set of file descriptors corresponding to a network interface device.

### Claim 20 (depends on 19)

A method as claimed in claim 19, wherein the file descriptors correspond to receive or transmit buffers.

### Claim 21 (depends on 1)

A method as claimed in claim 1, wherein the user-level interface is provided at a user-level network stack.

### Claim 22 (depends on 1)

A method as claimed in claim 1, further comprising the step of not enabling interrupts at the operating system in respect of file descriptors on which the operations represented by the sets of parameters stored at the data structure are operations to add or modify a file descriptor managed by the user-level network stack.

### Claim 23

A data processing system comprising:
a plurality of applications;
an operating system having a kernel and an I/O event notification mechanism operable to maintain a plurality of I/O event notification objects each handling a set of file descriptors associated with one or more I/O resources;
a data structure operable to store parameters of application-level configuration calls, each set of parameters representing an operation on the set of file descriptors handled by the I/O event notification object to which the respective configuration call is directed; and
a user-level interface configured to intercept a plurality of configuration calls from an application to the I/O event notification mechanism for configuring an I/O event notification object and store parameters of the configuration calls at the data structure;
wherein the user-level interface is configured to, on a predetermined criterion being met, cause the plurality of configuration calls to be effected by passing at least part of the data structure into the kernel context and invoking a system call to the kernel.

### Claim 24

A method for processing a blocking system call at a data processing system comprising an operating system that supports kernel and user-level contexts, the method comprising:
intercepting a blocking system call from an entity running a kernel or user-level context; and
repeatedly invoking the system call in non-blocking mode until one of the following conditions is satisfied:
a non-blocking system call returns a value; or
a first predetermined time period expires;
and
on one of the conditions being satisfied, returning to the entity a response to its blocking system call comprising a value returned by a non-blocking system call or a notification that the first predetermined time period expired.

### Claim 25 (depends on 24)

A method as claimed in claim 24, further comprising, on one of the conditions being satisfied, enabling interrupts for the entity on the entity next becoming blocked.

### Claim 26 (depends on 24)

A method as claimed in claim 24, wherein the first predetermined time period is a timeout of the entity indicating the maximum length of time before the blocking call is to return.

### Claim 27 (depends on 24)

A method as claimed in claim 24, wherein the step of repeatedly invoking the system call in non-blocking mode comprises:
repeatedly invoking the system call in non-blocking mode for no longer than a maximum length of time expressed by a second predetermined time period; and
if the second predetermined time period expires:
invoking the system call in blocking mode; and
enabling interrupts for the entity.

### Claim 28 (depends on 24)

A method as claimed in claim 24, wherein each non-blocking system call is invoked with a timeout parameter of zero.

### Claim 29 (depends on 24)

A method as claimed in claim 24, wherein the intercepting step is performed in the kernel context.

### Claim 30 (depends on 24)

A method as claimed in claim 24, wherein the intercepting step is performed at a user-level interface, the user-level interface:
replacing the blocking system call with a new system call; and
causing, by means of the new system call, the step of repeatedly invoking the system call to be performed in the kernel context.

### Claim 31 (depends on 24)

A method as claimed in claim 24, wherein the data processing system comprises a plurality of CPU cores.

### Claim 32 (depends on 24)

A method as claimed in claim 24, wherein the step of repeatedly invoking the system call in non-blocking mode further comprises not enabling interrupts for the entity whilst the system call is being repeatedly invoked in non-blocking mode.

### Claim 33 (depends on 24)

A method as claimed in claim 24, wherein the step of repeatedly invoking the system call in non-blocking mode further comprises not enabling interrupts for the entity in respect of the non-blocking system calls.

### Claim 34 (depends on 24)

A method as claimed in claim 24, wherein the operating system is Linux and the blocking system call is one of epoll( ), select( ), poll( ), read( ), write( ), send( ), recv( ), accept( ) and futex( ).
