CN112540871A - Method for realizing general register reservation and recovery - Google Patents

Method for realizing general register reservation and recovery Download PDF

Info

Publication number
CN112540871A
CN112540871A CN201910891118.0A CN201910891118A CN112540871A CN 112540871 A CN112540871 A CN 112540871A CN 201910891118 A CN201910891118 A CN 201910891118A CN 112540871 A CN112540871 A CN 112540871A
Authority
CN
China
Prior art keywords
user
kernel
work
reserved
processing function
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.)
Granted
Application number
CN201910891118.0A
Other languages
Chinese (zh)
Other versions
CN112540871B (en
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.)
Wuxi Jiangnan Computing Technology Institute
Original Assignee
Wuxi Jiangnan Computing Technology Institute
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 Wuxi Jiangnan Computing Technology Institute filed Critical Wuxi Jiangnan Computing Technology Institute
Priority to CN201910891118.0A priority Critical patent/CN112540871B/en
Publication of CN112540871A publication Critical patent/CN112540871A/en
Application granted granted Critical
Publication of CN112540871B publication Critical patent/CN112540871B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/142Reconfiguring to eliminate the error
    • G06F11/1428Reconfiguring to eliminate the error with loss of hardware functionality
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • 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/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)
  • Executing Machine-Instructions (AREA)

Abstract

The invention discloses a method for realizing the retention and recovery of a general register, which comprises the following steps: calling an ioctl function by a system through a user process; setting a progress flag reserving/recovering zone bit in an ioctl function; switching the kernel state to a user state, and judging a reserved/recovered flag bit according to a linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function; the do _ work _ pending processing function stores all general registers $0 to $29 in the kernel stack into a file or a specified memory; the process recovery method comprises the following steps: the first three steps are the same as the steps of the process reservation method, the kernel mode is switched to the user mode, and the reservation/recovery flag bit is judged according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function; and recovering the general registers $0 to $29 saved in the file or the specified memory to the kernel stack by the do _ work _ pending processing function, and returning the user process to the user mode after the do _ work _ pending processing function exits. The invention solves the problem of incomplete general register reservation.

Description

Method for realizing general register reservation and recovery
Technical Field
The invention relates to a method for realizing retention and recovery of a general register, belonging to the technical field of operating systems of domestic Shenwei multi-core servers.
Background
In High Performance Computing, a large application project requires fault tolerance using checkpoint techniques because the average runtime of the large application project often exceeds the effective stable runtime of a High Performance Computing (HPC) system. The system level reservation recovery is a checkpoint technology which is transparent to users, and one important technical point involved in the checkpoint technology is the system level reservation recovery of processes. The system level reservation and recovery of the process is that a user process enters an operating system kernel state through a specific system call interface, and information such as space, signals, general registers and the like of the process is reserved in the kernel state to a file; when the user is recovered, the user recovery process enters an operating system kernel state through a specific system call interface, and the kernel state recovers the space, signals and register information of the user process from the reserved file.
Currently, in a domestic Shenwei multi-core server operating system, a part of registers of a user process are mainly saved in system calling, and registers $9 to $15 are not reserved due to the agreement with a compiler, so the registers cannot be reserved in the system reservation of the process, and only registers $0 to $8 and $16 to $29 can be reserved in the system of the process. Therefore, in the retention/recovery process of the homemade Shenwei multi-core server operating system, because a general system call process is adopted, several registers of $9 to $15 cannot be saved, and recovery failure can be caused for certain applications; meanwhile, the operating system on the domestic Shenwei processor cannot completely reserve all general registers, so that the process recovery is possibly incorrect.
Disclosure of Invention
The invention aims to provide a method for realizing the retention recovery of a general register, which solves the problem of incomplete retention of the general register.
In order to achieve the purpose, the invention adopts the technical scheme that: a method for realizing general register reservation recovery comprises a process reservation method and a process recovery method, wherein the process reservation method comprises the following steps,
s11, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s12, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s13, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s14, storing all general registers $0 to $29 in the kernel stack in a do _ work _ pending processing function into a file or a specified memory;
the process recovery method comprises the following steps,
s21, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s22, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s23, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s24, restoring general registers $0 to $29 saved in a file or a designated memory to a kernel stack by a do _ work _ pending processing function, setting values of the general registers $0 to $29 on the kernel stack to registers corresponding to a processor after the do _ work _ pending processing function exits, and returning a user state by a user process.
The further improved scheme in the technical scheme is as follows:
1. in the above solution, the reservation/restoration flag is located at any one of the 14 th to 32 th bits of the flag process.
Due to the application of the technical scheme, compared with the prior art, the invention has the following advantages:
the method for realizing the retention and recovery of the general register utilizes a signal processing mechanism of Linux, and the main actions of the retention/recovery flag bit are put into the process of system call exit for execution by adding the retention/recovery flag bit in the process flag, so that the retention/recovery of all general registers can be finished at the minimum cost under the existing architecture, and a foundation is provided for perfecting the support of a domestic Shenwei processor operating system on system level retention/recovery.
Drawings
FIG. 1 is a flow chart of a method for implementing general register reservation recovery according to the present invention.
FIG. 2 is a simplified flow chart of a method for implementing the general register reservation recovery according to the present invention.
Detailed Description
In the description of this patent, it is noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience in describing the present invention and simplifying the description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus should not be construed as limiting the present invention; the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance; furthermore, unless expressly stated or limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, as they may be fixedly connected, detachably connected, or integrally connected, for example; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The meaning of the above terms in this patent may be specifically understood by those of ordinary skill in the art.
As shown in fig. 1 and 2, a method for implementing general register reservation recovery includes a process reservation method and a process recovery method, the process reservation method includes the following steps,
s11, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s12, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s13, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s14, storing all general registers $0 to $29 in the kernel stack in a do _ work _ pending processing function into a file or a specified memory;
the process recovery method comprises the following steps,
s21, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s22, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s23, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s24, restoring general registers $0 to $29 saved in a file or a designated memory to a kernel stack by a do _ work _ pending processing function, setting values of the general registers $0 to $29 on the kernel stack to registers corresponding to a processor after the do _ work _ pending processing function exits, and returning a user state by a user process.
The reservation/restoration flag is located at any one of bits 14-32 of the flag process.
The examples are further explained below:
the signal processing mechanism of Linux is to write the relevant information of signals into task _ structure (process signal) or signal _ structure (thread group signal) of other processes in a kernel mode, and then the kernel processes the signals which are not processed in the processes at a certain time. After the system is called, the system is interrupted or abnormal, and before the user process returns to the user state, signals which are not processed by the current process are processed. In particular, the user state is returned by a system call, wherein the system call exits the flow syscall _ exit, which is a part of the standard flow of the system call of the operating system user process. Checking whether a flag bit of a signal exists in a process flag bit (the flag is 32-bit data and exists in a structure of a thread _ struct of a process); if yes, jumping to a do _ work _ pending processing function in the kernel, before the jump is over, the kernel stores all registers $0 to $29 in a kernel stack of the process, and after the do _ work _ pending processing function returns, the registers $0 to $29 are recovered from the kernel stack.
By utilizing a signal processing mechanism of Linux, a reserved/recovered flag bit is defined in a flag bit of a user process and is used for representing a system reserved/recovered bit, and the judgment of the reserved/recovered flag bit is added in the judgment of a signal when a system call returns, so that the reserved/recovered system call called by a user can enter a do _ work _ pending processing function to reserve/recover registers of $0 to $29 in a kernel stack when the system call returns.
The new process retention flow is as follows: (1) the user process can enter the operating system by calling a system calling programming interface provided by the linux operating system, namely, the user mode is switched to the kernel mode; namely, a user process enters a kernel mode through a user mode system call, and the user process calls an iotcl function, wherein the iotcl is one of posix system call interfaces provided by a linux operating system for a user, and the call interface can be regarded as a function. Calling interface definition: ioctl is a function in the device driver that manages the I/O channels of the device. And the system call processing function enters the kernel mode from the user mode.
(2) And setting a reserved/recovered flag bit of a process flag in the ioctl function. The process flag is a numerical value with the length of 32 bits, the reservation/recovery flag bit is self-defined according to actual conditions, and only needs not to conflict with bits defined in the linux operating system, 0-13 bits are used in the linux operating system at present, namely the reservation/recovery flag bit can be any one of 14-32 bits, namely 14 or 15 or 16 bits and the like. The reservation/restoration flag bit is an extended definition of the flag bit in the process flag in the operating system of the Shenwei multi-core server, for example, the process flag = 0x4 (the corresponding binary number is 0100) indicates that the 2 nd bit is 1, and the 1 of the bit may indicate that the process possesses a certain attribute or state, for example, in a reservation/restoration state. When the system self-defined reserved/recovered bit in the process flag (the value with the length of 32 bits) is operated, the bit is modified from 0 to 1, and other bits are unchanged.
(3) When the user process calls the system call to enter the operating system to be executed, the operating system returns to the user state, namely when the system call is switched back from the kernel state to the user state, the system call is also in the return state, the signal flag bit judgment process is entered according to the linux signal processing mechanism process, the judgment on the reserved/recovered flag bit is added in the process, and if the reserved/recovered flag bit exists, the do _ work _ pending function is entered.
(4) And storing all general registers $0 to $29 on the kernel stack into a file or a specified memory in the do _ work _ pending processing function.
The new process recovery flow is as follows:
(1) and the user process enters a kernel mode through user mode system call, and the user process calls the system call iotcl function.
(2) And setting a reserved/recovered flag bit of a progress flag in the ioctl function.
(3) After the user process enters the kernel state through the user state system call and is executed, the kernel state is switched to the user state, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, the do _ work _ pending processing function is entered, otherwise, the do _ work _ pending processing function is not entered.
(4) And restoring the general registers $0 to $29 saved in the file or the designated memory to the kernel stack by the do _ work _ pending processing function, setting the values of the general registers $0 to $29 in the kernel stack to the registers corresponding to the processor after the do _ work _ pending processing function exits, and returning the user state by the user process. The do word pending is run in kernel mode, so the stack used by it is the kernel stack. The stack is a space used for storing inter-program call parameters, return values, return points and local variables of the subprogram. When the user process is in the user state, the used stack corresponds to the user stack, and when the user process is in the kernel state, the used stack corresponds to the kernel stack.
When the method for realizing the retention and recovery of the general register is adopted, a signal processing mechanism of Linux is utilized, the retention/recovery zone bit is added in the process flag, and the main action of the retention/recovery zone bit is put into the process of system call quitting for execution, so that the retention/recovery of all the general registers can be finished at the minimum cost under the existing architecture, and a foundation is provided for perfecting the support of a domestic Shenwei processor operating system on system level retention/recovery.
To facilitate a better understanding of the invention, the terms used herein will be briefly explained as follows:
several basic concepts need to be clarified here:
a general register: and the storage part is used for transmitting and temporarily storing data in the CPU, and can also participate in arithmetic logic operation and store an operation result.
Concept of user mode and kernel mode: when a process is in a user running state (user state) when executing the user's own code, the privilege level is the lowest level at this time, 3, which is the privilege level of the normal user process running, and most of the programs directly faced by the user are all running in the user state. The Ring3 state does not have access to Ring 0's address space, including code and data; when a process is in a kernel operating state (kernel state) because a system call is trapped in kernel code and executed, the privilege level is the highest and is 0 level. The kernel code that is executed will use the kernel stack of the current process, each process having its own kernel stack.
Concept of privilege level: for any operating system, creating a process is a core function; many tasks are required to be done by the creation process, which consumes many physical resources, such as allocating physical memory, copying information of parent and child processes, copying a page table of a page directory, and the like, and the tasks are done by a specific process, so that the concept of privilege level is provided. The most critical work must be given to the process with the highest privilege level to be executed, so that centralized management can be achieved, and access and use conflicts of limited resources are reduced. The CPUs of the inter x86 architecture have a total of four levels, levels 0-3, with the highest level 0 privilege level and the lowest level 3 privilege level.
Switching between a user mode and a kernel mode: when a program is executed in a system, the program runs in a user mode most of the time, and is switched to a kernel mode when the program needs an operating system to help complete some operations which are not privileged and capable by the user mode
And (4) process: the program in the computer is a basic unit for resource allocation and scheduling of a system with respect to one-time operation activity on a certain data set, and is the basis of an operating system structure.
And (3) system calling: a set of all system calls provided by an operating system implementation, namely a program Interface or Application Programming Interface (API), is an Interface between an Application and a system.
Kernel stack: and the system exists in a kernel space and is used for storing call parameters, return values and the like of the user process during kernel-state operation.
The above embodiments are merely illustrative of the technical ideas and features of the present invention, and the purpose thereof is to enable those skilled in the art to understand the contents of the present invention and implement the present invention, and not to limit the protection scope of the present invention. All equivalent changes and modifications made according to the spirit of the present invention should be covered within the protection scope of the present invention.

Claims (2)

1. A method for realizing general register reservation recovery is characterized in that: including a process reservation method and a process recovery method,
the process reservation method comprises the steps of,
s11, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s12, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s13, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s14, storing all general registers $0 to $29 in the kernel stack in a do _ work _ pending processing function into a file or a specified memory;
the process recovery method comprises the following steps,
s21, the user process enters a kernel state through user state system call, and the user process calls the system call ioctl function;
s22, setting a reserved/recovered flag bit of a progress flag in the ioctl function;
s23, after the user process enters the kernel mode through the user mode system call and is executed, the kernel mode is switched to the user mode, and the judgment of the reserved/recovered flag bit can be entered according to the linux signal processing mechanism; if the reserved/recovered flag bit exists, entering a do _ work _ pending processing function, otherwise, not entering the do _ work _ pending processing function;
s24, restoring general registers $0 to $29 saved in a file or a designated memory to a kernel stack by a do _ work _ pending processing function, setting values of the general registers $0 to $29 on the kernel stack to registers corresponding to a processor after the do _ work _ pending processing function exits, and returning a user state by a user process.
2. The method for implementing general register reservation recovery according to claim 1, wherein: the reservation/restoration flag is located at any one of bits 14-32 of the flag process.
CN201910891118.0A 2019-09-20 2019-09-20 Method for realizing general register reservation and recovery Active CN112540871B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910891118.0A CN112540871B (en) 2019-09-20 2019-09-20 Method for realizing general register reservation and recovery

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910891118.0A CN112540871B (en) 2019-09-20 2019-09-20 Method for realizing general register reservation and recovery

Publications (2)

Publication Number Publication Date
CN112540871A true CN112540871A (en) 2021-03-23
CN112540871B CN112540871B (en) 2022-10-04

Family

ID=75012315

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910891118.0A Active CN112540871B (en) 2019-09-20 2019-09-20 Method for realizing general register reservation and recovery

Country Status (1)

Country Link
CN (1) CN112540871B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115080122A (en) * 2022-07-22 2022-09-20 飞腾信息技术有限公司 Processor, device, method and chip for saving and restoring context data
CN115599505A (en) * 2021-06-28 2023-01-13 华为技术有限公司(Cn) User mode interrupt request processing method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226487A (en) * 2008-01-30 2008-07-23 中国船舶重工集团公司第七〇九研究所 Method for implementing inner core level thread library based on built-in Linux operating system
US20160350161A1 (en) * 2015-05-28 2016-12-01 Intel Corporation Multiple processor modes execution method and apparatus including signal handling

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101226487A (en) * 2008-01-30 2008-07-23 中国船舶重工集团公司第七〇九研究所 Method for implementing inner core level thread library based on built-in Linux operating system
US20160350161A1 (en) * 2015-05-28 2016-12-01 Intel Corporation Multiple processor modes execution method and apparatus including signal handling

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
XIAONAN TIAN 等: "《Optimizing GPU Register Usage: Extensions to OpenACC and Compiler Optimizations》", 《2016 45TH INTERNATIONAL CONFERENCE ON PARALLEL PROCESSING》 *
姜军 等: "《一种寄存器分配的优化策略》", 《计算机应用与软件》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115599505A (en) * 2021-06-28 2023-01-13 华为技术有限公司(Cn) User mode interrupt request processing method and device
CN115080122A (en) * 2022-07-22 2022-09-20 飞腾信息技术有限公司 Processor, device, method and chip for saving and restoring context data

Also Published As

Publication number Publication date
CN112540871B (en) 2022-10-04

Similar Documents

Publication Publication Date Title
US9798595B2 (en) Transparent user mode scheduling on traditional threading systems
JP4448784B2 (en) Parallel computer synchronization method and program
CN101946235B (en) Method and apparatus for moving threads in a shared processor partitioning environment
CN100570565C (en) Operating system service method and system based on strategy are provided in supervisory routine
US7406699B2 (en) Enhanced runtime hosting
CN101334721B (en) Thread livelock unit
EP2431876B1 (en) Method and device for exception handling in embedded system
CN102262559B (en) Resource sharing method and system
CN107257959B (en) System and method for garbage collection control in managed code
RU2437144C2 (en) Method to eliminate exception condition in one of nuclei of multinuclear system
CN105359101B (en) System management interrupt handling for multi-core processors
US20100083261A1 (en) Intelligent context migration for user mode scheduling
CN112306669A (en) Task processing method and device based on multi-core system
CN112540871B (en) Method for realizing general register reservation and recovery
US9563494B2 (en) Systems and methods for managing task watchdog status register entries
CN115576734A (en) Multi-core heterogeneous log storage method and system
CN115033459A (en) CPU utilization monitoring method and device and storage medium
US7673125B2 (en) Resetting multiple cells within a partition of a multiple partition computer system
US9619277B2 (en) Computer with plurality of processors sharing process queue, and process dispatch processing method
US8762776B2 (en) Recovering from a thread hang
JP2006293559A (en) Processing device and method for avoiding phenomenon of inversion of priority among tasks
Luan et al. Towards fault-tolerant task backup and recovery in the sel4 microkernel
Atwood Concurrency in operating systems
CN117272412B (en) Interrupt control register protection method, device, computer equipment and storage medium
US20240231847A9 (en) Java bytecode injection methods and apparatuses, electronic devices, and storage media

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
GR01 Patent grant
GR01 Patent grant