WO2023121104A1 - Interrupt handling method for linux kernel - Google Patents

Interrupt handling method for linux kernel Download PDF

Info

Publication number
WO2023121104A1
WO2023121104A1 PCT/KR2022/020178 KR2022020178W WO2023121104A1 WO 2023121104 A1 WO2023121104 A1 WO 2023121104A1 KR 2022020178 W KR2022020178 W KR 2022020178W WO 2023121104 A1 WO2023121104 A1 WO 2023121104A1
Authority
WO
WIPO (PCT)
Prior art keywords
cpu
packet
linux kernel
cpus
searching
Prior art date
Application number
PCT/KR2022/020178
Other languages
French (fr)
Korean (ko)
Inventor
이강민
Original Assignee
주식회사 알티스트
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
Priority claimed from KR1020220043950A external-priority patent/KR20230094106A/en
Application filed by 주식회사 알티스트 filed Critical 주식회사 알티스트
Publication of WO2023121104A1 publication Critical patent/WO2023121104A1/en

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/48Program initiating; Program switching, e.g. by interrupt
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]

Definitions

  • the present invention relates to a method for handling interrupts in the Linux kernel, and more particularly, to a method for ensuring real-time performance of the Linux kernel.
  • 5G and edge computing are enabling new applications such as AR and VR. Low latency and high bandwidth have been proposed as key characteristics of 5G to provide these applications, and telecommunications companies are meeting these requirements through edge computing.
  • the Linux kernel is widely used due to its extensive application and driver support.
  • the Linux kernel is not a real-time OS, scheduling delays may occur due to resource contention. This can be an obstacle to achieving sub 1 ms network latency in the Linux network stack. Therefore, there is a need for a Linux kernel processing method capable of maintaining real-time properties.
  • the present invention is a next-generation edge computing system technology development (R & D) of the Ministry of Science and ICT (Task identification number: 1711125982, Assignment number: 2020-0-00844-002, Research title: Lightweight system for managing and controlling edge server system resources) It was derived from a study conducted as part of software technology development, project management agency: National Institute of Information and Communications Technology Evaluation and Planning, project executing agency: Korea Electronics and Telecommunications Research Institute, research period: 2020.04.01 ⁇ 2023.12.31).
  • An object of the present invention relates to a method for handling interrupts in a Linux kernel in which real-time performance is guaranteed through a process of searching for a CPU.
  • a method for processing an interrupt in a Linux kernel that guarantees real-time performance may be provided.
  • 1 is a diagram for explaining a general packet processing situation and a situation in which a delay occurs in the packet processing situation.
  • FIG. 2 is a flowchart of an interrupt processing method of a Linux kernel according to an embodiment.
  • FIG. 3 is a diagram for explaining an interrupt processing method of a Linux kernel according to an embodiment.
  • An interrupt processing method of a Linux kernel includes receiving a packet and storing it in a memory; determining whether a software interrupt is being executed on a first CPU among the plurality of CPUs; searching for a CPU in which the software interrupt is not being executed, among the plurality of CPUs, when the software interrupt is being executed; and selecting a second CPU from among the plurality of CPUs and transmitting the packet stored in the memory to the second CPU.
  • the step of searching for a CPU in which the software interrupt is not executing may include searching for a CPU whose counter value is 0 among the plurality of CPUs.
  • the step of searching for a CPU in which the software interrupt is not executing may include sequentially searching for CPUs other than the first CPU among the plurality of CPUs.
  • the data processing priority of the packet may be higher than the data processing priority of the software interrupt.
  • the first period which is the processing period of the software interrupt on the first CPU, may overlap at least a part with the second period, which is the processing period of the packet on the second CPU.
  • An interrupt processing method of a Linux kernel includes searching for a CPU in which software interrupts are not being executed among a plurality of CPUs; selecting a first CPU from among the plurality of CPUs; and transmitting a packet to the first CPU, wherein the searching for the CPU may include searching for a CPU whose counter value is 0.
  • the step of searching for the CPU may include sequentially checking the CPUs included in the plurality of CPUs.
  • the step of searching for the CPU may include stopping checking of the next CPU when a CPU having a counter value of 0 is identified.
  • a computer program stored in a computer-readable recording medium may be provided to execute the interrupt handling method of the Linux kernel.
  • real-time can mean that results are output within a fixed time for input. For example, if the result of the input is output within 1 ms of the input, this can be interpreted as guaranteeing real-time in the Linux kernel.
  • the Linux RT Real Time
  • the PREEMPT_RT patch played a role in reducing the non-preemptible area of the Linux kernel's code path as much as possible.
  • the non-preemptable region may mean a locked region (critical section) protected by a spin lock.
  • PREEMPT_RT was able to provide response characteristics close to real-time operating systems.
  • the present invention proposes an interrupt handling method of the Linux kernel that guarantees real-time performance to solve these conventional problems.
  • 1 is a diagram for explaining a general packet processing situation and a situation in which a delay occurs in the packet processing situation.
  • FIG. 1(a) is a diagram for explaining a general packet processing situation
  • FIG. 1(b) is a diagram for explaining a packet processing delay situation caused by a software interrupt mechanism of the Linux kernel.
  • the first CPU processes the RT task and then enters a waiting state waiting for packets.
  • a portion marked with a red solid line indicates a section in which the RT task is processed, and a section indicated in a dotted line indicates a section in which the RT task is not processed.
  • the first CPU processes the RT task until before the reference time point t0, and enters a standby state of waiting for packets from the reference time point t0.
  • the Linux kernel receives a packet from an external device. At this time, the kernel performs a data processing process on the received packet.
  • a packet data processing process performed by a kernel may be a pre-processing process for a packet processing process of a CPU.
  • a portion marked with a solid blue line represents a process in which a kernel processes data for a packet.
  • the kernel When the kernel performs data processing on packets, it stores the processed packets in memory.
  • the memory may be an internal storage of the Linux kernel.
  • the kernel scheduler may transmit packet-related data to the first CPU to process the packet stored in the memory. That is, the kernel scheduler may cause the first CPU to perform the RT task on the packet.
  • the time point at which the first CPU receives the packet data may be the second time point t2.
  • FIG. 1(b) a delay situation for packet processing caused by a software interrupt is described.
  • the first CPU after performing the RT task, the first CPU enters a waiting state in which a packet is waiting from a reference point in time t0.
  • a software interrupt may be executed on the first CPU.
  • a softirq bottom half lock hereinafter referred to as bh lock
  • bh lock a softirq bottom half lock
  • the kernel may receive a packet at a first time point t1.
  • the kernel may perform data processing on packets and store the processed packets in memory.
  • the time when the kernel completes the data processing process for the packet and stores the packet in the memory is indicated as the kernel processing completion time t11.
  • Packets that have been processed by the kernel and stored in the memory must then be subjected to an RT task process on the CPU, but the first CPU cannot process the packets due to the bh lock caused by the pre-executing software interrupt. That is, a problem arises in that the kernel scheduler cannot transmit a packet to the first CPU immediately after the kernel processing completion point (t11).
  • the kernel scheduler has to wait until the execution of the software interrupt on the first CPU is completed, which may cause a delay in packet processing. That is, a delay occurs from the kernel processing completion time t11 to the second time point t2 on the first CPU timeline of FIG. 1(b). That is, resource contention occurs with respect to the first CPU, resulting in scheduling delay.
  • the present invention proposes a method of processing packets through a CPU other than the CPU in which software interrupts are executed by modifying the RT scheduler.
  • the RT task can be performed on the other CPU immediately after the kernel processes the packet through the other CPU, so that the real-time nature of the Linux kernel can be guaranteed.
  • FIGS. 2 and 3 an interrupt processing method according to the present invention capable of ensuring real-time performance of the Linux kernel will be described through FIGS. 2 and 3.
  • FIG. 2 is a flowchart of an interrupt processing method of a Linux kernel according to an embodiment.
  • the interrupt processing method of the Linux kernel includes receiving a packet and storing it in a memory (S110), determining whether a software interrupt is running on a CPU (S120), and selecting another CPU. It may include searching (S130), determining whether a software interrupt is running on the CPU (S140), and transmitting a packet stored in the memory to the CPU (S150).
  • Receiving and storing the packet in the memory (S110) may include receiving a data packet from an external device or another internal component.
  • the data packet may be a data packet including information or a data packet related to a signal for control.
  • Data packets can vary depending on the device to which the Linux kernel is applied.
  • the kernel can receive packets and process data on the packets.
  • Data processing of the kernel may be a data pre-processing process for the RT task on the CPU.
  • kernel data processing may be a process of modifying data to meet CPU specifications.
  • kernel data processing may be a process of arranging data so that a calculation process can be efficiently performed on a CPU.
  • the kernel can process packets as data and store them in memory.
  • the memory may be an internal device of a device to which the Linux kernel is applied or another external device used as a storage. If the memory is another external device, the kernel can communicate with the external device and transmit the processed data packet.
  • Examples of the memory include a hard disk drive (HDD), solid state drive (SSD), flash memory, read-only memory (ROM), random access memory (RAM), or cloud storage ( Cloud Storage), etc. However, it is not limited thereto, and the memory may be implemented with various modules for storing data.
  • HDD hard disk drive
  • SSD solid state drive
  • flash memory read-only memory
  • RAM random access memory
  • Cloud Storage Cloud Storage
  • the step of determining whether a software interrupt is running on the CPU may be a previous step for performing an RT task on a packet after the packet processing process of the kernel. Specifically, when a software interrupt is being executed on the CPU, a delay in packet processing occurs, so a step of checking whether the software interrupt is executed in advance is required.
  • the software interrupt may be a softirq function.
  • the CPU in step S120 may be the CPU that performed the process of receiving the packet by the kernel. That is, step S120 may be a step in which the kernel checks whether or not the CPU performing the process of receiving the packet was executing a software interrupt before receiving the packet.
  • Determining whether the software interrupt is being executed may be determined through a value of a software interrupt counter (hereinafter referred to as a counter). Specifically, the kernel scheduler may determine that the software interrupt is not executed when the value of the counter is 0. Also, the kernel scheduler may determine that a software interrupt is being executed when the value of the counter is 1. In this case, the software interrupt counter may be a softirq counter function.
  • the kernel scheduler may immediately perform step S150 when the counter value of the CPU is 0. That is, when the counter value of the CPU is 0, since the software interrupt is not running, the kernel scheduler can transmit the packet stored in the memory to the CPU.
  • the CPU receiving the packet may process the data of the packet by performing the RT task.
  • the kernel scheduler may perform step S130 when the counter value of the CPU is 1. That is, when the counter value of the CPU is 1, since the software interrupt is running, a process of searching for another CPU that is not running the software interrupt can be performed to avoid a delay.
  • the step of searching for another CPU may be a step of sequentially checking a plurality of CPUs included in the device. Sequentially checking may mean checking counter values of CPUs sequentially according to the number of CPUs. That is, the kernel scheduler can individually check the counter values of multiple CPUs, such as #1 CPU, #2 CPU, and #3 CPU.
  • the step of determining whether a software interrupt is being executed on the CPU may be similar to step S120. For example, if the CPU in step S120 is CPU No. 1, the kernel scheduler searches for CPU No. 2 through step S130, and in step S140, it can check whether the counter value of CPU No. 2 is 0.
  • the kernel scheduler may search for a CPU whose counter value is 0 by repeating steps S130 and S140, such as checking whether the counter value of CPU 3 is 0 again. .
  • Transmitting the packet stored in the memory to the CPU may be a step in which the kernel scheduler searches for and/or selects a CPU in which the software interrupt is not running, and transmits the packet stored in the memory to the CPU.
  • the packet transmitted to the CPU by the kernel scheduler may be a packet processed by the kernel.
  • the kernel scheduler can send other data for RT tasks to the CPU in addition to packets stored in memory.
  • a CPU with no software interrupts running can acquire packets by the kernel scheduler and perform RT tasks.
  • a period in which the CPU in which the software interrupt is not executing performs the RT task for the packet may overlap a period in which the CPU in which the software interrupt is executing performs the software interrupt. That is, while the first CPU performs a software interrupt, the second CPU may obtain the packet by the kernel scheduler and perform the RT task for the packet.
  • performing the RT task on the received packet by the CPU may be reading the packet and performing a calculation process for processing the packet.
  • the RT task may be a process of modifying a received packet according to a purpose.
  • the RT task may be immediately performed on the received packet by utilizing another CPU, which is a resource on which software interrupts are not executed.
  • FIG. 3 is a diagram for explaining an interrupt processing method of a Linux kernel according to an embodiment.
  • the kernel scheduler may perform RT tasks for packets by searching for other CPUs.
  • the first CPU After processing the RT task, the first CPU enters a standby state in which it waits for packets from the reference time point t0. During the standby state, a software interrupt other than a packet may be executed on the first CPU at the first sudden point in time s1. While the software interrupt is being performed from the first sudden time point s1, the kernel may receive the packet at the first time point t1.
  • the kernel receiving the packet may perform a data processing process and store the packet in memory. Since a software interrupt is running on the first CPU, the kernel scheduler can search for another CPU that can immediately handle the RT task for the packet.
  • the kernel scheduler may sequentially search for a CPU whose counter value is 0 among a plurality of CPUs included in the device.
  • the kernel scheduler may select a second CPU on which software interrupts are not running.
  • the kernel scheduler may transmit packets stored in the memory to the second CPU.
  • the second CPU may perform an RT task on the packet.
  • the software interrupt execution period of the first CPU may overlap the RT task processing period for the packet of the second CPU.
  • the kernel scheduler of the present invention does not wait for the first CPU to complete a software interrupt, but immediately searches for a second CPU capable of processing data and transmits a packet to the second CPU, thereby ensuring real-time performance of the Linux kernel. .
  • the method according to the embodiment may be implemented in the form of program instructions that can be executed through various computer means and recorded on a computer readable medium.
  • the computer readable medium may include program instructions, data files, data structures, etc. alone or in combination.
  • Program commands recorded on the medium may be specially designed and configured for the embodiment or may be known and usable to those skilled in computer software.
  • Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks and magnetic tapes, optical media such as CD-ROMs and DVDs, and magnetic media such as floptical disks.
  • - includes hardware devices specially configured to store and execute program instructions, such as magneto-optical media, and ROM, RAM, flash memory, and the like.
  • program instructions include high-level language codes that can be executed by a computer using an interpreter, as well as machine language codes such as those produced by a compiler.
  • the hardware devices described above may be configured to operate as one or more software modules to perform the operations of the embodiments, and vice versa.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

An interrupt handling method for the Linux kernel may comprise the steps of: receiving a packet and storing same in a memory; determining whether a software interrupt is running on a first CPU from among a plurality of CPUs; searching for the CPU on which the software interrupt is not running from among the plurality of CPUs when the software interrupt is running; and selecting a second CPU from among the plurality of CPUs so as to transmit the packet stored in the memory to the second CPU.

Description

리눅스 커널의 인터럽트 처리 방법Interrupt Handling in the Linux Kernel
본 발명은 리눅스 커널의 인터럽트 처리 방법에 관한 것으로, 보다 상세하게는, 리눅스 커널의 실시간성을 보장하기 위한 방법에 관한 것이다.The present invention relates to a method for handling interrupts in the Linux kernel, and more particularly, to a method for ensuring real-time performance of the Linux kernel.
5G와 엣지 컴퓨팅은 AR 및 VR과 같은 새로운 어플리케이션들을 현실화시키고 있다. 이러한 어플리케이션들을 제공하기 위한 5G의 핵심 특성으로 저지연성과 고대역폭이 제시되었고, 통신사들은 엣지 컴퓨팅을 통해 상기 요구사항들을 충족하고 있다.5G and edge computing are enabling new applications such as AR and VR. Low latency and high bandwidth have been proposed as key characteristics of 5G to provide these applications, and telecommunications companies are meeting these requirements through edge computing.
한편, 엣지 컴퓨팅 환경에서 리눅스 커널은 광범위한 어플리케이션, 드라이버 지원으로 인해 널리 사용되고 있다. 그러나, 리눅스 커널은 실시간 운영 체제(Real Time OS)가 아니기 때문에, 자원 경합으로 인한 스케줄링 지연이 나타날 수 있다. 이는 리눅스 네트워크 스택에서 1ms 미만의 네트워크 레이턴시(latency)를 달성하는 데에 장애물이 될 수 있다. 따라서, 실시간성을 유지할 수 있는 리눅스 커널의 처리 방법이 필요하다.Meanwhile, in the edge computing environment, the Linux kernel is widely used due to its extensive application and driver support. However, since the Linux kernel is not a real-time OS, scheduling delays may occur due to resource contention. This can be an obstacle to achieving sub 1 ms network latency in the Linux network stack. Therefore, there is a need for a Linux kernel processing method capable of maintaining real-time properties.
본원 발명은 과학기술정보통신부의 차세대엣지컴퓨팅시스템기술개발(R&D)(과제고유번호: 1711125982, 과제번호:2020-0-00844-002, 연구과제명: 엣지 서버 시스템 자원 관리 및 제어를 위한 경량 시스템 소프트웨어 기술 개발, 과제관리기관: 정보통신기획평가원, 과제수행기관: 한국전자통신연구원, 연구기간: 2020.04.01~2023.12.31)의 일환으로 수행한 연구로부터 도출된 것이다.The present invention is a next-generation edge computing system technology development (R & D) of the Ministry of Science and ICT (Task identification number: 1711125982, Assignment number: 2020-0-00844-002, Research title: Lightweight system for managing and controlling edge server system resources) It was derived from a study conducted as part of software technology development, project management agency: National Institute of Information and Communications Technology Evaluation and Planning, project executing agency: Korea Electronics and Telecommunications Research Institute, research period: 2020.04.01 ~ 2023.12.31).
한편, 본 발명의 모든 측면에서 과제 제공 주체인 한국 정부의 재산 이익은 없다.On the other hand, in all aspects of the present invention, there is no property interest of the Korean government, which is the subject of the project.
본 발명의 일 과제는 CPU를 탐색하는 과정을 통해 실시간성이 보장되는 리눅스 커널의 인터럽트 처리 방법에 관한 것이다.An object of the present invention relates to a method for handling interrupts in a Linux kernel in which real-time performance is guaranteed through a process of searching for a CPU.
본 발명의 일 실시예에 따르면 실시간성이 보장되는 리눅스 커널의 인터럽트 처리 방법이 제공될 수 있다.According to an embodiment of the present invention, a method for processing an interrupt in a Linux kernel that guarantees real-time performance may be provided.
도 1은 일반적인 패킷 처리 상황 및 패킷 처리 상황에 지연이 발생하는 상황을 설명하기 위한 도면이다.1 is a diagram for explaining a general packet processing situation and a situation in which a delay occurs in the packet processing situation.
도 2는 일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법의 순서도이다.2 is a flowchart of an interrupt processing method of a Linux kernel according to an embodiment.
도 3은 일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법을 설명하기 위한 도면이다.3 is a diagram for explaining an interrupt processing method of a Linux kernel according to an embodiment.
일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법은 패킷을 수신하여 메모리에 저장하는 단계; 복수의 CPU 중 제1 CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계; 상기 소프트웨어 인터럽트가 실행중인 경우, 상기 복수의 CPU 중 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계; 및 상기 복수의 CPU 중 제2 CPU를 선택하여, 상기 제2 CPU에 상기 메모리에 저장된 패킷을 전송하는 단계를 포함할 수 있다.An interrupt processing method of a Linux kernel according to an embodiment includes receiving a packet and storing it in a memory; determining whether a software interrupt is being executed on a first CPU among the plurality of CPUs; searching for a CPU in which the software interrupt is not being executed, among the plurality of CPUs, when the software interrupt is being executed; and selecting a second CPU from among the plurality of CPUs and transmitting the packet stored in the memory to the second CPU.
여기서, 상기 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계는, 상기 복수의 CPU 중 카운터의 값이 0인 CPU를 탐색하는 단계를 포함할 수 있다.Here, the step of searching for a CPU in which the software interrupt is not executing may include searching for a CPU whose counter value is 0 among the plurality of CPUs.
여기서, 상기 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계는, 상기 복수의 CPU 중 상기 제1 CPU를 제외한 CPU들을 차례대로 탐색하는 단계를 포함할 수 있다.Here, the step of searching for a CPU in which the software interrupt is not executing may include sequentially searching for CPUs other than the first CPU among the plurality of CPUs.
여기서, 상기 패킷의 데이터 처리 우선 순위는 상기 소프트웨어 인터럽트의 데이터 처리 우선 순위보다 높을 수 있다.Here, the data processing priority of the packet may be higher than the data processing priority of the software interrupt.
여기서, 상기 제1 CPU 상에서 상기 소프트웨어 인터럽트의 처리 기간인 제1 기간은 상기 제2 CPU 상에서 상기 패킷의 처리 기간인 제2 기간과 적어도 일부가 오버랩될 수 있다.Here, the first period, which is the processing period of the software interrupt on the first CPU, may overlap at least a part with the second period, which is the processing period of the packet on the second CPU.
다른 실시예에 따른 리눅스 커널의 인터럽트 처리 방법은 복수의 CPU 중 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계; 상기 복수의 CPU 중 제1 CPU를 선택하는 단계; 및 상기 제1 CPU에 패킷을 전송하는 단계를 포함하고, 상기 CPU를 탐색하는 단계는 카운터의 값이 0인 CPU를 탐색하는 단계를 포함할 수 있다.An interrupt processing method of a Linux kernel according to another embodiment includes searching for a CPU in which software interrupts are not being executed among a plurality of CPUs; selecting a first CPU from among the plurality of CPUs; and transmitting a packet to the first CPU, wherein the searching for the CPU may include searching for a CPU whose counter value is 0.
여기서, 상기 CPU를 탐색하는 단계는, 복수의 CPU에 포함된 CPU들을 차례대로 확인하는 단계를 포함할 수 있다.Here, the step of searching for the CPU may include sequentially checking the CPUs included in the plurality of CPUs.
여기서, 상기 CPU를 탐색하는 단계는, 카운터의 값이 0인 CPU가 확인되면 다음 차례의 CPU를 확인하는 것을 중단하는 단계를 포함할 수 있다.Here, the step of searching for the CPU may include stopping checking of the next CPU when a CPU having a counter value of 0 is identified.
여기서, 상기 리눅스 커널의 인터럽트 처리 방법을 실행시키도록 컴퓨터로 판독 가능한 기록 매체에 저장된 컴퓨터 프로그램이 제공될 수 있다.Here, a computer program stored in a computer-readable recording medium may be provided to execute the interrupt handling method of the Linux kernel.
본 명세서에 기재된 실시예는 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에게 본 발명의 사상을 명확히 설명하기 위한 것이므로, 본 발명이 본 명세서에 기재된 실시예에 한정되는 것은 아니며, 본 발명의 범위는 본 발명의 사상을 벗어나지 아니하는 수정예 또는 변형예를 포함하는 것으로 해석되어야 한다.The embodiments described in this specification are intended to clearly explain the spirit of the present invention to those skilled in the art to which the present invention belongs, so the present invention is not limited to the embodiments described in this specification, and the The scope should be construed to include modifications or variations that do not depart from the spirit of the invention.
본 명세서에서 사용되는 용어는 본 발명에서의 기능을 고려하여 가능한 현재 널리 사용되고 있는 일반적인 용어를 선택하였으나 이는 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자의 의도, 판례 또는 새로운 기술의 출현 등에 따라 달라질 수 있다. 다만, 이와 달리 특정한 용어를 임의의 의미로 정의하여 사용하는 경우에는 그 용어의 의미에 관하여 별도로 기재할 것이다. 따라서 본 명세서에서 사용되는 용어는 단순한 용어의 명칭이 아닌 그 용어가 가진 실질적인 의미와 본 명세서의 전반에 걸친 내용을 토대로 해석되어야 한다.The terms used in this specification have been selected as general terms that are currently widely used as much as possible in consideration of the functions in the present invention, but these may vary depending on the intention of those skilled in the art, precedents, or the emergence of new technologies to which the present invention belongs. can However, in the case where a specific term is defined and used in an arbitrary meaning, the meaning of the term will be separately described. Therefore, the terms used in this specification should be interpreted based on the actual meaning of the term and the overall content of this specification, not the simple name of the term.
본 명세서에 첨부된 도면은 본 발명을 용이하게 설명하기 위한 것으로 도면에 도시된 형상은 본 발명의 이해를 돕기 위하여 필요에 따라 과장되어 표시된 것일 수 있으므로 본 발명이 도면에 의해 한정되는 것은 아니다.The drawings accompanying this specification are intended to easily explain the present invention, and the shapes shown in the drawings may be exaggerated as necessary to aid understanding of the present invention, so the present invention is not limited by the drawings.
본 명세서에서 본 발명에 관련된 공지의 구성 또는 기능에 대한 구체적인 설명이 본 발명의 요지를 흐릴 수 있다고 판단되는 경우에 이에 관한 자세한 설명은 필요에 따라 생략하기로 한다.If it is determined that a detailed description of a known configuration or function related to the present invention in this specification may obscure the gist of the present invention, a detailed description thereof will be omitted if necessary.
리눅스 커널에서 실시간성은 입력에 대해 결과가 정해진 시간 내에 출력되는 것을 의미할 수 있다. 예를 들어, 입력에 대해 1ms 이내에 상기 입력에 대한 결과가 출력된다면, 이는 리눅스 커널에서 실시간성이 보장되는 것으로 해석할 수 있다.In the Linux kernel, real-time can mean that results are output within a fixed time for input. For example, if the result of the input is output within 1 ms of the input, this can be interpreted as guaranteeing real-time in the Linux kernel.
종래에 리눅스 RT(Real Time) 커뮤니티는 리눅스 커널을 완전히 선점 가능하게 만드는 것을 목표로 PREEMPT_RT 패치를 사용하였다. PREEMPT_RT 패치는 리눅스 커널의 코드 패스(code path) 중 선점 불가능한 영역을 최대한 줄이는 역할을 수행했다. 이때, 선점 불가능한 영역이란, 스핀 락(spin lock)으로 보호되는 잠김 영역(locked region, critical section)을 의미하는 것일 수 있다.Previously, the Linux RT (Real Time) community used the PREEMPT_RT patch with the goal of making the Linux kernel completely preemptible. The PREEMPT_RT patch played a role in reducing the non-preemptible area of the Linux kernel's code path as much as possible. In this case, the non-preemptable region may mean a locked region (critical section) protected by a spin lock.
종래에는 PREEMPT_RT 패치를 통해 우선 순위가 낮은 어플리케이션이 우선 순위가 높은 어플리케이션이 사용해야 하는 자원을 선점하는 것이 방지되었다. 따라서, PREEMPT_RT는 실시간 운영체제에 가까운 응답 특성을 제공할 수 있었다.Conventionally, through the PREEMPT_RT patch, an application with a low priority is prevented from preoccupying a resource to be used by an application with a high priority. Therefore, PREEMPT_RT was able to provide response characteristics close to real-time operating systems.
그러나, PREEMPT_RT를 사용하더라도, 높은 우선 순위를 가지는 어플리케이션이 낮은 우선 순위를 가지는 어플리케이션보다 늦게 처리되는 지연 상황이 발생할 수 있다. 구체적으로, 상기 문제점은 구현 드라이버를 보호하기 위해 사용되는 소프트웨어 인터럽트 매커니즘에 의해서 발생될 수 있다.However, even if PREEMPT_RT is used, a delay situation may occur in which an application having a higher priority is processed later than an application having a lower priority. Specifically, the problem may be caused by the software interrupt mechanism used to protect the implementation driver.
또한, 스핀 락의 단점을 보완하기 위해, 종래에는 다른 잠김 영역(locked region)을 탐색하는 뮤텍스 락 기법을 사용했었다. 그러나, 뮤텍스 락은 동일한 CPU 상에서 컴파일하는 코드 중 특정 영역을 의미하는 다른 잠김 영역(critical section)을 찾는 것이므로, softirq 매커니즘에서 bh lock에 의해 CPU가 완전히 RT 태스크를 실행하지 못하는 문제를 해결할 수 없다.In addition, in order to compensate for the disadvantages of the spin lock, a mutex lock technique that searches for another locked region has been conventionally used. However, since the mutex lock is to find another locked area (critical section), which means a specific area among codes compiled on the same CPU, the bh lock in the softirq mechanism cannot solve the problem that the CPU cannot completely execute the RT task.
본원 발명은 이러한 종래의 문제점을 해결하기 위한 실시간성이 보장되는 리눅스 커널의 인터럽트 처리 방법을 제안한다.The present invention proposes an interrupt handling method of the Linux kernel that guarantees real-time performance to solve these conventional problems.
도 1은 일반적인 패킷 처리 상황 및 패킷 처리 상황에 지연이 발생하는 상황을 설명하기 위한 도면이다.1 is a diagram for explaining a general packet processing situation and a situation in which a delay occurs in the packet processing situation.
도 1(a)는 일반적인 패킷 처리 상황을 설명하기 위한 도면이고, 도 1(b)는 리눅스 커널의 소프트웨어 인터럽트 매커니즘으로 인해 발생되는 패킷 처리의 지연 상황을 설명하기 위한 도면이다.1(a) is a diagram for explaining a general packet processing situation, and FIG. 1(b) is a diagram for explaining a packet processing delay situation caused by a software interrupt mechanism of the Linux kernel.
도 1(a)를 참조하면, 제1 CPU는 RT 태스크를 처리하고 나서 패킷을 기다리는 대기 상황(wating state)에 진입하게 된다. 도 1(a)의 제1 CPU의 타임 라인 상에서, 빨간색 실선으로 표시된 부분은 RT 태스크를 처리하는 구간을 나타낸 것이고, 점선으로 표시한 부분은 RT 태스크를 처리하지 않는 구간을 나타낸 것이다. 구체적으로, 제1 CPU는 기준 시점(t0) 이전까지는 RT 태스크를 처리하고, 기준 시점(t0)부터 패킷을 기다리는 대기 상황에 진입하게 된다.Referring to FIG. 1(a), the first CPU processes the RT task and then enters a waiting state waiting for packets. On the timeline of the first CPU of FIG. 1( a ), a portion marked with a red solid line indicates a section in which the RT task is processed, and a section indicated in a dotted line indicates a section in which the RT task is not processed. Specifically, the first CPU processes the RT task until before the reference time point t0, and enters a standby state of waiting for packets from the reference time point t0.
제1 CPU의 대기 상황 중 리눅스 커널은 외부 장치로부터 패킷을 수신한다. 이때, 커널은 수신한 패킷에 대해 데이터 처리 과정을 수행한다. 예를 들어, 커널이 수행하는 패킷의 데이터 처리 과정은 CPU의 패킷 처리 과정을 위한 전처리 과정일 수 수 있다. 도 1(a)의 제1 CPU의 타임 라인 상에서, 파란색 실선으로 표시된 부분은 커널이 패킷에 대해 데이터 처리를 하는 과정을 나타낸 것이다.During the standby state of the first CPU, the Linux kernel receives a packet from an external device. At this time, the kernel performs a data processing process on the received packet. For example, a packet data processing process performed by a kernel may be a pre-processing process for a packet processing process of a CPU. On the time line of the first CPU in FIG. 1(a), a portion marked with a solid blue line represents a process in which a kernel processes data for a packet.
커널이 패킷에 대해 데이터 처리 과정을 수행하면, 처리된 패킷을 메모리에 저장한다. 이때, 메모리는 리눅스 커널의 내부 저장소일 수 있다. 커널 스케줄러는 메모리에 저장된 패킷의 처리를 위해 제1 CPU에 패킷과 관련된 데이터를 전송할 수 있다. 즉, 커널 스케줄러는 제1 CPU가 패킷에 대해 RT 태스크를 수행하게 할 수 있다. 이때, 제1 CPU가 패킷에 대한 데이터를 수신한 시점은 제2 시점(t2)일 수 있다.When the kernel performs data processing on packets, it stores the processed packets in memory. At this time, the memory may be an internal storage of the Linux kernel. The kernel scheduler may transmit packet-related data to the first CPU to process the packet stored in the memory. That is, the kernel scheduler may cause the first CPU to perform the RT task on the packet. In this case, the time point at which the first CPU receives the packet data may be the second time point t2.
여기까지, 도 1(a)을 참조하여 리눅스 커널에서 지연 상황이 없는 일반적인 패킷 처리 상황을 설명하였다. 도 1(b)에서는 소프트웨어 인터럽트에 의해 발생되는 패킷 처리에 대한 지연 상황을 설명한다.So far, a general packet processing situation without delay in the Linux kernel has been described with reference to FIG. 1(a). In FIG. 1(b), a delay situation for packet processing caused by a software interrupt is described.
도 1(b)를 참조하면, 도 1(a)와 같이, 제1 CPU는 RT 태스크를 수행한 이후, 기준 시점(t0)부터 패킷을 기다리는 대기 상황에 진입하게 된다. 대기 상황 도중, 제1 CPU 상에서 소프트웨어 인터럽트가 실행될 수 있다. 예를 들어, 제1 CPU 상에서 softirq가 실행되어, 제1 CPU에 softirq bottom half lock(이하, bh lock)이 걸릴 수 있다.Referring to FIG. 1(b), as shown in FIG. 1(a), after performing the RT task, the first CPU enters a waiting state in which a packet is waiting from a reference point in time t0. During the standby condition, a software interrupt may be executed on the first CPU. For example, when a softirq is executed on the first CPU, a softirq bottom half lock (hereinafter referred to as bh lock) may be taken on the first CPU.
제1 CPU 상에서 소프트웨어 인터럽트가 수행되는 도중, 커널이 제1 시점(t1)에서 패킷을 수신할 수 있다. 커널은 패킷에 대해 데이터 처리 과정을 수행하여 처리된 패킷을 메모리에 저장할 수 있다. 도 1(b)의 제1 CPU 타임 라인 상에서 커널이 패킷에 대해 데이터 처리 과정을 완료하여 패킷을 메모리에 저장한 시점은 커널 처리 완료 시점(t11)으로 표시되어 있다.While a software interrupt is being performed on the first CPU, the kernel may receive a packet at a first time point t1. The kernel may perform data processing on packets and store the processed packets in memory. On the first CPU timeline of FIG. 1(b), the time when the kernel completes the data processing process for the packet and stores the packet in the memory is indicated as the kernel processing completion time t11.
커널에 의해 처리가 완료되어 메모리에 저장된 패킷은 이후 CPU 상에서 RT 태스크 과정이 수행되어야 하는데, 제1 CPU는 미리 실행중인 소프트웨어 인터럽트에 의한 bh lock에 의해 패킷을 처리하지 못하는 문제가 발생하게 된다. 즉, 커널 스케줄러가 커널 처리 완료 시점(t11) 이후 곧바로 패킷을 제1 CPU에 전송하지 못하는 문제가 발생하게 된다.Packets that have been processed by the kernel and stored in the memory must then be subjected to an RT task process on the CPU, but the first CPU cannot process the packets due to the bh lock caused by the pre-executing software interrupt. That is, a problem arises in that the kernel scheduler cannot transmit a packet to the first CPU immediately after the kernel processing completion point (t11).
커널 스케줄러는 제1 CPU 상에서 소프트웨어 인터럽트의 수행이 완료되기까지 기다려야 하고, 이는 패킷 처리의 지연(delay)을 발생시킬 수 있다. 즉, 도 1(b)의 제1 CPU 타임라인 상에서 커널 처리 완료 시점(t11) 내지 제2 시점(t2) 까지의 지연(delay)이 발생하게 된다. 즉, 제1 CPU에 대해서 자원 경합이 발생되어 스케줄링 지연이 발생하게 된다.The kernel scheduler has to wait until the execution of the software interrupt on the first CPU is completed, which may cause a delay in packet processing. That is, a delay occurs from the kernel processing completion time t11 to the second time point t2 on the first CPU timeline of FIG. 1(b). That is, resource contention occurs with respect to the first CPU, resulting in scheduling delay.
상기 지연은 리눅스 커널의 실시간성을 해치게 되므로, 리눅스 네트워크 스택에서의 네트워크 레이턴시(latency)를 달성하는 데에 장애가 될 수 있다.Since the delay impairs real-time performance of the Linux kernel, it may be an obstacle to achieving network latency in the Linux network stack.
또한, 패킷은 일반적으로 소트프웨어 인터럽트보다 데이터 처리 우선 순위가 높음에도 불구하고, 소프트웨어 인터럽트가 CPU 상에서 미리 실행되고 있으므로, 데이터 처리 우선 순위가 낮은 것이 우선 순위가 높은 것보다 먼저 처리되는 모순이 발생하게 된다.In addition, although packets generally have a higher data processing priority than software interrupts, since software interrupts are executed in advance on the CPU, a contradiction occurs in which data processing priority is lower than that of higher priority. .
위 문제를 해결하기 위해 본원 발명은 RT 스케줄러를 수정하여, 소프트웨어 인터럽트가 실행중인 CPU가 아닌 다른 CPU를 통해 패킷을 처리하는 방법을 제안한다. 본원 발명에 따르면, 다른 CPU를 통해 커널이 패킷을 처리하고난 이후 바로 상기 다른 CPU 상에서 RT 태스크를 수행할 수 있어, 리눅스 커널의 실시간성을 보장할 수 있다.In order to solve the above problem, the present invention proposes a method of processing packets through a CPU other than the CPU in which software interrupts are executed by modifying the RT scheduler. According to the present invention, the RT task can be performed on the other CPU immediately after the kernel processes the packet through the other CPU, so that the real-time nature of the Linux kernel can be guaranteed.
이하 도 2 및 도 3을 통해 리눅스 커널의 실시간성을 보장할 수 있는 본원 발명의 인터럽트 처리 방법을 설명한다.Hereinafter, an interrupt processing method according to the present invention capable of ensuring real-time performance of the Linux kernel will be described through FIGS. 2 and 3.
도 2는 일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법의 순서도이다.2 is a flowchart of an interrupt processing method of a Linux kernel according to an embodiment.
도 2를 참조하면, 일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법은 패킷을 수신하여 메모리에 저장하는 단계(S110), CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계(S120), 다른 CPU를 탐색하는 단계(S130), CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계(S140) 및 메모리에 저장된 패킷을 CPU에 전송하는 단계(S150)를 포함할 수 있다.Referring to FIG. 2 , the interrupt processing method of the Linux kernel according to an embodiment includes receiving a packet and storing it in a memory (S110), determining whether a software interrupt is running on a CPU (S120), and selecting another CPU. It may include searching (S130), determining whether a software interrupt is running on the CPU (S140), and transmitting a packet stored in the memory to the CPU (S150).
패킷을 수신하여 메모리에 저장하는 단계(S110)는 외부 장치 또는 내부 다른 구성 요소로부터 데이터 패킷을 수신하는 단계를 포함할 수 있다. 이때, 데이터 패킷이란 정보를 포함하는 데이터 패킷일 수도 있고, 제어를 위한 신호와 관련된 데이터 패킷일 수도 있다. 데이터 패킷은 리눅스 커널이 적용되는 장치에 따라 다양할 수 있다.Receiving and storing the packet in the memory (S110) may include receiving a data packet from an external device or another internal component. In this case, the data packet may be a data packet including information or a data packet related to a signal for control. Data packets can vary depending on the device to which the Linux kernel is applied.
커널은 패킷을 수신하여 패킷에 대해 데이터 처리를 할 수 있다. 커널의 데이터 처리는 CPU 상에서 RT 태스크를 위한 데이터 전처리 과정일 수 있다. 예를 들어, 커널의 데이터 처리는 CPU의 스펙에 맞도록 데이터를 수정하는 과정일 수 있다. 또한 예를 들어, 커널의 데이터 처리는 CPU 상에서 계산 과정이 효율적으로 수행될 수 있도록, 데이터를 정리하는 과정일 수 있다.The kernel can receive packets and process data on the packets. Data processing of the kernel may be a data pre-processing process for the RT task on the CPU. For example, kernel data processing may be a process of modifying data to meet CPU specifications. Also, for example, kernel data processing may be a process of arranging data so that a calculation process can be efficiently performed on a CPU.
커널은 패킷을 데이터 처리하여 메모리에 저장할 수 있다. 이때, 메모리는 리눅스 커널이 적용되는 장치의 내부 장치이거나, 저장소로 사용하는 다른 외부 장치일 수도 있다. 메모리가 다른 외부 장치일 경우, 커널은 외부 장치와 통신하여 데이터 처리된 패킷을 전송할 수 있다.The kernel can process packets as data and store them in memory. At this time, the memory may be an internal device of a device to which the Linux kernel is applied or another external device used as a storage. If the memory is another external device, the kernel can communicate with the external device and transmit the processed data packet.
메모리의 예로는 하드디스크(HDD: Hard Disk Drive), SSD(Solid State Drive), 플래쉬 메모리(flash memory), 롬(ROM: Read-Only Memory), 램(RAM: Random Access Memory) 또는 클라우드 스토리지(Cloud Storage) 등이 있을 수 있다. 다만, 이에 한정되지 않고, 메모리는 데이터를 저장하기 위한 다양한 모듈로 구현될 수 있다.Examples of the memory include a hard disk drive (HDD), solid state drive (SSD), flash memory, read-only memory (ROM), random access memory (RAM), or cloud storage ( Cloud Storage), etc. However, it is not limited thereto, and the memory may be implemented with various modules for storing data.
CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계(S120) 커널의 패킷 처리 과정 이후, 패킷에 대해 RT 태스크를 수행하기 위한 전단계일 수 있다. 구체적으로, CPU 상에서 소프트웨어 인터럽트가 실행중일 경우, 패킷 처리에 대한 지연이 발생하기 때문에, 미리 소프트웨어 인터럽트의 실행 여부를 확인하는 단계가 필요하다. 이때, 소프트웨어 인터럽트는 softirq 함수일 수 있다.The step of determining whether a software interrupt is running on the CPU (S120) may be a previous step for performing an RT task on a packet after the packet processing process of the kernel. Specifically, when a software interrupt is being executed on the CPU, a delay in packet processing occurs, so a step of checking whether the software interrupt is executed in advance is required. In this case, the software interrupt may be a softirq function.
단계 S120에서의 CPU는 커널이 패킷을 수신하는 과정을 수행한 CPU일 수 있다. 즉, 단계 S120은 커널이 패킷을 수신하는 과정을 수행한 CPU가 패킷을 수신하기 전에 소프트웨어 인터럽트를 실행하고 있었는지 여부를 확인하는 단계일 수 있다.The CPU in step S120 may be the CPU that performed the process of receiving the packet by the kernel. That is, step S120 may be a step in which the kernel checks whether or not the CPU performing the process of receiving the packet was executing a software interrupt before receiving the packet.
소프트웨어 인터럽트가 실행중인지 여부를 판단하는 것은 소프트웨어 인터럽트 카운터(이하, 카운터)의 값을 통해 판단하는 것일 수 있다. 구체적으로, 커널 스케줄러는 카운터의 값이 0인 경우, 소프트웨어 인터럽트가 실행되지 않은 것으로 판단할 수 있다. 또한, 커널 스케줄러는 카운터의 값이 1인 경우, 소트프웨어 인터럽트가 실행되고 있는 것으로 판단할 수 있다. 이때, 소프트웨어 인터럽트 카운터는 softirq counter 함수일 수 있다.Determining whether the software interrupt is being executed may be determined through a value of a software interrupt counter (hereinafter referred to as a counter). Specifically, the kernel scheduler may determine that the software interrupt is not executed when the value of the counter is 0. Also, the kernel scheduler may determine that a software interrupt is being executed when the value of the counter is 1. In this case, the software interrupt counter may be a softirq counter function.
커널 스케줄러는 CPU의 카운터 값이 0일 경우 곧바로 단계 S150을 수행할 수 있다. 즉, CPU의 카운터 값이 0일 경우, 소프트웨어 인터럽트가 실행중이지 않기 때문에, 커널 스케줄러는 상기 CPU에 메모리에 저장된 패킷을 전송할 수 있다. 패킷을 수신한 CPU는 RT 태스크를 수행하여 패킷에 대한 데이터를 처리할 수 있다.The kernel scheduler may immediately perform step S150 when the counter value of the CPU is 0. That is, when the counter value of the CPU is 0, since the software interrupt is not running, the kernel scheduler can transmit the packet stored in the memory to the CPU. The CPU receiving the packet may process the data of the packet by performing the RT task.
그러나, 커널 스케줄러는 CPU의 카운터 값이 1일 경우, 단계 S130을 수행할 수 있다. 즉, CPU의 카운터 값이 1일 경우, 소프트웨어 인터럽트가 실행중이기 때문에, 지연을 피하기 위해 소프트웨어 인터럽트가 실행되고 있지 않은 다른 CPU를 탐색하는 과정을 수행할 수 있다.However, the kernel scheduler may perform step S130 when the counter value of the CPU is 1. That is, when the counter value of the CPU is 1, since the software interrupt is running, a process of searching for another CPU that is not running the software interrupt can be performed to avoid a delay.
다른 CPU를 탐색하는 단계(S130)는 장치에 포함된 복수의 CPU들을 순차적으로 확인하는 단계일 수 있다. 순차적으로 확인하는 것은 CPU들의 번호를 따라 차례대로 CPU의 카운터 값을 확인하는 것을 의미하는 것일 수 있다. 즉, 커널 스케줄러는 #1 CPU, #2 CPU, #3 CPU 등등 복수의 CPU의 카운터 값을 개별적으로 확인할 수 있다.The step of searching for another CPU (S130) may be a step of sequentially checking a plurality of CPUs included in the device. Sequentially checking may mean checking counter values of CPUs sequentially according to the number of CPUs. That is, the kernel scheduler can individually check the counter values of multiple CPUs, such as #1 CPU, #2 CPU, and #3 CPU.
CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계(S140)는 단계 S120과 유사할 수 있다. 예를 들어, 단계 S120의 CPU가 1번 CPU였을 경우, 커널 스케줄러는 단계 S130을 거쳐 2번 CPU를 탐색하고, 단계 S140에서는 2번 CPU의 카운터 값이 0인지 여부를 확인할 수 있다.The step of determining whether a software interrupt is being executed on the CPU (S140) may be similar to step S120. For example, if the CPU in step S120 is CPU No. 1, the kernel scheduler searches for CPU No. 2 through step S130, and in step S140, it can check whether the counter value of CPU No. 2 is 0.
2번 CPU의 카운터 값이 1일 경우, 다시 3번 CPU의 카운터 값이 0인지 여부를 확인하는 등, 커널 스케줄러는 카운터 값이 0인 CPU를 단계 S130 및 S140을 반복하여 CPU를 탐색할 수 있다.If the counter value of CPU 2 is 1, the kernel scheduler may search for a CPU whose counter value is 0 by repeating steps S130 and S140, such as checking whether the counter value of CPU 3 is 0 again. .
메모리에 저장된 패킷을 CPU에 전송하는 단계(S150)는 커널 스케줄러가 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색 및/또는 선택하고, 상기 CPU에 메모리에 저장된 패킷을 전송하는 단계일 수 있다. 이때, 커널 스케줄러가 CPU에 전송하는 패킷은 커널에 의해 데이터 처리가 된 패킷일 수 있다. 또한, 커널 스케줄러는 메모리에 저장된 패킷 외에도 RT 태스크를 위한 다른 데이터를 CPU에 전송할 수 있다.Transmitting the packet stored in the memory to the CPU ( S150 ) may be a step in which the kernel scheduler searches for and/or selects a CPU in which the software interrupt is not running, and transmits the packet stored in the memory to the CPU. At this time, the packet transmitted to the CPU by the kernel scheduler may be a packet processed by the kernel. In addition, the kernel scheduler can send other data for RT tasks to the CPU in addition to packets stored in memory.
소프트웨어 인터럽트가 실행중이지 않은 CPU는 커널 스케줄러에 의해 패킷을 획득하고, RT 태스크를 수행할 수 있다. 이때, 소프트웨어 인터럽트가 실행중이지 않은 CPU가 패킷에 대해 RT 태스크를 수행하는 기간은 소프트웨어 인터럽트가 실행중인 CPU가 소프트웨어 인터럽트를 수행하는 기간과 오버랩될 수 있다. 즉, 제1 CPU가 소프트웨어 인터럽트를 수행하는 동안 제2 CPU가 커널 스케줄러에 의해 패킷을 획득하여 패킷에 대한 RT 태스크를 수행할 수 있다.A CPU with no software interrupts running can acquire packets by the kernel scheduler and perform RT tasks. In this case, a period in which the CPU in which the software interrupt is not executing performs the RT task for the packet may overlap a period in which the CPU in which the software interrupt is executing performs the software interrupt. That is, while the first CPU performs a software interrupt, the second CPU may obtain the packet by the kernel scheduler and perform the RT task for the packet.
예를 들어, CPU가 수신한 패킷에 대해 RT 태스크를 수행하는 것은 패킷을 읽고, 패킷을 처리하기 위한 계산 과정을 수행하는 것일 수 있다. 또는 RT 태스크는 목적에 따라 수신한 패킷을 수정하는 과정일 수 있다.For example, performing the RT task on the received packet by the CPU may be reading the packet and performing a calculation process for processing the packet. Alternatively, the RT task may be a process of modifying a received packet according to a purpose.
제1 CPU의 소프트웨어 인터럽트 처리 기간과 제2 CPU의 패킷 처리 기간이 오버랩되므로, 리눅스 커널의 실시간성이 보장될 수 있다. 즉, 소프트웨어 인터럽트가 실행되지 않은 자원인 다른 CPU를 활용하여, 수신한 패킷에 대해 바로 RT 태스크가 수행될 수 있다.Since the software interrupt processing period of the first CPU and the packet processing period of the second CPU overlap, real-time performance of the Linux kernel can be guaranteed. That is, the RT task may be immediately performed on the received packet by utilizing another CPU, which is a resource on which software interrupts are not executed.
도 3은 일 실시예에 따른 리눅스 커널의 인터럽트 처리 방법을 설명하기 위한 도면이다.3 is a diagram for explaining an interrupt processing method of a Linux kernel according to an embodiment.
도 3을 참조하면, 커널 스케줄러는 다른 CPU를 탐색하여 패킷에 대한 RT 태스크를 수행할 수 있다.Referring to FIG. 3 , the kernel scheduler may perform RT tasks for packets by searching for other CPUs.
제1 CPU는 RT 태스크를 처리하고 나서 기준 시점(t0)부터 패킷을 기다리는 대기 상황에 진입하게 된다. 대기 상황 중 제1 CPU 상에서는 제1 돌발 시점(s1)에 패킷이 아닌 소프트웨어 인터럽트가 실행될 수 있다. 제1 돌발 시점(s1)부터 소트프웨어 인터럽트가 수행되는 도중, 제1 시점(t1)에 커널이 패킷을 수신할 수 있다.After processing the RT task, the first CPU enters a standby state in which it waits for packets from the reference time point t0. During the standby state, a software interrupt other than a packet may be executed on the first CPU at the first sudden point in time s1. While the software interrupt is being performed from the first sudden time point s1, the kernel may receive the packet at the first time point t1.
패킷을 수신한 커널은 데이터 처리 과정을 수행하여 패킷을 메모리에 저장할 수 있다. 커널 스케줄러는 제1 CPU에서 소프트웨어 인터럽트가 실행중이기 때문에, 패킷에 대한 RT 태스크를 바로 처리할 수 있는 다른 CPU를 탐색할 수 있다.The kernel receiving the packet may perform a data processing process and store the packet in memory. Since a software interrupt is running on the first CPU, the kernel scheduler can search for another CPU that can immediately handle the RT task for the packet.
커널 스케줄러는 장치에 포함된 복수의 CPU 중 카운터의 값이 0인 CPU를 순차적으로 탐색할 수 있다. 커널 스케줄러는 소프트웨어 인터럽트가 실행되지 않고 있는 제2 CPU를 선택할 수 있다. 커널 스케줄러는 메모리에 저장된 패킷을 제2 CPU에 전송할 수 있다. 패킷을 수신한 제2 CPU는 패킷에 대해 RT 태스크를 진행할 수 있다. 이때, 제1 CPU의 소프트웨어 인터럽트 실행 기간은 제2 CPU의 패킷에 대한 RT 태스크 처리 기간과 오버랩될 수 있다.The kernel scheduler may sequentially search for a CPU whose counter value is 0 among a plurality of CPUs included in the device. The kernel scheduler may select a second CPU on which software interrupts are not running. The kernel scheduler may transmit packets stored in the memory to the second CPU. Upon receiving the packet, the second CPU may perform an RT task on the packet. In this case, the software interrupt execution period of the first CPU may overlap the RT task processing period for the packet of the second CPU.
본원 발명의 커널 스케줄러는 제1 CPU가 소프트웨어 인터럽트를 완료할때까지 기다리지 않고, 바로 데이터 처리가 가능한 제2 CPU를 탐색하고 제2 CPU에 패킷을 전송하여, 리눅스 커널의 실시간성을 보장할 수 있다.The kernel scheduler of the present invention does not wait for the first CPU to complete a software interrupt, but immediately searches for a second CPU capable of processing data and transmits a packet to the second CPU, thereby ensuring real-time performance of the Linux kernel. .
실시예에 따른 방법은 다양한 컴퓨터 수단을 통하여 수행될 수 있는 프로그램 명령 형태로 구현되어 컴퓨터 판독 가능 매체에 기록될 수 있다. 상기 컴퓨터 판독 가능 매체는 프로그램 명령, 데이터 파일, 데이터 구조 등을 단독으로 또는 조합하여 포함할 수 있다. 상기 매체에 기록되는 프로그램 명령은 실시예를 위하여 특별히 설계되고 구성된 것들이거나 컴퓨터 소프트웨어 당업자에게 공지되어 사용 가능한 것일 수도 있다. 컴퓨터 판독 가능 기록 매체의 예에는 하드 디스크, 플로피 디스크 및 자기 테이프와 같은 자기 매체(magnetic media), CD-ROM, DVD와 같은 광기록 매체(optical media), 플롭티컬 디스크(floptical disk)와 같은 자기-광 매체(magneto-optical media), 및 롬(ROM), 램(RAM), 플래시 메모리 등과 같은 프로그램 명령을 저장하고 수행하도록 특별히 구성된 하드웨어 장치가 포함된다. 프로그램 명령의 예에는 컴파일러에 의해 만들어지는 것과 같은 기계어 코드뿐만 아니라 인터프리터 등을 사용해서 컴퓨터에 의해서 실행될 수 있는 고급 언어 코드를 포함한다. 상기된 하드웨어 장치는 실시예의 동작을 수행하기 위해 하나 이상의 소프트웨어 모듈로서 작동하도록 구성될 수 있으며, 그 역도 마찬가지이다The method according to the embodiment may be implemented in the form of program instructions that can be executed through various computer means and recorded on a computer readable medium. The computer readable medium may include program instructions, data files, data structures, etc. alone or in combination. Program commands recorded on the medium may be specially designed and configured for the embodiment or may be known and usable to those skilled in computer software. Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks and magnetic tapes, optical media such as CD-ROMs and DVDs, and magnetic media such as floptical disks. - includes hardware devices specially configured to store and execute program instructions, such as magneto-optical media, and ROM, RAM, flash memory, and the like. Examples of program instructions include high-level language codes that can be executed by a computer using an interpreter, as well as machine language codes such as those produced by a compiler. The hardware devices described above may be configured to operate as one or more software modules to perform the operations of the embodiments, and vice versa.
이상과 같이 실시예들이 비록 한정된 실시예와 도면에 의해 설명되었으나, 해당 기술분야에서 통상의 지식을 가진 자라면 상기의 기재로부터 다양한 수정 및 변형이 가능하다. 예를 들어, 설명된 기술들이 설명된 방법과 다른 순서로 수행되거나, 및/또는 설명된 시스템, 구조, 장치, 회로 등의 구성요소들이 설명된 방법과 다른 형태로 결합 또는 조합되거나, 다른 구성요소 또는 균등물에 의하여 대치되거나 치환되더라도 적절한 결과가 달성될 수 있다.As described above, although the embodiments have been described with limited examples and drawings, those skilled in the art can make various modifications and variations from the above description. For example, the described techniques may be performed in an order different from the method described, and/or components of the described system, structure, device, circuit, etc. may be combined or combined in a different form than the method described, or other components may be used. Or even if it is replaced or substituted by equivalents, appropriate results can be achieved.
그러므로, 다른 구현들, 다른 실시예들 및 특허청구범위와 균등한 것들도 후술하는 특허청구범위의 범위에 속한다.Therefore, other implementations, other embodiments, and equivalents of the claims are within the scope of the following claims.

Claims (9)

  1. 적어도 하나 이상의 프로세서에 의해 수행되는 리눅스 커널의 인터럽트 처리 방법에 있어서,In the interrupt processing method of the Linux kernel performed by at least one processor,
    패킷을 수신하여 메모리에 저장하는 단계;receiving and storing packets in a memory;
    복수의 CPU 중 제1 CPU 상에서 소프트웨어 인터럽트가 실행중인지 여부를 판단하는 단계;determining whether a software interrupt is being executed on a first CPU among the plurality of CPUs;
    상기 소프트웨어 인터럽트가 실행중인 경우, 상기 복수의 CPU 중 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계; 및searching for a CPU in which the software interrupt is not being executed, among the plurality of CPUs, when the software interrupt is being executed; and
    상기 복수의 CPU 중 제2 CPU를 선택하여, 상기 제2 CPU에 상기 메모리에 저장된 패킷을 전송하는 단계를 포함하는Selecting a second CPU from among the plurality of CPUs and transmitting the packet stored in the memory to the second CPU
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  2. 제1항에 있어서,According to claim 1,
    상기 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계는, 상기 복수의 CPU 중 카운터의 값이 0인 CPU를 탐색하는 단계를 포함하는The step of searching for a CPU in which the software interrupt is not running includes searching for a CPU whose counter value is 0 among the plurality of CPUs.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  3. 제1항에 있어서,According to claim 1,
    상기 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계는, 상기 복수의 CPU 중 상기 제1 CPU를 제외한 CPU들을 차례대로 탐색하는 단계를 포함하는The step of searching for a CPU in which the software interrupt is not executing includes sequentially searching for CPUs other than the first CPU among the plurality of CPUs.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  4. 제1항에 있어서,According to claim 1,
    상기 패킷의 데이터 처리 우선 순위는 상기 소프트웨어 인터럽트의 데이터 처리 우선 순위보다 높은The data processing priority of the packet is higher than the data processing priority of the software interrupt.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  5. 제1항에 있어서,According to claim 1,
    상기 제1 CPU 상에서 상기 소프트웨어 인터럽트의 처리 기간인 제1 기간은 상기 제2 CPU 상에서 상기 패킷의 처리 기간인 제2 기간과 적어도 일부가 오버랩되는The first period, which is the processing period of the software interrupt on the first CPU, overlaps at least a part with the second period, which is the processing period of the packet on the second CPU.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  6. 적어도 하나 이상의 프로세서에 의해 수행되는 리눅스 커널의 인터럽트 처리 방법에 있어서,In the interrupt processing method of the Linux kernel performed by at least one processor,
    복수의 CPU 중 소프트웨어 인터럽트가 실행중이지 않은 CPU를 탐색하는 단계;searching for a CPU in which a software interrupt is not running among the plurality of CPUs;
    상기 복수의 CPU 중 제1 CPU를 선택하는 단계; 및selecting a first CPU from among the plurality of CPUs; and
    상기 제1 CPU에 패킷을 전송하는 단계를 포함하고,Transmitting a packet to the first CPU;
    상기 CPU를 탐색하는 단계는 카운터의 값이 0인 CPU를 탐색하는 단계를 포함하는The step of searching for the CPU includes searching for a CPU whose counter value is 0.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  7. 제6항에 있어서,According to claim 6,
    상기 CPU를 탐색하는 단계는, 복수의 CPU에 포함된 CPU들을 차례대로 확인하는 단계를 포함하는The step of searching for the CPU includes sequentially checking the CPUs included in the plurality of CPUs.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  8. 제7항에 있어서,According to claim 7,
    상기 CPU를 탐색하는 단계는, 카운터의 값이 0인 CPU가 확인되면 다음 차례의 CPU를 확인하는 것을 중단하는 단계를 포함하는The step of searching for the CPU includes stopping checking of the next CPU when a CPU whose counter value is 0 is identified.
    리눅스 커널의 인터럽트 처리 방법.How the Linux kernel handles interrupts.
  9. 제1항에 기재된 리눅스 커널의 인터럽트 처리 방법을 실행하기 위한 프로그램이 기록된 컴퓨터로 판독 가능한 비일시적 기록 매체.A computer-readable non-transitory recording medium on which a program for executing the interrupt handling method of the Linux kernel according to claim 1 is recorded.
PCT/KR2022/020178 2021-12-20 2022-12-13 Interrupt handling method for linux kernel WO2023121104A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
KR10-2021-0182308 2021-12-20
KR20210182308 2021-12-20
KR1020220043950A KR20230094106A (en) 2021-12-20 2022-04-08 Method for processing interrupts of linux kernel
KR10-2022-0043950 2022-04-08

Publications (1)

Publication Number Publication Date
WO2023121104A1 true WO2023121104A1 (en) 2023-06-29

Family

ID=86903289

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2022/020178 WO2023121104A1 (en) 2021-12-20 2022-12-13 Interrupt handling method for linux kernel

Country Status (1)

Country Link
WO (1) WO2023121104A1 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070061464A (en) * 2005-12-08 2007-06-13 한국전자통신연구원 Method for enhancing real time response in embedded os kernel
US20110258610A1 (en) * 2010-04-16 2011-10-20 International Business Machines Corporation Optimizing performance of integrity monitoring

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070061464A (en) * 2005-12-08 2007-06-13 한국전자통신연구원 Method for enhancing real time response in embedded os kernel
US20110258610A1 (en) * 2010-04-16 2011-10-20 International Business Machines Corporation Optimizing performance of integrity monitoring

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
BOVET, DANIEL P. ET AL.: "Understanding the Linux Kernel. 3rd Edition, Cover Version 2.6.", 23 May 2016, O'REILLY MEDIA, INC., article BOVET, DANIEL P. ET AL.: "Passages; Understanding the Linux Kernel", pages: 144 - 177,259, XP009547564 *
MADDEN MICHAEL M.: "Challenges Using Linux as a Real-Time Operating System", AIAA SCITECH 2019 FORUM; 7-11 JANUARY 2019; SAN DIEGO, CALIFORNIA, USA, AMERICAN INSTITUTE OF AERONAUTICS AND ASTRONAUTICS, RESTON, VIRGINIA, 7 January 2019 (2019-01-07), Reston, Virginia , XP093074472, ISBN: 978-1-62410-578-4, DOI: 10.2514/6.2019-0502 *
WU, W. CRAWFORD, M. BOWDEN, M.: "The performance analysis of linux networking - Packet receiving", COMPUTER COMMUNICATIONS., ELSEVIER SCIENCE PUBLISHERS BV, AMSTERDAM., NL, vol. 30, no. 5, 20 February 2007 (2007-02-20), NL , pages 1044 - 1057, XP005895784, ISSN: 0140-3664, DOI: 10.1016/j.comcom.2006.11.001 *

Similar Documents

Publication Publication Date Title
US10970144B2 (en) Packet processing on a multi-core processor
WO2011053038A2 (en) Method and system for processing data for preventing deadlock
US11099872B2 (en) Techniques to copy a virtual machine
WO2014025145A1 (en) Method and apparatus for processing message between processors
US7836195B2 (en) Preserving packet order when migrating network flows between cores
US7797445B2 (en) Dynamic network link selection for transmitting a message between compute nodes of a parallel computer
US20040107240A1 (en) Method and system for intertask messaging between multiple processors
US7996843B2 (en) Symmetric multi-processor system
US10228869B1 (en) Controlling shared resources and context data
US10592281B1 (en) Wait optimizer for recording an order of first entry into a wait mode by a virtual central processing unit
US20230353419A1 (en) Cross network bridging
US7103631B1 (en) Symmetric multi-processor system
EP3756092A1 (en) Apparatus and method for managing a shareable resource in a multi-core processor
US9021492B2 (en) Dual mode reader writer lock
WO2023121104A1 (en) Interrupt handling method for linux kernel
US20050249228A1 (en) Techniques for providing scalable receive queues
US8347045B2 (en) Using a dual mode reader writer lock
US7006442B1 (en) Communication control system and control method thereof
US11126474B1 (en) Reducing resource lock time for a virtual processing unit
US11582133B2 (en) Apparatus and method for distributed processing of identical packet in high-speed network security equipment
WO2020080882A1 (en) Method for handling kernel service request for interrupt routines in multi-core environment and electronic device thereof
US9015717B2 (en) Method for processing tasks in parallel and selecting a network for communication
US9838324B2 (en) Information processing system, information management apparatus, and data transfer control method
US7680138B2 (en) Inter-module communication apparatus
KR20230094106A (en) Method for processing interrupts of linux kernel

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22911737

Country of ref document: EP

Kind code of ref document: A1