CN115470014A - Method and device for acquiring task completion notification and method for directly accessing memory - Google Patents

Method and device for acquiring task completion notification and method for directly accessing memory Download PDF

Info

Publication number
CN115470014A
CN115470014A CN202211035562.0A CN202211035562A CN115470014A CN 115470014 A CN115470014 A CN 115470014A CN 202211035562 A CN202211035562 A CN 202211035562A CN 115470014 A CN115470014 A CN 115470014A
Authority
CN
China
Prior art keywords
limit
polling
counter
completion
count
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211035562.0A
Other languages
Chinese (zh)
Inventor
王芳
冯丹
施展
陈思新
帅晓雨
安行
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Mass Institute Of Information Technology
Huazhong University of Science and Technology
Original Assignee
Shandong Mass Institute Of Information Technology
Huazhong University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Mass Institute Of Information Technology, Huazhong University of Science and Technology filed Critical Shandong Mass Institute Of Information Technology
Priority to CN202211035562.0A priority Critical patent/CN115470014A/en
Publication of CN115470014A publication Critical patent/CN115470014A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/14Handling requests for interconnection or transfer
    • G06F13/20Handling requests for interconnection or transfer for access to input/output bus
    • G06F13/28Handling requests for interconnection or transfer for access to input/output bus using burst mode transfer, e.g. direct memory access DMA, cycle steal
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/544Remote
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method and a device for acquiring task completion notification and a method for directly accessing a memory, which belong to the field of computer network communication and comprise the following steps: when the system is started, setting two past counting records, wherein the two past counting records are initialized to the maximum value of the upper counting limit; when a new task completion notification is generated in the completion queue, performing a polling step, comprising: (S1) calculating the average value of past counting records as count _ limit; (S2) setting the value of the counter to be 0; (S3) polling the completion queue, and if a task completion notification exists, turning to (S4); otherwise, turning to (S5); (S4) after the task completion notification is obtained in batches, turning to (S2); (S5) after the value of the counter is added with 1, judging whether the counter < count _ limit is met, if so, turning to (S3); otherwise, quitting the polling mode and ending the polling step; and dynamically adjusting the past counting record according to the load. The invention can quickly acquire the task completion notification under the condition of not consuming excessive CPU resources.

Description

Method and device for acquiring task completion notification and method for directly accessing memory
Technical Field
The invention belongs to the field of computer network communication, and particularly relates to a method and a device for acquiring task completion notification and a method for directly accessing a memory.
Background
The Remote Direct Memory Access (RDMA) technology is a new type of Memory Access technology, and can realize Direct Memory Access from the Memory of one computer to the Memory of another computer.
In a traditional TCP/IP transmission flow, a CPU needs to copy data between a user space and a kernel space, and package and analysis of a data packet also needs the participation of the CPU in the whole process. Compared with the traditional TCP/IP network, RDMA has three advantages: (1) bypassing the kernel: the I/O flow can bypass the kernel, namely the data can be prepared and the hardware is informed to send and receive in the user mode, thereby avoiding the overhead of system calling and context switching; (2) zero copy: due to the inherent defects of a TCP/IP protocol stack, data needs to be copied back and forth in a user space and a kernel space in the process of sending and receiving the message, while RDMA does not need; (3) CPU unloading: the memory can be read and written under the condition that a CPU (central processing unit) of the remote node does not participate, and the encapsulation and the analysis of the message are actually finished by the RDMA network card. Compared with TCP/IP, RDMA has the advantages of low delay, high bandwidth and the like, so that the RDMA is widely applied to a data center.
One of the advantages of RDMA over TCP/IP is CPU offload, which does not require the involvement of a remote CPU during the transmission, but only requires the CPU to process in other links when RDMA READ/WRITE is used.
When the RDMA resource is initialized, a CPU is required to perform a series of operations, including obtaining an RDMA device list, opening the RDMA device, distributing a protection domain, registering a memory, creating a completion queue and creating a queue peer. Correspondingly, the CPU is also required to call the relevant interface execution function when destroying the resource. The CPU resource is only used during system initialization and shutdown, does not affect the transmission flow and cannot be omitted.
When data transmission is carried out, a CPU is required to package a transmission task into a RDMA Work Request (Work Request, WR) and transmit the RDMA Work Request (Work Request, WR) to an RDMA network card, and if RDMA SEND/RECV is used for data transmission, a batch of RECV WR is required to be prepared and transmitted to a receiving Queue (Recv Queue, RQ). In addition to the transmission of Work requests, the processing of task Completion notifications (WC) also requires CPU involvement. When a Completion Queue Element (CQE) is generated, the CPU needs to acquire a task Completion notification from the Completion Queue Element (CQ) and then process the task Completion notification. It is only after a task completion notification is processed that a transmission task is actually completed. The WR and WC processes must require the participation of the CPU, and checking whether there is a new CQE in the CQ is generated in a different manner and at a different CPU occupancy rate. The most basic ways to check whether a new CQE is generated in a CQ are two, namely, interrupt and poll.
The way of interrupting the CQE acquisition needs to use a multiplexing mechanism such as Epoll/Select/Kqueue to listen to the Completion Channel (CC) bound by the Completion queue CQ. When a new CQE is generated in the CQ, the file descriptor of the completion channel CC generates a readable event, which informs the CPU through an interrupt, the CQE fetch thread wakes up and then calls the ibv _ poll _ CQ () interface to fetch the CQE. This approach does not require the thread to check whether any CQE is generated in the CQ at any time, does not occupy CPU resources, but requires the thread to be woken up, and thus the delay is high.
Polling to acquire CQEs continually polls CQs without falling into sleep. When a completion event is generated in the CQ, the polling thread acquires and processes the completion event in sequence. Although the method for obtaining the CQE has no thread wakeup overhead, low delay and quick response, the thread for obtaining the CQE can dominate the CPU core, and the long-term idle running can waste the CPU resource.
In addition to the most basic interrupt and poll CQE acquisition approach, there are some CQE acquisition approaches that attempt to combine interrupts and polls for better results, such as the batch poll CQE acquisition approach. This way of obtaining CQEs does not poll CQs, but also uses a multiplexing mechanism to listen to the completion channel CC and to notify the CPU through an interrupt when a CQE is generated. After triggering the interrupt, the CQE thread will poll CQ a fixed number of times, and unless an error occurs, K WCs may be obtained, where K is greater than 0 and less than or equal to the number of polling times N. The acquisition mode can reduce the interruption times from N to 1 at most, and compared with the interruption mode, the acquisition mode reduces the interruption times and improves the performance. However, after polling N times, even if other CQEs are generated later in the CQ, the batch polling method still returns to the interrupt trigger mode, and waits for the next interrupt to be processed, so that the later generated CQEs cannot be processed in time, and the overall delay is high.
Disclosure of Invention
Aiming at the defects and the improvement requirements of the prior art, the invention provides a method and a device for acquiring task completion notifications and a method for directly accessing a memory, and aims to quickly acquire the task completion notifications under the condition of not consuming excessive CPU resources.
To achieve the above object, according to an aspect of the present invention, there is provided a method of acquiring a task completion notification, including:
when the system is started, setting a past count record pre _ record2 used for recording the number of polling times required to be executed for acquiring the completion notification from the completion queue last time and a past count record pre _ record1 used for recording the number of polling times required to be executed for acquiring the completion notification from the completion queue currently, and initializing the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT;
when a new task completion notification is generated in the completion queue, executing a polling step to enter a polling mode; the polling step includes:
(S1) calculating a count upper limit count _ limit by count _ limit = (pre _ record1+ pre _ record 2)/2;
(S2) setting the value of the counter to be 0;
(S3) polling the completion queue, and if a task completion notification exists in the completion queue, turning to the step (S4); otherwise, go to step (S5);
(S4) after task completion notifications in the completion queue are obtained in batches, the step (S2) is carried out;
(S5) after the value of the counter is added with 1, judging whether the counter < count _ limit is met, if so, turning to the step (S3); otherwise, exiting the polling mode and ending the polling step.
Further, the method for acquiring task completion notification provided by the present invention, before proceeding to step (S2), further includes, in step (S4):
judging whether the counter is larger than or equal to LOWER _ LIMIT, if so, updating the past count records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then turning to the step (S1);
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT.
Further, in the method for acquiring a task completion notification provided by the present invention, before exiting the polling mode, in step (S5), the method further includes:
the past count records pre _ record2 and pre _ record1 are updated as follows:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
wherein STEP _ FORWARD is a predetermined non-negative integer.
Further, STEP _ FORWARD >0.
According to another aspect of the present invention, there is provided an apparatus for acquiring a task completion notification, including: the device comprises an initialization module, a monitoring module and a polling module;
the system comprises an initialization module, a first module and a second module, wherein the initialization module is used for setting a past count record pre _ record2 used for recording the number of polling times required to be executed for obtaining a completion notification from a completion queue last time and a past count record pre _ record1 used for recording the number of polling times required to be executed for obtaining the completion notification from the completion queue at present when the system is started, and initializing the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT value;
the monitoring module is used for triggering the polling module to enter a polling mode when a new task completion notice is generated in the completion queue;
the polling module comprises: the device comprises a counting upper limit updating unit, a counter zero clearing unit, a polling unit, a CQE acquisition unit and a counter updating unit;
the count upper limit updating unit is used for triggering the counter zero clearing unit after the count upper limit count _ limit is calculated according to the count _ limit = (pre _ record1+ pre _ record 2)/2;
the counter zero clearing unit is used for setting the value of the counter to be 0 and then triggering the polling unit;
the polling unit is used for polling the completion queue, triggering the CQE acquisition unit when the completion queue has a task completion notice, and triggering the counter updating unit when the completion queue has no task completion notice;
the CQE acquisition unit is used for acquiring task completion notifications in the completion queue in batches and then triggering the counter zero clearing unit;
and the counter updating unit is used for judging whether the counter < count _ limit is met or not after the value of the counter is added by 1, if so, the polling unit is triggered, otherwise, the polling mode is exited, and the polling is ended.
Further, the apparatus for acquiring task completion notification provided by the present invention further includes: the first past counting record updating unit is used for updating the past counting records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then triggering the counting upper limit updating unit;
before triggering the counter zero clearing unit, the CQE acquisition unit judges whether the counter is more than or equal to LOWER _ LIMIT, if so, the first past counting record updating unit is triggered, and otherwise, the counter zero clearing unit is triggered;
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT.
Further, the apparatus for acquiring task completion notification provided by the present invention further includes: a second past count record updating unit, configured to update the past count records pre _ record2 and pre _ record1 in the following manner:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
before exiting the polling mode, the counter updating unit triggers the second past count record updating unit;
wherein STEP _ FORWARD is a predetermined non-negative integer.
Further, STEP _ FORWARD >0.
According to another aspect of the present invention, there is provided a method for directly accessing a memory remotely, comprising:
the communication thread generates a transmission task and transmits the transmission task to a work queue;
the RDMA enabled network interface card acquires a work task from the work queue, performs network data communication according to the work task, packages the completion condition of the work task into a task completion notification after the network data communication is completed, and transmits the task completion notification to the completion queue;
the method for acquiring the task completion notification acquires the task completion notification from the completion queue, processes the task completion notification, and notifies the communication thread of task completion after the processing is completed.
Further, the method for notifying the communication thread of completion of the transmission task is as follows:
registering a completion queue channel associated with a completion queue into an IO multiplex Epoll, and calling an interface accessed by a remote direct memory by a communication thread to provide a notification mechanism for a specified completion queue; when the RDMA enabled network interface card places a new completion notification in the completion queue, the IO mux triggers a callback, switches to a communication thread and calls the interface to acknowledge receipt of the notification.
Generally, by the above technical solution conceived by the present invention, the following beneficial effects can be obtained:
(1) The invention combines the interrupt CQE acquisition mode and the polling CQE acquisition mode, uses the counter to record the polling times executed by the CQE acquired from the completion queue, and maintains the polling state according to the counter, concretely, when the completion queue has the CQE, the CQE is acquired from the completion queue in batch, and the counter is cleared, when the completion queue has no CQE, the polling is not stopped immediately, but the polling times is recorded by the counter, and the polling mode is exited when the polling times exceeds the upper limit count _ limit, thereby ensuring that the task completion notification WC which arrives in a short time can be acquired and processed in time, reducing the delay, and avoiding the occupation of excessive CPU resources caused by the blind polling of the CPU. Generally speaking, the invention can rapidly acquire the task completion notification under the condition of not consuming excessive CPU resources, and reduce the task processing delay.
(2) Before the counter is cleared, whether the counter reaches the preset UPPER LIMIT and the minimum value of the count is judged, if yes, the past count record is dynamically updated by utilizing the polling times required by the last time of obtaining the CQE, and the adopted updating mode can gradually reduce the UPPER LIMIT count _ LIMIT within a preset range [ LOWER _ LIMIT, UPPER _ LIMIT ] in single interruption, so that infinite circulation is avoided, and the over-high occupancy rate of a CPU is also avoided.
(3) Before exiting the polling mode, the invention dynamically updates the past count record by using the polling times required for obtaining the CQE last time, and the adopted updating mode can adjust the count upper limit _ limit to a larger value when entering the polling mode next time so as to obtain the CQE.
Generally speaking, the invention combines the interruption CQE acquisition mode and the polling CQE acquisition mode, can not seize CPU resources when no element exists in the completion queue, and quickly acquires task completion notification when the element exists in the completion queue, thereby avoiding the problems that a plurality of CQEs need to be interrupted for processing for many times and the CQE needs to be interrupted for the next time to process after arriving later, giving consideration to low CPU occupancy rate and low acquisition delay, and further dynamically adjusting the upper limit of the polling count according to the load condition, so that the polling times can be maintained in a reasonable range according to the load characteristic, and the invention has strong adaptability.
Drawings
Fig. 1 is a flowchart of a method for obtaining a task completion notification according to an embodiment of the present invention;
fig. 2 is an algorithm diagram of a method for obtaining a task completion notification of a remote direct memory access technology according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a method for directly accessing a memory remotely according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention. In addition, the technical features involved in the respective embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
In the present application, the terms "first," "second," and the like (if any) in the description and the drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Before explaining the technical scheme of the invention in detail, english abbreviations of related technical terms are briefly introduced as follows:
RDMA: remote Direct Memory Access;
WR: work Request, RDMA Work Request;
RQ: recv Queue, receive Queue;
CQ: completion Queue, completing the Queue;
CQE: completion Queue Element;
WC: work Completion, task Completion notification; in the invention, task completion notification is taken as CQE and placed in a completion queue CQ;
CC: completion Channel, complete Channel.
In order to solve the problems that the existing method for acquiring the task completion notification of the remote direct memory access cannot take account of low CPU occupancy rate and low acquisition delay and the problem that the new task completion notification can be processed only by next interruption when arriving, the invention provides a method and a device for acquiring the task completion notification and a method for directly accessing the memory, and the overall thought is as follows: the method for interrupting the acquisition of the CQE is combined with the method for polling the acquisition of the CQE, when no CQE is generated in a completion queue, a communication thread does not actively access the completion queue, data transmission is carried out by centralized resources, when new CQE is generated in the completion queue, the communication thread is informed through an informing mechanism, the communication thread starts polling the completion queue after the current task is executed, when all task completion notices are obtained, polling is not stopped but continues to poll the completion queue, and the polling mode is not exited until the polling times reach the upper limit of times and no new CQE is generated. On the basis, the upper limit of the polling times is further dynamically adjusted in combination with the load so as to keep the polling times within a reasonable range.
The following are examples.
Example 1:
a method of obtaining task completion notifications, comprising:
when the system is started, setting a past count record pre _ record2 used for recording the number of polling times required to be executed for acquiring a completion notification from a completion queue last time and a past count record pre _ record1 used for recording the number of polling times required to be executed for acquiring the completion notification from the completion queue at present, and initializing the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT;
when a new task completion notification is generated in the completion queue, executing a polling step to enter a polling mode; as shown in fig. 1 and 2, the polling step includes:
(S1) calculating a count upper limit count _ limit in accordance with count _ limit = (pre _ record1+ pre _ record 2)/2;
(S2) setting the value of the counter to be 0;
(S3) polling the completion queue, and if a task completion notification exists in the completion queue, turning to the step (S4); otherwise, go to step (S5);
(S4) after task completion notifications in the completion queue are obtained in batches, the step (S2) is carried out;
(S5) after the value of the counter is added with 1, judging whether the counter < count _ limit is met, if so, turning to the step (S3); otherwise, it indicates that no new CQE is generated in the completion queue for a long time, and thus, exits the polling mode and ends the polling step.
In the embodiment, a mode of interrupting to acquire the CQE and a mode of polling to acquire the CQE are combined, a counter is used for recording the polling times of the CQE acquired from a completion queue, and the polling state is maintained according to the counter, specifically, when the CQE exists in the completion queue, the CQE is acquired in batch from the completion queue, the counter is cleared, when the CQE does not exist in the completion queue, polling is not stopped immediately, the counter is used for recording the polling times, and the polling mode is exited when the polling times exceed a count upper limit count _ limit, so that a task completion notification WC which arrives in a short time can be timely acquired and processed, delay is reduced, and excessive CPU resources occupied by blind polling of a CPU can be avoided.
In order to adapt to the dynamic change of the load, in the process of executing the polling step, the embodiment also updates two past count records according to the load condition, and updates the count upper limit count _ limit according to the past count records after updating, so that the count upper limit count _ limit is adapted to the load; as shown in fig. 1 and fig. 2, in the present embodiment, before the counter is cleared, the past count record is updated according to the polling count, and before the polling mode exits, the past count record is also updated; specifically updated as follows:
in the present embodiment, before proceeding to step (S2), step (S4) further includes:
judging whether the counter is larger than or equal to LOWER _ LIMIT, if so, updating the past count records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then turning to the step (S1);
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT;
the updating method dynamically adjusts the upper limit of the count of the next round by utilizing the polling times required when the CQE is acquired in the previous round, and the upper limit of the count of each round is gradually reduced in a single interruption, so that infinite circulation is avoided; in this embodiment, each time the CQE is acquired, the past count record is updated to the value of the counter only if the value of the counter is greater than or equal to LOWER _ LIMIT, so that it is ensured that the past count record is greater than or equal to LOWER _ LIMIT;
in step (S5) of this embodiment, before exiting the polling mode, the method further includes:
the past count records pre _ record2 and pre _ record1 are updated as follows:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
wherein STEP _ FORWARD is a preset non-negative integer; considering that the value of the counter is equal to the count upper limit _ limit when exiting the polling mode, therefore, the count upper limit should be adjusted to be larger to obtain the CQE when entering the polling mode next time, in this embodiment, STEP _ FORWARD >0, and the specific value thereof may be set according to the load characteristic; in this embodiment, when the past count record pre _ record1 is updated, the smaller value of counter + STEP _ FORWARD and UPPER _ LIMIT is taken as the updated value, so that the UPPER LIMIT of the count is increased and the UPPER LIMIT is not exceeded.
In this embodiment, two past count records are maintained, the number of polls that need to be executed for obtaining CQEs twice is maintained, and the average value of the two past count records is taken as the UPPER count LIMIT, so that the UPPER count LIMIT is dynamically adjusted between UPPER _ LIMIT and LOWER _ LIMIT by this method, the number of polls can be adjusted in a range selected by a user according to a load condition, and a low CPU occupancy rate is achieved under the condition of ensuring low delay.
In general, the present embodiment provides a new task completion notification method for obtaining remote direct memory access by combining an interrupt method and a busy polling method; CPU resources are not occupied when the queue elements are not completed, a new completed queue element can quickly enter a polling mode after being generated, a task completion notice is obtained, and low CPU occupancy rate and low acquisition delay are considered; after entering the polling mode, the counter maintains the polling of the CQ, thereby avoiding the problems that a plurality of CQEs need to be interrupted for processing for many times and the CQE needs to be interrupted for processing next time after arriving later; meanwhile, the upper limit of the counting is dynamically adjusted according to past records, so that the polling times are maintained in a reasonable range according to load characteristics, and the method has strong adaptability.
Example 2:
an apparatus to obtain task completion notifications, comprising: the device comprises an initialization module, a monitoring module and a polling module;
the system comprises an initialization module, a first module and a second module, wherein the initialization module is used for setting a past count record pre _ record2 used for recording the number of polling times required to be executed for obtaining a completion notification from a completion queue last time and a past count record pre _ record1 used for recording the number of polling times required to be executed for obtaining the completion notification from the completion queue at present when the system is started, and initializing the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT;
the monitoring module is used for triggering the polling module to enter a polling mode when a new task completion notice is generated in the completion queue;
the polling module comprises: the device comprises a counting upper limit updating unit, a counter zero clearing unit, a polling unit, a CQE acquisition unit and a counter updating unit;
the count upper limit updating unit is used for triggering the counter zero clearing unit after the count upper limit count _ limit is calculated according to the count _ limit = (pre _ record1+ pre _ record 2)/2;
the counter zero clearing unit is used for setting the value of the counter to be 0 and then triggering the polling unit;
the polling unit is used for polling the completion queue, triggering the CQE acquisition unit when the completion queue has a task completion notice, and triggering the counter updating unit when the completion queue has no task completion notice;
the CQE acquisition unit is used for acquiring task completion notifications in the completion queue in batches and then triggering the counter zero clearing unit;
and the counter updating unit is used for judging whether the counter < count _ limit is met or not after the value of the counter is added by 1, if so, triggering the polling unit, otherwise, exiting the polling mode and finishing polling.
In order to dynamically adjust the upper limit of the count according to the load, the embodiment further includes: the first past counting record updating unit is used for updating the past counting records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then triggering the counting upper limit updating unit;
before triggering the counter zero clearing unit, the CQE acquisition unit judges whether the counter is more than or equal to LOWER _ LIMIT, if so, the first past counting record updating unit is triggered, and otherwise, the counter zero clearing unit is triggered;
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT.
In order to dynamically adjust the upper limit of the count according to the load, the embodiment further includes: a second past count record updating unit, configured to update the past count records pre _ record2 and pre _ record1 in the following manner:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
before exiting the polling mode, the counter updating unit triggers a second past count record updating unit;
wherein STEP _ FORWARD is a preset non-negative integer; likewise, in order to adjust the upper limit of the count to be larger when the polling mode is entered next time so that the CQE can be acquired, STEP _ FORWARD >0 in the present embodiment;
in this embodiment, the specific implementation of each module or unit may also refer to the description in embodiment 1 above.
Example 3:
a method for directly accessing a memory remotely, as shown in fig. 3, includes:
the communication thread generates a transmission task and transmits the transmission task to a work queue;
the RDMA enabled network interface card acquires a work task from the work queue, performs network data communication according to the work task, packages the completion condition of the work task into a task completion notification after the network data communication is completed, and transmits the task completion notification to the completion queue;
the method for acquiring the task completion notification provided by the embodiment 1 is used for acquiring the task completion notification from the completion queue, processing the task completion notification, and notifying the communication thread of task completion after the processing is completed;
in this embodiment, the manner of notifying the communication thread of completion of the transmission task is as follows:
registering a completion queue channel associated with a completion queue into an IO multiplex Epoll, and calling an interface accessed by a remote direct memory by a communication thread to provide a notification mechanism for a specified completion queue; when the RDMA enabled network interface card places a new completion notification in the completion queue, the IO mux triggers a callback, switches to a communication thread and calls the interface to acknowledge receipt of the notification.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for obtaining task completion notifications, comprising:
when the system is started, setting a past count record pre _ record2 used for recording the number of polling times executed for acquiring the completion notification from the completion queue last time and a past count record pre _ record1 used for recording the number of polling times executed for acquiring the completion notification from the completion queue currently, and initializing the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT;
when a new task completion notification is generated in the completion queue, executing a polling step to enter a polling mode; the polling step includes:
(S1) calculating a count upper limit count _ limit by count _ limit = (pre _ record1+ pre _ record 2)/2;
(S2) setting the value of the counter to be 0;
(S3) polling the completion queue, and if a task completion notification exists in the completion queue, turning to the step (S4); otherwise, go to step (S5);
(S4) after the task completion notifications in the completion queue are obtained in batches, the step (S2) is carried out;
(S5) after the value of the counter is added with 1, judging whether the counter < count _ limit is met, if so, turning to the step (S3); otherwise, exiting the polling mode and ending the polling step.
2. The method for obtaining task completion notification according to claim 1, wherein in step (S4), before proceeding to step (S2), further comprising:
judging whether the counter is larger than or equal to LOWER _ LIMIT, if so, updating the past count records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then turning to the step (S1);
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT.
3. The method of obtaining task completion notifications according to claim 2, wherein said step (S5), before exiting polling mode, further comprises:
the past count records pre _ record2 and pre _ record1 are updated as follows:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
wherein STEP _ FORWARD is a predetermined non-negative integer.
4. A method of retrieving task completion notifications as claimed in claim 3, wherein STEP _ FORWARD >0.
5. An apparatus for obtaining task completion notifications, comprising: the device comprises an initialization module, a monitoring module and a polling module;
the initialization module is configured to set a past count record pre _ record2 used for recording the number of polls required to be executed for the last time of acquiring the completion notification from the completion queue and a past count record pre _ record1 used for recording the number of polls required to be executed for the current time of acquiring the completion notification from the completion queue, and initialize the two past count records according to pre _ record1= UPPER _ LIMIT and pre _ record2= UPPER _ LIMIT; UPPER _ LIMIT is a preset maximum UPPER counting LIMIT;
the monitoring module is used for triggering the polling module to enter a polling mode when a new task completion notice is generated in the completion queue;
the polling module comprises: the device comprises a counting upper limit updating unit, a counter zero clearing unit, a polling unit, a CQE acquisition unit and a counter updating unit;
the count upper limit updating unit is configured to trigger the counter zero clearing unit after the count upper limit count _ limit is calculated according to count _ limit = (pre _ record1+ pre _ record 2)/2;
the counter zero clearing unit is used for setting the value of the counter to be 0 and then triggering the polling unit;
the polling unit is used for polling the completion queue, triggering the CQE acquisition unit when a task completion notice exists in the completion queue, and triggering the counter updating unit when no task completion notice exists in the completion queue;
the CQE acquisition unit is used for acquiring task completion notifications in the completion queue in batches and then triggering the counter zero clearing unit;
and the counter updating unit is used for judging whether the counter < count _ limit is met or not after the value of the counter is added by 1, if so, triggering the polling unit, otherwise, exiting the polling mode and finishing polling.
6. An apparatus for obtaining task completion notifications according to claim 5, further comprising: the first past counting record updating unit is used for updating the past counting records pre _ record2 and pre _ record1 according to pre _ record2= pre _ record1 and pre _ record1= counter, and then triggering the counting upper limit updating unit;
before triggering the counter zero clearing unit, the CQE acquisition unit judges whether the counter is greater than or equal to LOWER _ LIMIT, if so, the first past counting record updating unit is triggered, and otherwise, the counter zero clearing unit is triggered;
wherein, LOWER _ LIMIT is a preset counting upper LIMIT minimum value; LOWER _ LIMIT < UPPER _ LIMIT.
7. An apparatus for obtaining task completion notifications according to claim 6, further comprising: a second past count record updating unit, configured to update the past count records pre _ record2 and pre _ record1 in the following manner:
pre_record2=pre_record1;
pre_record1=min(counter+STEP_FORWARD,UPPER_LIMIT);
before exiting the polling mode, the counter updating unit triggers the second past count record updating unit;
wherein STEP _ FORWARD is a predetermined non-negative integer.
8. An apparatus for obtaining task completion notifications as claimed in claim 7, wherein STEP _ FORWARD >0.
9. A method for remotely accessing memory directly, comprising:
the communication thread generates a transmission task and transmits the transmission task to a work queue;
the RDMA enabled network interface card acquires a work task from the work queue, performs network data communication according to the work task, packages the completion condition of the work task into a task completion notification after the network data communication is completed, and transmits the task completion notification to the completion queue;
the method for acquiring task completion notification according to any one of claims 1 to 4, wherein the task completion notification is acquired from the completion queue and processed, and the communication thread is notified of task completion after the processing is completed.
10. The method of claim 9, wherein the communication thread is notified of completion of the transfer task by:
registering a completion queue channel associated with the completion queue into an IO multiplex Epoll, and calling an interface accessed by a remote direct memory by a communication thread to provide a notification mechanism for the specified completion queue; when the RDMA enabled network interface card places a new completion notification in the completion queue, the IO mux triggers a callback, switches to a communication thread and calls the interface to acknowledge receipt of the notification.
CN202211035562.0A 2022-08-26 2022-08-26 Method and device for acquiring task completion notification and method for directly accessing memory Pending CN115470014A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211035562.0A CN115470014A (en) 2022-08-26 2022-08-26 Method and device for acquiring task completion notification and method for directly accessing memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211035562.0A CN115470014A (en) 2022-08-26 2022-08-26 Method and device for acquiring task completion notification and method for directly accessing memory

Publications (1)

Publication Number Publication Date
CN115470014A true CN115470014A (en) 2022-12-13

Family

ID=84369432

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211035562.0A Pending CN115470014A (en) 2022-08-26 2022-08-26 Method and device for acquiring task completion notification and method for directly accessing memory

Country Status (1)

Country Link
CN (1) CN115470014A (en)

Similar Documents

Publication Publication Date Title
US8006005B2 (en) Centralized polling service
US5974518A (en) Smart buffer size adaptation apparatus and method
KR101502808B1 (en) A method and system for improved multi-cell support on a single modem board
EP2645674A1 (en) Interrupt management
US6967920B2 (en) Smart interface for payload transfers in networking applications
EP2171934B1 (en) Method and apparatus for data processing using queuing
CN101442439B (en) Method for reporting interruption and PCI bus system
CN106547566A (en) Communications service process pool management method and system
CN115470014A (en) Method and device for acquiring task completion notification and method for directly accessing memory
CN101997777A (en) Interruption processing method, device and network equipment
JP3028953B1 (en) Call distribution method for wireless exchange in mobile communication system
US9948533B2 (en) Interrupt management
EP0466467B1 (en) A method of processing access service requests in data processing systems, such as telephone exchanges, and a distributed system applying said method
JP2000222374A (en) Load distribution type packet parallel processor
CN117278505B (en) Message transmission method, system, equipment and medium between RAID card nodes
CN118524063B (en) Tenant multi-network access method and system
WO2024152699A1 (en) Cache management method for switching device and switching device
US20240223683A1 (en) Packet Processing Method, Network Interface Card, and Server
KR100291014B1 (en) Method for processing signaling protocol in atm switch
CN118138689A (en) Method for processing AMI data, terminal equipment and storage medium
KR100333947B1 (en) Subscriber Call Service Keeping Method in Overloading Processor of Mobile Communication System
KR100259439B1 (en) Radio frequency-specific overload controlling method in paging system
CN118678306A (en) Short message sending method, device, equipment, storage medium and program product
JP3696557B2 (en) Congestion control method
CN117349195A (en) Cross-device memory exchange method for mobile device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination