Retrieval method and device for Linux kernel interactive interface

By utilizing the tree-like organizational structure of Linux kernel state items and parent directory help information, combined with the search structure based on parent directory weights, the kernel state item retrieval problem in Linux system is solved, and more efficient and accurate kernel state item retrieval and visual display is achieved.

CN114816350BActive Publication Date: 2025-04-08INST OF SOFTWARE - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210463252.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2025-04-08
Estimated Expiration
2042-04-28

AI Technical Summary

Technical Problem

It is difficult for the existing technology to effectively retrieve and utilize nearly a thousand kernel status items under the Procfs and sysfs interfaces in Linux systems, especially in scenarios such as system monitoring, security, performance optimization and debugging. Traditional search methods cannot support the feature of kernel status units, making it difficult for users to find suitable kernel status items.

Method used

By using the tree-like organizational structure of the kernel state item, combined with the help information of the parent directory, the kernel state item description information is supplemented, and a search structure based on the parent directory weight is used to calculate the similarity between the keywords to be queryed and the kernel state item, and the kernel state item in the search results are visually displayed to show its association in the kernel state unit.

Benefits of technology

It improves the accuracy and efficiency of kernel state item retrieval, can better support the kernel state unit feature, help users quickly find the required kernel state items and show the relationship between them.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114816350B_ABST
    Figure CN114816350B_ABST
Patent Text Reader

Abstract

The present invention discloses a retrieval method and device for a Linux kernel interactive interface. The generation method comprises: using a file containing kernel system information in a Linux kernel interactive interface directory as a kernel status item, wherein the description text of the kernel status item comprises: help information H i Based on the path information, the kernel status item is organized according to a tree directory structure to obtain the help information of the kernel status item corresponding to the parent directory #imgabs0# based on the query keyword and the help information H i , similarity of help information #imgabs1#, and obtaining search results. The present invention not only considers parent directory information of kernel state items at all levels, but also associates kernel state items based on kernel state units.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer software, and in particular relates to a retrieval method and device for a Linux kernel interactive interface. Background Art

[0002] Procfs and sysfs are important interfaces for exchanging data between user space and kernel in Linux system. Users can view kernel system status information (such as CPU, memory, process, etc.) or modify kernel system parameters (such as the maximum number of files that a process can open) through this interface. Procfs interface is accessed through the directory / proc. The organizational structure of the / proc directory is as follows: Figure 1 As shown, the / proc directory contains subdirectories and files, and the subdirectories may also contain subdirectories and files. Each file records the status information of the kernel system, and different files contain different system information. Users can access these kernel status files as ordinary text files: users can obtain kernel system information by reading file contents, such as obtaining system memory usage information through cat / proc / meminfo; users can also change the parameters of the kernel system by writing operations to these files, such as modifying the maximum number of file handles that the current kernel can open through echo 16380> / proc / sys / fs / file-max. Sysfs is an interface split out from the procfs interface, which is mainly used to view and set the information and parameters of block devices. The interface is accessed through the directory / sys, and the directory structure is also similar to procfs. In the present invention, the files containing kernel system information under the / proc and / sys directories are called kernel status items. Each kernel status item has unique path information path, which consists of directory information dirpath and kernel status item name basename. For example, for kernel status item / proc / sys / vm / oom_dump_tasks, its directory information dirpath is / proc / sys / vm / , and kernel status item name basename is oom_dump_tasks. Directory information dirpath and kernel status item name basename constitute its complete path information. The / sys directory under the sysfs interface also has a similar organizational structure.

[0003] Kernel status items are important in scenarios such as system monitoring, system security, performance optimization, policy setting, and program debugging. Procfs and sysfs interfaces are important ways for users to interact with the kernel. Users can obtain system status and parameters through these interfaces by direct access or programmatically. However, the huge number of kernel status items provided by these interfaces makes it difficult for users to master them. In order to cover various important system modules and provide comprehensive and flexible functions, there are usually 800 to 1000 kernel status items in the / proc directory under the procfs interface alone (the number of kernel status items is related to the hardware environment and the current system operation status). All kernel status items are distributed in different directories. It is difficult for users to master so many kernel status items. When they encounter problems, it is difficult to know which kernel status items in which directory should be used. In addition, kernel status items with the same file name have different functions and meanings when they are in different directories. For example, max_user_watche has different meanings when it is in / proc / sys / fs / epoll / or / proc / sys / fs / inotify / . Kernel status item information will vary depending on the configuration item settings. For example, / proc / sys / vm / highmem_is_dirtyable only exists when the configuration item CONFIG_HIGHMEM is enabled. These factors further increase the difficulty for users to use the procfs interface. Although third-party tools based on procfs and sysfs can also be used to interact with the kernel layer instead of directly accessing kernel status items, these third-party tools often only involve a small number of kernel status items and cannot fully unleash the powerful functions provided by the procfs and sysfs interfaces. For example, tools such as domainname, hostname, and free only utilize the function of one kernel status item. In addition, third-party tools themselves are extremely diverse and huge in number, and it is also challenging for users to learn and master each tool.

[0004] Efficient search tools can help users quickly find suitable items from nearly a thousand kernel status items. However, the Linux system's own tool apropos and third-party tool howdoi are both relatively general search tools, not specifically for procfs and sysfs interface tools: apropos search objects include commands / programs, functions, etc.; howdoi search scope involves various programming languages, databases, operating systems, software tools, etc. Although apropos and howdoi can both search for kernel status item related information, the content of kernel status items they contain is not comprehensive enough, and is easily disturbed by other subject content, matching non-kernel status item information. In addition, the present invention finds that procfs and sysfs have the following characteristics when they are applied in practice: multiple kernel status items can form a kernel status unit, and multiple items in the kernel status unit are used together in many task scenarios. However, the traditional retrieval method based on relevance cannot effectively support the kernel status unit feature: (a) the traditional retrieval method only sorts the results according to similarity, resulting in the items in the same status unit being scattered in the retrieval results, and the association between the items cannot be displayed; (b) due to the inaccuracy of the query statement and other reasons, the retrieval result TopK may only contain some items in the kernel status unit. Summary of the invention

[0005] In view of the technical problems existing in the prior art, the purpose of the present invention is to provide a retrieval method and device for the Linux kernel interaction interface, which utilizes the tree-like organizational structure of kernel status items to supplement their description information to improve the retrieval effect, and visualizes each status item in the kernel status unit corresponding to the retrieval result.

[0006] The technical solution of the present invention is as follows:

[0007] A retrieval method for Linux kernel interactive interface, the steps are:

[0008] The file containing kernel system information in the Linux kernel interactive interface directory is used as a kernel status item, and the description text of the kernel status item includes: help information H i and path information, i is the depth of the kernel state item;

[0009] Based on the path information, the kernel status item is organized according to a tree directory structure to obtain help information of a parent directory corresponding to the kernel status item j is the depth of the parent directory, 0≤j<i;

[0010] Based on the query keywords and help information H i , Help Information similarity to obtain the search results.

[0011] Furthermore, the Linux kernel interaction interface includes: a procfs interface or a sysfs interface.

[0012] Furthermore, the path information includes: directory information and kernel status item name.

[0013] Furthermore, the query based on the keywords and the help information H0, help information H j , obtain the search results, including:

[0014] Treat query keywords, help information H0, help information H j Perform vector conversion respectively to obtain keyword vector q and help vector cur i , help vector cur i j ;

[0015] Calculate the keyword vector q and the help vector cur i The similarity of FW i ;

[0016] Calculate the keyword vector q and the help vector cur i j The similarity of FW i j ;

[0017] By comparing the similarity FW i Similarity FW i j Weighted summation is used to calculate the similarity S between the keyword to be queried and each kernel status item. fin , and then obtain the search result.

[0018] Furthermore, the query keyword, the help information H0, the help information H j Methods for performing vector conversion include: word2vec algorithm or glove algorithm.

[0019] Furthermore, the calculation of the keyword vector q and the help vector cur i The similarity of FW i Methods include: cosine similarity.

[0020] Furthermore, the similarity S between the query keyword and each kernel state item is fin =FW i +α 1 FW i j = i-1 +…+α i-1 FW i j=0 , where α is the weight coefficient.

[0021] Furthermore, the method further comprises:

[0022] For the kernel status item in the search result, according to the help information H i Calculate the text similarity with other kernel state items, and calculate the path similarity with other kernel state items based on the path information;

[0023] The final similarity is obtained by weighted summing the text similarity and the path similarity;

[0024] Based on the final similarity, selecting a number of other kernel state items;

[0025] The kernel state item and other selected kernel state items are placed into the same kernel state unit.

[0026] The connection between the kernel state items in the kernel state unit is visually displayed, and the connection includes: text similarity, path similarity and final similarity.

[0027] A storage medium stores a computer program, wherein the computer program is configured to execute any of the above methods when running.

[0028] An electronic device, characterized in that it comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any of the above methods.

[0029] Compared with the prior art, the present invention has the following positive effects:

[0030] (1) The traditional retrieval method only considers the relevance between the kernel state item and the query statement. The present invention considers the parent directory information of each level in addition to the kernel state item information itself when calculating the similarity.

[0031] (2) The present invention discovers the feature of kernel state unit: state items usually form a unit, and multiple items in the unit are usually used together. Traditional search methods do not provide any support for the feature of kernel state unit, but the present invention supports this feature. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 Directory organization method under the procfs interface.

[0033] Figure 2 Technical architecture diagram of the retrieval method of the present invention.

[0034] Figure 3 / proc / sys / fs / inotify / max_user_watches and its parent directory description information.

[0035] Figure 4 Flowchart of similarity calculation between kernel state items.

[0036] Figure 5 Visualization of kernel status units related to the OOM killer mechanism. DETAILED DESCRIPTION

[0037] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only specific embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0038] The retrieval method of the present invention consists of two parts: a retrieval architecture module based on parent directory weights and a kernel state unit calculation and visualization module. The retrieval architecture module based on parent directory weights uses the tree-like organizational structure of kernel state items to supplement their description information and thus improve the retrieval effect. The kernel state unit calculation and visualization module calculates each state item in the kernel state unit corresponding to the TopK result and displays it visually as a supplement to the retrieval results. In the visualization diagram, associations will be established between items belonging to the same state unit in TopK, and state items in the same unit that have not entered TopK will be displayed.

[0039] The present invention proposes a retrieval method for procfs and sysfs interfaces to help improve the interaction efficiency between users and kernel systems. The method consists of a retrieval architecture module based on parent directory weights and a kernel state unit calculation and visualization module (such as Figure 2 As shown). In the retrieval architecture module based on the parent directory weight, the similarity score between the query statement and the kernel state item is calculated, and the retrieval result is returned based on the similarity score. In the traditional retrieval method, the retrieval task is completed at this time. However, the present invention finds the characteristics of the kernel state item in practical applications: multiple similar kernel state items usually form a state unit and are used together in the application scenario. However, the traditional retrieval method can neither reflect the association between the state items nor ensure that the related kernel state items appear in the TopK results. The present invention supplements and supports this feature of the kernel state unit through the kernel state unit calculation and visualization module. Figure 2As shown, in the kernel state unit calculation and visualization module, the state item information of the kernel state unit with the same kernel state unit is first calculated for the retrieval result TopK, and then the characteristic of the kernel state unit is displayed through the visualization layer. The result returned to the user by the retrieval method of the present invention includes two parts, one part is the retrieval result based on the query statement and the correlation between each kernel state item, and the other part is the visualization of the state unit corresponding to the TopK retrieval result.

[0040] 1) If Figure 2 As shown, compared with the traditional retrieval architecture, the retrieval architecture module based on the parent directory weight is optimized by using the tree-like organizational structure of the kernel state item. The kernel state item is organized according to the tree-like directory structure, and each kernel state item has directory information dirpath. Based on the directory attribute, a retrieval architecture based on the parent directory weight is proposed. In the retrieval architecture, the help text of the parent directory is used to supplement and enhance the kernel state item text information to improve the retrieval effect. After research, the present invention found that the parent directory is of great significance to the kernel state item: (a) The meaning of the kernel state item under different directories is different. As described in the background technology, the kernel state item path path is composed of dirpath and basename. Even if the basename of two kernel state items is the same but the dirpath is different, the meanings of the two kernel state items are different. For example, the directories / proc / sys / net / ipv4 / conf / all / and / proc / sys / net / ipv4 / conf / enp0s3 / both contain kernel status items with basename log_martins. The help information of the two kernel status items is the same, but the description information for the directories / proc / sys / net / ipv4 / conf / all / and / proc / sys / net / ipv4 / conf / enp0s3 / is different. The kernel status items under the directory / proc / sys / net / ipv4 / conf / all / are valid for all network card devices, while the kernel status items under the directory / proc / sys / net / ipv4 / conf / enp0s3 / are only for the network card enp0s3. Only when the parent directory information is considered can the functional differences between / proc / sys / net / ipv4 / conf / enp0s3 / log_martins and / proc / sys / net / ipv4 / conf / all / log_martins be effectively distinguished. (b) The parent directory description information is an effective supplement to the kernel status item description information. The kernel status item help document is usually concise and brief, so some keywords closely related to its own functions may be omitted. You can use the help information of the parent directory information to supplement the current kernel status item help information. Figure 3As shown in the figure, the kernel status item / proc / sys / fs / inotify / max_user_watches can specify the upper limit of the maximum number of users monitored in the inotify mechanism to limit memory consumption. However, the help information of the kernel status item does not contain keywords such as "memory" and "inotify", while its parent directory information contains relevant keywords. The parent directory information can be used to supplement the description information of the kernel status item / proc / sys / fs / inotify / max_user_watches. Based on this, a retrieval framework based on parent directory weight is proposed. In this framework, not only the similarity between the kernel status item description document and the query statement is considered, but also the similarity between the parent directory description document and the query statement. The similarity calculation formula between the kernel status item and the query statement in the parent directory weight retrieval framework is as follows:

[0041]

[0042] Wherein q is the word vector / word embedding generated based on the query statement, cur_i is the word vector / word embedding corresponding to the kernel state item or parent directory with depth i, sim is the similarity calculation algorithm (the present invention adopts the cosine similarity algorithm), fi is the word vector / word embedding generated based on the parent directory information of the current node i, FW(q,fi) is the similarity between the parent directory description document and the query statement, and α is the weight of the parent directory in the similarity calculation.

[0043] 2) If Figure 2As shown, the calculation and visualization module of the kernel state unit includes two submodules: the calculation of the kernel state unit and the visualization of the kernel state unit. In traditional retrieval, candidate items are usually considered independent of each other. For example, in the process of web page retrieval, each web page is considered independent of each other. Even if the contents of two web pages are similar, they will be treated as independent web pages. In fact, in order to ensure the diversity of results, traditional retrieval will filter out some similar items in the results to ensure information diversity. However, in kernel state item retrieval, users often need to use all or multiple kernel state items in the same kernel state unit to complete the task together. Users expect the retrieval results to include all items of the corresponding kernel state unit rather than partial items of the unit. By visually displaying the items in the kernel state unit corresponding to the retrieval result TopK, the state items of the same unit in TopK can be effectively associated, and by displaying the state items in the same unit that have not entered TopK, the problem of only retrieving partial items of the kernel state items in the same unit due to inaccurate query statements can be solved. (a) Kernel state unit calculation method. The present invention determines the probability of two kernel state items being in the same kernel state unit by calculating the similarity between them. The calculation process of each state item in the same kernel state unit can also be regarded as a retrieval process: the query input in this retrieval process is the kernel state item instead of the ordinary query keyword. In addition to text information, the present invention finds that kernel state item path information is also an important basis for measuring the similarity between kernel state items. The Linux system organizes different kernel state items according to directories and paths. The directory or path itself is a rough classification of kernel state items based on function. Kernel state items under the same path usually have certain similarities. Therefore, when calculating the similarity between kernel state items, in addition to text factors, the path similarity factor between kernel state items is also considered. The present invention will calculate the probability that two kernel state items belong to the same kernel state unit based on text information and path information: the text similarity score S is calculated based on the kernel state item help text. txt , calculate the path similarity score S based on the kernel state item path path path , based on S txt and S path The final similarity score S of the two kernel state items can be obtained fin (like Figure 4 As shown), finally based on S fin Determine the probability that two kernel state items are in the same kernel state unit. txt The calculation uses the text similarity algorithm, S path The Jaccard correlation coefficient is used for calculation. (b) Kernel state unit visualization. This visualization method shows the following relationship between the items in the kernel state unit: For the kernel status items in the search results, when visually displaying their related kernel status items, they need to be sorted according to the similarity scores, so as to number each status item. <ii>If the kernel state items in the TopK search results are related to each other, then these state items may belong to the same kernel unit, and the visualization method clearly shows this connection. <iii>If a non-TopK kernel state item is related to multiple kernel state items in the TopK search results, the connection should be clearly displayed in the visualization method. The more kernel state items are related to the TopK search results, the more important the state item may be.

[0044] The specific steps are as follows (taking the procfs interface as an example, the sysfs interface is similar):

[0045] 1) The user enters the query keyword "memory kill";

[0046] 2) Taking the kernel status item / proc / sys / net / ipv4 / taa as an example, taa and its parent directories proc, sys, net, and ipv4 at all levels are converted into vectors based on their description texts. The vector conversion method can be completed with the help of word2vec or glove algorithm.

[0047] 3) Repeat step 2) to convert all kernel status items and their parent directories into vectors based on their description text

[0048] 4) Convert the query "memory kill" entered by the user into a vector.

[0049] 5) Taking the kernel status item / proc / sys / net / ipv4 / taa as an example, based on the vectors of proc, sys, net, ipv4 and taa, the similarity between them and the query statement vector is calculated and the corresponding similarity score s is obtained. p ,s s ,s n ,si,s t ,The similarity score can be ,completed with the help of a similarity algorithm (such as cosine similarity);

[0050] 6) The similarity scores obtained in step 5) are weighted and added to obtain the final similarity score s between the kernel state item / proc / sys / net / ipv4 / taa and the query statement fin , let the weight coefficient be α, and the calculation formula is the final similarity score s fin =α 4 *s p +α 3 *s s +α 2 *s n +α*s i +s t ;

[0051] 7) Repeat steps 5) and 6) to finally obtain the similarity scores of all kernel state items and query statements;

[0052] 8) Sort all kernel state items based on the similarity scores obtained in step 7) and return the TopK to the user according to the sorting priority.

[0053] 9) For a kernel state item in TopK, calculate the similarity between the state item and other state items.

[0054] i) Calculate the text similarity S between two state items txt ;

[0055] ii) Calculate the path similarity S between two state items path ;

[0056] iii) Calculate the final similarity S between the two state items fin ;

[0057] 10) Repeat step 9) to find the N status items that are most similar in function to the status item. These N status items are items in the same unit as the status item.

[0058] 11) Based on step 10), for each kernel state item in TopK, the items in the same state unit are visualized, such as Figure 5 The visualization of the kernel status item units related to the OOM killer mechanism is shown, and the visualization is presented to the user as a supplement to the search results in step 8). In the visualization, a clear association is established for the four kernel status items related to the OOM killer mechanism in the TopK search results, and it can be seen from the figure that / proc / [pid] / oom_score and / proc / [pid] / oom_adj are highly correlated with the four status items in the Top10 search results. If the four status items in the Top10 are the expected results of the user, the user should also pay attention to / proc / [pid] / oom_score and / proc / [pid] / oom_adj.

[0059] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.< / iii> < / ii>

Claims

1. A search method for Linux kernel interactive interface, the steps are: The file containing kernel system information in the Linux kernel interactive interface directory is used as a kernel status item, and the description text of the kernel status item includes: Help Information i and path information, i is the depth of the kernel state item; Based on the path information, the kernel status item is organized according to a tree directory structure to obtain help information of the parent directory corresponding to the kernel status item j is the depth of the parent directory, 0≤j <i; Based on the query keywords and help information H i , Help Information similarity, obtain the search results; wherein, the similarity based on the query keyword and the help information H i , Help Information , obtain the search results, including: Treat query keywords and help information H i , Help Information Perform vector conversion respectively to obtain keyword vector q and help vector cur i , help vector Calculate the keyword vector q and the help vector cur i The similarity FW i ; Calculate the keyword vector q and the help vector Similarity By comparing the similarity FW i Similarity Weighted summation is used to calculate the similarity S between the keyword to be queried and each kernel status item. fin , and then obtain the search result; For the kernel status item in the search result, according to the help information H i Calculate the text similarity with other kernel state items, and calculate the path similarity with other kernel state items based on the path information; The final similarity is obtained by weighted summing the text similarity and the path similarity; Based on the final similarity, selecting a number of other kernel state items; Putting the kernel state item and other selected kernel state items into the same kernel state unit; The connection between the kernel state items in the kernel state unit is visually displayed, and the connection includes: text similarity, path similarity and final similarity.

2. The method according to claim 1, characterized in that The Linux kernel interactive interface includes: a procfs interface or a sysfs interface.

3. The method according to claim 1, characterized in that The path information includes: directory information and kernel status item name.

4. The method according to claim 1, characterized in that The query keywords, help information H i , Help Information Methods for performing vector conversion include: word2vec algorithm or glove algorithm.

5. The method according to claim 1, characterized in that The calculation of keyword vector q and help vector cur i The similarity FW i Methods include: cosine similarity.

6. The method according to claim 1, characterized in that The similarity between the query keyword and each kernel status item Among them, α is the weight coefficient.

7. A storage medium storing a computer program, wherein: The computer program is configured to execute the method according to any one of claims 1 to 6 when executed.

8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Linux system application program memory management method and system

    CN106648938A

  • File screening method and device

    CN112579534A