Method and system for realizing resource recovery and alarm of credential operation system

By realizing resource recycling and alarm functions in the kernel module of the Innovative Operating System, the problem of low resource utilization in the Innovative Operating System is solved, effective recycling and alarm of system resources is realized, and system performance and stability are improved.

CN119473629AInactive Publication Date: 2025-02-18SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 16 Cites 0 Cited by

Patent Information

Application Number
CN202510031486.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-09
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The resource utilization rate in the Xinchuang operating system is low, and the CPU and memory resources are not effectively and timely released, resulting in a degradation of system performance and affecting the user experience and overall efficiency of Xinchuang applications.

Method used

By implementing resource recycling and alarm functions in the kernel module, the process that occupies the largest physical memory is reduced and the memory swap out process is started, swapping the memory to disk until the specified water level line is reached. At the same time, based on the CPU and memory thresholds configured by the user, the resource usage alarm information is printed.

Benefits of technology

It realizes the effective recycling and alarm of system resources by the Innovative Innovation Operating System, improves the utilization rate of system resources, and ensures the overall stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473629A_ABST
    Figure CN119473629A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for realizing resource recovery and alarm of a creative operating system, which belong to the technical field of creative operating systems, and are characterized in that resource recovery and alarm of operating system application services are realized based on a kernel module, the priority of a process currently occupying the maximum physical memory is reduced, and a memory swap-out process is started; the memory is exchanged to a disk until a required water level line is reached; according to CPU and memory thresholds configured by a user, resource use alarm information is printed; the system resource recovery and alarm kernel module supports keyboard triggering system resource recovery, supports system resource threshold configuration and supports system resource use alarm. Effective recovery and alarm of system resources by the credential operation system are realized, the utilization rate of the system resources is improved, and the overall stability of the system is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of trusted computing operating systems, and specifically to a method and system for implementing trusted computing operating system resource recovery and alarm. Background Art

[0002] The emergence of trusted operating systems is to support and optimize specific trusted applications. These operating systems play a vital role in processing critical applications and data. Therefore, these systems have very high requirements for stability and performance, and must ensure that they can maintain efficient operation under various load conditions.

[0003] However, the actual situation shows that the resource utilization of many trusted operating systems is not satisfactory. Specifically, the CPU and memory resources in these systems are often not effectively and promptly released. The reasons for this phenomenon may include insufficient system resource management mechanisms, unreasonable resource allocation strategies, or mismatched resource requirements of the application itself. These problems prevent the operating system from fully exerting its due performance, which in turn affects the user experience and overall efficiency of trusted applications. In order to improve the resource utilization of the system, it is necessary to deeply analyze the resource management strategy of the operating system and perform targeted optimization to ensure that precious computing and storage resources can be better utilized, thereby improving the overall performance and application performance of the trusted operating system. How to effectively recycle precious system resources in a trusted environment is a key issue that each operating system vendor must solve. Summary of the invention

[0004] The technical task of the present invention is to address the above deficiencies and provide a method and system for realizing resource recovery and alarm of the trusted operating system, so as to realize the effective recovery and alarm of system resources by the trusted operating system, improve the utilization rate of system resources, and ensure the overall stability of the system.

[0005] The technical solution adopted by the present invention to solve its technical problem is: A method for realizing resource recycling and alarm of a trusted operating system, realizing resource recycling and alarm of operating system application services based on a kernel module, starting to lower the priority of the process currently occupying the largest physical memory, and starting the memory swap process to swap its memory to the disk until the required water level is reached; printing resource usage alarm information according to the CPU and memory thresholds configured by the user; The kernel module for system resource recovery and alarm supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm.

[0006] Furthermore, the resource recycling is specifically implemented as follows: Expose functions for starting memory swap and configuring process priority so that they can be called and used in modules outside the kernel; By registering keyboard events, when the user presses the specified key, the registered callback function is triggered and the resource recycling program is started; The resource recovery program starts a kthread kernel process to perform asynchronous resource detection and resource recovery; The kernel process started by resource recycling will sort all processes according to their RSS memory usage and change the process priority. Through the memory swap interface in the kernel, the memory can be adjusted to a specified watermark.

[0007] Preferably, the designated key is the "1" key.

[0008] Furthermore, the system resource threshold configuration implements the procfs interface to receive the CPU and memory alarm thresholds input by the user.

[0009] Furthermore, the warning, The resource detection function is implemented in a kernel thread. The thread will periodically traverse all processes, count the memory usage and CPU usage of the processes, and compare them with the configured CPU and memory alarm thresholds. If the threshold is exceeded, a log is printed to / dev / ttyS0.

[0010] Furthermore, the warning, Generate an array named pi_list to record the CPU usage of the process in the last scan cycle. Each element in the array is a structure that records the process ID, the CPU usage of the last cycle, and the name of the process. If the process does not have an mm object, traverse the next process in the linked list. If the CPU recorded in the element corresponding to pid is empty or the name is inconsistent, it means that the process is newly started, and it is necessary to record the current CPU usage and continue to check the next element; If there is a record of the last CPU value, continue to obtain the recorded value of the CPU time used by the current process, and calculate the difference, then multiply the difference by 100 and divide it by the time difference between the two execution scans, and compare whether it is greater than the current CPU threshold. If it is greater, the relevant information of the current process will be printed.

[0011] Furthermore, the warning, Check the memory usage of the current task, compare the ratio between the mapping of anonymous pages of memory and its total requested virtual memory with the memory threshold, and if it is greater than the memory threshold, print relevant information of the current process.

[0012] The present invention also claims a system for realizing resource recovery and alarm of a trusted operating system, wherein the system realizes a system resource recovery function and a system resource alarm function based on a resource recovery and alarm module. The system resource recovery function starts to lower the priority of the process that currently occupies the largest physical memory, and starts the memory swap process to swap its memory to the disk until the required watermark is reached; The system resource alarm function prints resource usage alarm information according to the CPU and memory thresholds configured by the user; The resource recovery and alarm module supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm; The system specifically implements resource recovery and alarm of the trusted operating system through the above method.

[0013] The present invention also claims a device for realizing resource recovery and alarm of a trusted operating system, comprising: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the above method.

[0014] The present invention also claims protection for a computer-readable medium having computer instructions stored thereon, which, when executed by a processor, causes the processor to perform the above method.

[0015] Compared with the prior art, the method and system for realizing resource recovery and alarm of the information creation operating system of the present invention have the following beneficial effects: Through the technical solution of the present invention, a kernel module for system resource recovery and alarm is implemented, keyboard-triggered system resource recovery is supported, system resource threshold configuration is supported, and system resource usage alarm is supported, thereby realizing effective recovery and alarm of system resources by the trusted operating system, improving the utilization rate of system resources and ensuring the overall stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a schematic diagram of the architectural principles of the method for implementing resource recovery and alarm for a trusted operating system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0017] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0018] The embodiment of the present invention provides a method for realizing resource recovery and alarm of a trusted operating system, and realizes resource recovery and alarm of operating system application services based on a kernel module. To realize the resource recovery function: start to lower the priority of the process that currently occupies the largest physical memory, and start the memory swap process to swap its memory to the disk until the required water level is reached; to realize the resource alarm function: print resource usage alarm information according to the CPU and memory thresholds configured by the user.

[0019] The kernel module for system resource recovery and alarm supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm.

[0020] Combined with Figure 1 As shown, the specific implementation of this method is as follows: System resource recycling: Expose functions for starting memory swap and configuring process priority so that they can be called and used in modules outside the kernel; By registering keyboard events, when the user presses the "1" key, the registered callback function is triggered and the resource recycling program is started; The resource recovery program starts a kthread kernel process to perform asynchronous resource detection and resource recovery; The kernel process started by resource recovery will sort all processes according to the RSS usage of memory, and change the process priority through the exposed function; through the memory exchange interface in the kernel, the memory can be adjusted to a specified water level.

[0021] System resource warning: Implement the resource detection function in a kernel-mode thread.

[0022] The thread will periodically traverse all processes, count the memory usage and CPU usage of the processes, and compare them with the configured CPU and memory alarm thresholds. If the threshold is exceeded, a log is printed to / dev / ttyS0 and the terminal is refreshed every 5 seconds.

[0023] Use the procfs interface to implement a file named app_resource_monitor to accept the CPU and memory alarm thresholds passed in by the user.

[0024] Register the keyboard hook and start the process: Register the keyboard hook, capture the keyboard event of the user pressing "1", and trigger a kernel state thread, which is started through the kthread_run function.

[0025] Code example for registering a keyboard hook: / / Used to pass parameters to the callback function in the registered keyboard event notification chain when a keyboard event occurs static intkeyboard_notifier_callback(structnotifier_block *nblock, unsigned long code, void *_param) { structkeyboard_notifier_param *param = _param; if (code == KBD_KEYCODE) { pr_info("state: %d\n", state); if (param->down&¶m->shift) { / / Get the value of the button unsigned int value = param->value; ch = keycode_to_char(value,param->shift); if(state==0){ if (ch == 0x1 || ch == 0x2){ pr_info("press 1\n"); if(kthread_rs_monitor){ stop_monitor_thread(); }else { / / Start monitoring thread start_monitor_thread(); } last = ch; } else { state = 0; } } } } return NOTIFY_OK; }

[0026] Register the procfs interface: By implementing a new procfs entry, the alarm thresholds for user-input CPU and memory are implemented under / procfs / app_resource_monitor.

[0027] Code example for registering the procfs interface: static intread_current_data(structseq_file *m, void *v) { / / Print the current configuration seq_printf(m, "%d,%d\n", cpu_ratio, mem_ratio); return 0; } / / Implement the interface to open the procfs file static intproc_open(structinode *inode, struct file *filp) { int (*show)(structseq_file *m, void *v) = PDE_DATA(inode); return single_open(filp, show, NULL); } / / Implement the interface for closing the procfs file static intproc_release(structinode *inode, struct file *filp) { return single_release(inode, filp); } / / Implement the interface for writing procfs files static ssize_tproc_write(struct file *fp, const char __user *buf, size_tssize, loff_t *offset) { char *str = kzalloc(sizeof(char) * ssize, GFP_KERNEL); char *p = NULL; int ret; ssize_ti; if (copy_from_user(str, buf, ssize)) { return -EINVAL; } / / find comma for (i = 0; i <ssize; i++ ) { if (str[i] == ',') { p = str + i; break; } } / / no comma if (p == NULL) { return -EINVAL; } *p = '\0'; / / Get CPU threshold ret = kstrtoint(str, 10,&cpu_ratio); if (ret<0) { kfree(str); return -EINVAL; } / / Get the memory threshold ret = kstrtoint(p + 1, 10,&mem_ratio); if (ret<0) { kfree(str); return -EINVAL; } return ssize; } / / Implement the operations required by procfs static structproc_opsproc_ops = { .proc_open = proc_open, .proc_read = seq_read, .proc_lseek = seq_lseek, .proc_release = proc_release, .proc_write = proc_write, }; / / Initialize the kernel module static intm_init(void) { / / Register the file in the proc folder proc_create_data("app_resource_monitor", 0, NULL,&proc_ops, read_current_data); return 0; } static void m_exit(void) { / / Delete the corresponding file in the proc folder remove_proc_entry("app_resource_monitor", NULL); }

[0028] Monitor current memory and CPU usage and issue alerts: In order to record the CPU usage of the process in the last scanning cycle, an array named pi_list is generated. Each element in the array is a structure that records the process ID, the CPU usage of the last cycle, and the name of the process.

[0029] If the process does not have an mm object, traverse the next process in the linked list.

[0030] If the CPU recorded in the element corresponding to pid is empty or the name is inconsistent, it means that the process is newly started, and it is necessary to record the current CPU usage and continue to check the next element.

[0031] If there is a record of the last CPU value, continue to obtain the recorded value of the CPU time used by the current process, and calculate a difference, then multiply the difference by 100 and divide it by the time difference between the two execution scans, and compare whether it is greater than the current CPU threshold. If it is greater, the variable print will be recorded as true.

[0032] Check the memory usage of the current task, compare the ratio between the mapping of anonymous pages of memory and its total requested virtual memory with the memory threshold, and if it is greater than the memory threshold, print it as true.

[0033] If print is true, then information about the current process is printed.

[0034] Implementation code example: / / Implemented the logic of the monitoring program static intmonitor_work(void *data) { structtask_struct *task; structprocess_info *pi; unsigned long total_vm, total_rss; u64 ut, st, lu, lj; u64 cm, cc; bool print = false; struct tm tm; struct timespec64 ts64; / / current time char * curtime = vzalloc(sizeof(char) * 1024); struct timespec64 lt, time; pr_info("%s is called\n", __FUNCTION__ ); lj = 0; while (!kthread_should_stop()) { if (cpu_ratio<= 0 || mem_ratio<= 0) { lj = jiffies; ktime_get_real_ts64(<); msleep(1000); continue; } for_each_process(task) { print = false; / / skip kernel thread if (!task->mm) { continue; } down_read(&task->mm->mmap_lock); if (task->pid>MAX_PID) { continue; } / / get user time task_cputime_adjusted(task,&ut,&st); ut = ut; pi =&pi_list[task->pid]; if (memcmp(pi->name, task->comm, TASK_COMM_LEN)) { / / first time find this process / / keep tracking of user mode timesand continue next / / entry pi->cpu = ut; memcpy(pi->name, task->comm, TASK_COMM_LEN); continue; } lu = pi->cpu; / / compute current cpu ratio ktime_get_real_ts64(&ts64); cc = (ut - lu) * 100 / ((ts64.tv_sec - lt.tv_sec) * 1000000000); if (cc>cpu_ratio) { print = true; } / / get memory total_vm = task->mm->total_vm; total_rss = get_mm_counter(task->mm, MM_ANONPAGES); / / compute current memory ratio cm = (total_rss) * 100 / total_vm; if (cm>mem_ratio) { print = true; } if (print) { ktime_get_real_ts64(&ts64); time64_to_tm(ts64.tv_sec, 0,&tm); / / get current time string snprintf(curtime, 1024 * sizeof(char), "%ld-%d-%d %02d:%02d:%02d",tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); / / Print the usage of the process, CPU, and memory that exceed the threshold printk("%s %d %lld %lld\n", curtime, task->pid, cc, cm); } } ktime_get_real_ts64(<); lj = jiffies; pr_debug("Complete loop \n"); / / wait 1s msleep(1000); } mon = NULL; if (curtime) { vfree(curtime); } / / return value to monitor return 0; }

[0035] The embodiment of the present invention also provides a system for realizing resource recovery and alarm of the trusted operating system. The system realizes the system resource recovery function and the system resource alarm function based on the resource recovery and alarm module. The system resource recovery function starts to lower the priority of the process that currently occupies the largest physical memory, and starts the memory swap process to swap its memory to the disk until the required watermark is reached; The system resource alarm function prints resource usage alarm information according to the CPU and memory thresholds configured by the user; The resource recovery and alarm module supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm.

[0036] The system specifically implements resource recovery and alarm of the trusted operating system through the method for implementing resource recovery and alarm of the trusted operating system described in the embodiment.

[0037] System resource recycling: Expose functions for starting memory swap and configuring process priority so that they can be called and used in modules outside the kernel; By registering keyboard events, when the user presses the "1" key, the registered callback function is triggered and the resource recycling program is started; The resource recovery program starts a kthread kernel process to perform asynchronous resource detection and resource recovery; The kernel process started by resource recycling will sort all processes according to the RSS usage of memory, and change the process priority through the exposed function; through the memory exchange interface in the kernel, the memory can be adjusted to a specified watermark.

[0038] System resource warning: Implement the resource detection function in a kernel-mode thread.

[0039] The thread will periodically traverse all processes, count the memory usage and CPU usage of the processes, and compare them with the configured CPU and memory alarm thresholds. If the threshold is exceeded, a log is printed to / dev / ttyS0 and the terminal is refreshed every 5 seconds.

[0040] Use the procfs interface to implement a file named app_resource_monitor to accept the CPU and memory alarm thresholds passed in by the user.

[0041] Register the keyboard hook and start the process: Register the keyboard hook, capture the keyboard event of the user pressing "1", and trigger a kernel state thread, which is started through the kthread_run function.

[0042] Register the procfs interface: By implementing a new procfs entry, the alarm thresholds for user-input CPU and memory are implemented under / procfs / app_resource_monitor.

[0043] Monitor current memory and CPU usage and issue alerts: In order to record the CPU usage of the process in the last scanning cycle, an array named pi_list is generated. Each element in the array is a structure that records the process ID, the CPU usage of the last cycle, and the name of the process.

[0044] If the process does not have an mm object, traverse the next process in the linked list.

[0045] If the CPU recorded in the element corresponding to pid is empty or the name is inconsistent, it means that the process is newly started, and it is necessary to record the current CPU usage and continue to check the next element.

[0046] If there is a record of the last CPU value, continue to obtain the recorded value of the CPU time used by the current process, and calculate a difference, then multiply the difference by 100 and divide it by the time difference between the two execution scans, and compare whether it is greater than the current CPU threshold. If it is greater, the relevant information of the current process will be printed.

[0047] Check the memory usage of the current task, compare the ratio between the mapping of anonymous pages of memory and its total requested virtual memory with the memory threshold, and if it is greater than the memory threshold, print relevant information of the current process.

[0048] An embodiment of the present invention further provides a device for realizing resource recovery and alarm of a trusted operating system, comprising: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method for realizing resource recovery and alarm of the trusted operating system described in the above embodiment.

[0049] The embodiment of the present invention also provides a computer-readable medium, on which computer instructions are stored, and when the computer instructions are executed by a processor, the processor executes the method for realizing resource recovery and alarm of the trusted operating system described in the above embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which software program codes for realizing the functions of any of the above embodiments are stored, and a computer (or CPU or MPU) of the system or device is enabled to read and execute the program code stored in the storage medium.

[0050] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0051] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.

[0052] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0053] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0054] The present invention is shown and described in detail above through the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above multiple embodiments, those skilled in the art can know that the code review methods in the above different embodiments can be combined to obtain more embodiments of the present invention, and these embodiments are also within the protection scope of the present invention.

Claims

1. A method for realizing resource recovery and alarm of a trusted operating system, characterized in that: Implement resource recovery and alarm for operating system application services based on kernel modules, lower the priority of the process that currently occupies the largest physical memory, and start the memory swap process to swap its memory to the disk until the required water level is reached; print resource usage alarm information according to the CPU and memory thresholds configured by the user; The kernel module for system resource recovery and alarm supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm.

2. According to the method of claim 1, the method is characterized in that: The resource recycling is specifically implemented as follows: Expose functions for starting memory swap and configuring process priority so that they can be called and used in modules outside the kernel; By registering keyboard events, when the user presses the specified key, the registered callback function is triggered and the resource recycling program is started; The resource recovery program starts a kthread kernel process to perform asynchronous resource detection and resource recovery; The kernel process started by resource recycling will sort all processes according to their RSS memory usage and change the process priority. Through the memory swap interface in the kernel, the memory can be adjusted to a specified watermark.

3. According to claim 2, a method for realizing resource recovery and alarm of a trusted operating system is characterized in that: The designated key is the "1" key.

4. According to the method of claim 1, it is characterized in that: The system resource threshold configuration implements the procfs interface to receive the CPU and memory alarm thresholds input by the user.

5. A method for realizing resource recovery and alarm of a trusted operating system according to claim 1 or 4, characterized in that: The warning, The resource detection function is implemented in a kernel thread. The thread will periodically traverse all processes, count the memory usage and CPU usage of the processes, and compare them with the configured CPU and memory alarm thresholds. If the threshold is exceeded, a log is printed to / dev / ttyS0.

6. According to claim 1, a method for realizing resource recovery and alarm of a trusted operating system is characterized in that: The warning, Generate an array named pi_list to record the CPU usage of the process in the last scan cycle. Each element in the array is a structure that records the process ID, the CPU usage of the last cycle, and the name of the process. If the process does not have an mm object, traverse the next process in the linked list. If the CPU recorded in the element corresponding to pid is empty or the name is inconsistent, it means that the process is newly started, and it is necessary to record the current CPU usage and continue to check the next element; If there is a record of the last CPU value, continue to obtain the recorded value of the CPU time used by the current process, and calculate the difference, then multiply the difference by 100 and divide it by the time difference between the two execution scans, and compare whether it is greater than the current CPU threshold. If it is greater, the relevant information of the current process will be printed.

7. A method for realizing resource recovery and alarm of a trusted operating system according to claim 1 or 6, characterized in that: The warning, Check the memory usage of the current task, compare the ratio between the mapping of anonymous pages of memory and its total requested virtual memory with the memory threshold, and if it is greater than the memory threshold, print relevant information of the current process.

8. A system for realizing resource recovery and alarm of a trusted operating system, characterized in that: The system implements system resource recovery function and system resource alarm function based on resource recovery and alarm module. The system resource recovery function starts to lower the priority of the process that currently occupies the largest physical memory, and starts the memory swap process to swap its memory to the disk until the required watermark is reached; The system resource alarm function prints resource usage alarm information according to the CPU and memory thresholds configured by the user; The resource recovery and alarm module supports keyboard-triggered system resource recovery, supports system resource threshold configuration, and supports system resource usage alarm; The system specifically implements resource recovery and alarm of the trusted operating system through any of the methods described in claims 1 to 7.

9. A device for realizing resource recovery and alarm of a trusted operating system, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is used to call the machine-readable program to implement the method described in any one of claims 1 to 7.

10. A computer-readable medium, characterized in that The computer readable medium stores computer instructions, which, when executed by a processor, cause the processor to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Page swap-out method

    CN107766151A

  • H5 page memory occupation monitoring method, device and equipment and readable storage medium

    CN109726069A

  • Server monitoring method and system

    CN112346924A

  • Method, system and device for optimization based on memory utilization rate in OpenStack environment

    CN115617513A

  • Method and device for managing and controlling resources occupied by application program and medium

    CN115794549A