Linux kernel customization method, device and equipment
By parsing the kernel configuration item resource pool and using the Cartesian product algorithm and conflict matrix to identify the optimal combination of configuration item values, the error problem of Linux kernel configuration tools in handling complex dependencies is solved, and efficient and accurate kernel customization configuration is achieved.
Patent Information
- Application Number
- CN202510810984.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-11-18
AI Technical Summary
Existing Linux kernel configuration tools cannot effectively handle complex dependencies and configuration conflicts, leading to frequent configuration errors, especially in scenarios such as embedded devices and cloud computing where they are inefficient.
By parsing the kernel configuration management system files, a configuration item resource pool is formed. The Cartesian product algorithm is used to determine the dependency chain, construct the conflict matrix, identify the combination of mutually exclusive configuration item values, generate the optimal combination of configuration item values, and verify it to ensure the correctness of the configuration.
It achieves efficient and accurate kernel customization configuration, significantly improving the accuracy and reliability of configuration, solving the error problem caused by the reliance on manual intervention in traditional methods, and improving configuration efficiency.
Smart Images

Figure CN120973404A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software technology, and in particular to a method, apparatus and device for customizing the Linux kernel. Background Technology
[0002] As the core of modern operating systems, the Linux kernel allows for flexible customization of its functional modules and hardware support through configuration items (Kconfig). Users can enable or disable specific features (such as file systems, driver support, security mechanisms, etc.) as needed. However, complex dependencies and mutual exclusions exist among kernel configuration items, making manual configuration highly prone to errors. For example, enabling "high-performance mode" may require disabling "power-saving options," and dependency chains may involve multi-level nesting (e.g., A depends on B, and B depends on C). This complexity makes kernel customization a high-barrier task, especially for scenarios requiring fine-grained configuration, such as embedded devices and cloud computing, where automated tools are urgently needed.
[0003] Currently, mainstream configuration management tools can be divided into two categories: Graphical tools (such as make menuconfig) provide an interactive interface, but cannot automatically resolve dependency conflicts, requiring users to manually troubleshoot.
[0004] Automation tools (such as ConfigFix, Kmax): ConfigFix generates fix suggestions for dependency conflicts, but experiments show that its success rate is only about 80%, and it cannot handle multi-level conditional dependencies (such as if statements).
[0005] Kmax focuses on detecting unmet dependencies, but has limitations such as high false positives and only supporting a single error type (such as select conflict).
[0006] Therefore, the existing technology has the following drawbacks: 1. Ignoring non-explicit dependencies such as menu and if statements can lead to missed configuration errors.
[0007] 2. It cannot efficiently handle the mutual exclusion of multiple configuration items (such as the trade-off between performance optimization and power consumption control).
[0008] 3. When the number of configuration items exceeds tens of thousands, the computational complexity of existing tools explodes, and the time consumption increases dramatically. Summary of the Invention
[0009] This invention provides a Linux kernel customization method, apparatus, and device, which solves the problem that existing technologies cannot automatically handle complex dependencies and configuration conflicts, and achieves efficient and accurate kernel customization configuration.
[0010] This invention provides a method for customizing the Linux kernel, comprising the following steps: The kernel configuration management system files in the Linux kernel source code are parsed to extract all configuration items and their dependencies, forming a configuration item resource pool. Based on the user's customized requirements, the optimal combination of configuration item values is determined based on the configuration item resource pool. Generate a Linux kernel configuration file based on the optimal combination of configuration item values; The Linux kernel configuration file is verified, and a customized kernel is obtained after successful verification.
[0011] According to a Linux kernel customization method provided by the present invention, the step of determining the optimal configuration item value combination based on the configuration item resource pool specifically includes: selecting a target configuration item from the configuration item resource pool; determining the dependency chain of the target configuration item and generating all configuration item value combinations; constructing a dependency chain conflict matrix and identifying mutually exclusive configuration item value combinations; and determining the optimal configuration item value combination according to the conflict matrix.
[0012] According to a Linux kernel customization method provided by the present invention, determining the dependency chain of the target configuration item specifically includes: determining the dependency chain of the target configuration item based on the Cartesian product algorithm.
[0013] According to a Linux kernel customization method provided by the present invention, the method for determining the dependency chain of the target configuration item based on the Cartesian product algorithm specifically includes: traversing the value set of the parent dependency or child configuration item of each target configuration item; and recursively calculating the value combinations of all dependencies based on the value set to generate all dependency chains.
[0014] According to a Linux kernel customization method provided by the present invention, the construction of the dependency chain conflict matrix specifically includes: determining the number of rows and columns of the conflict matrix based on the number of dependency chains; marking the corresponding elements in the conflict matrix according to whether there is a conflict between the dependency chains; wherein, a conflict refers to two dependency chains containing mutually exclusive configuration item values; after marking is completed, the constructed conflict matrix is obtained.
[0015] According to a Linux kernel customization method provided by the present invention, the step of parsing the kernel configuration management system file in the Linux kernel source code and extracting all configuration items and their dependencies specifically includes: performing lexical analysis on the kernel configuration management system file in the Linux kernel source code to obtain a lexical unit stream; performing syntactic analysis on the lexical unit stream to obtain a syntax tree; and the syntax tree including all configuration items and their dependencies.
[0016] According to a Linux kernel customization method provided by the present invention, the step of determining the optimal configuration item value combination based on the conflict matrix specifically includes: determining the maximum independent set based on the conflict matrix; the maximum independent set is the set of dependency chains with the largest number of non-conflicting dependencies selected from all dependency chains; wherein, conflict refers to two dependency chains containing mutually exclusive configuration item values; and selecting the dependency chain with the highest priority from the maximum independent set as the optimal configuration item value combination.
[0017] According to a Linux kernel customization method provided by the present invention, the step of determining the maximum independent set based on the conflict matrix specifically includes: performing dimensionality reduction processing on the conflict matrix; the dimensionality reduction processing includes removing dependency chains with the same conflict relationship and eliminating dependency chains that do not conflict with other dependency chains; and determining the maximum independent set based on the dimensionality-reduced conflict matrix.
[0018] This invention also provides a Linux kernel customization device, comprising the following modules: The configuration item parsing module is used to parse the kernel configuration management system files in the Linux kernel source code, extract all configuration items and their dependencies, and form a configuration item resource pool. The configuration generation module is used to determine the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; and to generate a Linux kernel configuration file based on the optimal combination of configuration item values. The configuration verification module is used to verify the Linux kernel configuration file. A customized kernel is obtained after successful verification.
[0019] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the Linux kernel customization methods described above.
[0020] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the Linux kernel customization method as described above.
[0021] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements any of the Linux kernel customization methods described above.
[0022] The present invention provides a Linux kernel customization method, apparatus, and device, which have the following beneficial effects: by automatically parsing kernel configuration items and their dependencies and building a configuration item resource pool, intelligently determining the optimal configuration combination based on user needs and generating the final configuration file, and finally verifying to ensure the correctness of the configuration, the invention realizes the fully automated kernel customization process from configuration parsing to generation and verification, effectively solving the problems of traditional methods relying on manual intervention, low efficiency, and easy errors, and significantly improving the accuracy and reliability of kernel configuration. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 This is one of the flowcharts illustrating the Linux kernel customization method provided by this invention.
[0025] Figure 2 This is an architecture diagram of the Linux kernel customization method provided by this invention.
[0026] Figure 3 This is the second flowchart of the Linux kernel customization method provided by this invention.
[0027] Figure 4 This is a schematic diagram of the structure of the Linux kernel customization device provided by the present invention.
[0028] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0030] The following explains some of the English abbreviations and terms involved in this invention.
[0031] Kconfig (Kernel Configuration): The configuration management system for the Linux kernel, used to define and select functional modules and parameters during kernel compilation.
[0032] MIS (Maximum Independent Set): A graph theory concept that refers to selecting the maximum number of unconnected vertices in an undirected graph, used here to solve the mutual exclusion problem between configuration items.
[0033] Tokens (lexical units): In compiler theory, lexical analyzers divide source code into meaningful string segments, such as keywords and identifiers.
[0034] "depends on" is a keyword in Linux kernel configuration items that indicates the prerequisites that must be met for the current configuration item to be enabled.
[0035] select (reverse dependency): A keyword in Linux kernel configuration items that indicates that enabling the current configuration item will force the other specified configuration items to be enabled.
[0036] menu (menu item): A keyword in Kconfig used to group and display related configuration items.
[0037] if (conditional statement): A keyword in Kconfig used to define the conditions under which configuration items take effect.
[0038] `make oldconfig` (old configuration update command): A Linux kernel compilation command used to update new configuration options based on existing configurations.
[0039] x86 (x86 architecture): A CPU instruction set architecture introduced by Intel, widely used in personal computers and servers.
[0040] ARM (Advanced RISC Machine): A popular low-power processor architecture widely used in mobile devices.
[0041] RISC-V (Reduced Instruction Set Computer - V): An open-source reduced instruction set computer architecture.
[0042] dict (dictionary): A data structure used in programming languages such as Python to store key-value pairs.
[0043] list: A basic data structure in programming languages used to store an ordered collection of elements.
[0044] ConfigFix (Configuration Repair Tool): An automated Linux kernel configuration repair tool.
[0045] Kmax (Kconfig Maximum Analysis Tool): A tool used to analyze the dependencies of Linux kernel configuration items.
[0046] Kernel configuration item parsing refers to resolving all kernel configuration items from the source code. This includes information such as the name, category, child configuration items, and parent configuration items for all configuration items in this version. Child and parent configuration items are parsed as logical expressions. In the Kconfig grammar, the conditions for a configuration item to be valid are not limited to the `depends` keyword within the configuration item itself, but also include some attributes of upstream group keywords. The dependency propagation chain includes dependencies within configuration items and dependencies in menu items, as well as expressions pointed to by the `if` group keyword.
[0047] The kernel configuration item resource pool refers to the pool of configuration items and their values organized according to the capabilities and enhanced functions that the kernel needs to support. The current resource pool includes service scenarios, custom high-security mechanisms, general optimizations, application optimizations, and AI enhancements.
[0048] The configuration item dependency chain is analyzed as follows: When the configuration item is an option, each option needs to undergo on / off logical calculations. The Cartesian product algorithm is used to calculate all possible combinations of values for the configuration item dependency chain, and then these combinations are concatenated. When a configuration item is modified to be on (y, m, or set to other values or strings), the values of the parent dependencies that satisfy the logical expression `depends on` need to be calculated. When a configuration item is off, the values of its child configuration items that satisfy the logical expression `select` need to be calculated.
[0049] Configuration item mutual exclusion judgment: When modifying multiple configuration items, there may be mutually exclusive configuration items. In this case, it is necessary to select mutually exclusive dependency chains in the dependency chain.
[0050] The configuration item value retrieval strategy calculates mutually exclusive configuration items based on mutual exclusion criteria, then determines which configuration items to discard and modify. The current strategy is to minimize conflict, i.e., modify as many selected configuration items as possible.
[0051] Configuration file verification can be performed using `make oldconfig` on the `.config` file. This command prompts the user to configure new options based on the new kernel source code tree, while retaining existing configuration options.
[0052] Kernel verification: After the kernel configuration file is generated, the kernel needs to be verified to ensure its reliability.
[0053] Currently, several tools and methods exist to assist kernel configuration, such as graphical configuration tools like `make menuconfig` and `makexconfig`, as well as automated configuration tools like `ConfigFix` and `Kmax`. However, these tools still have many limitations in practical applications. `ConfigFix` aims to resolve dependency conflicts between configuration items to be enabled and upstream configuration items, automatically generating a set of upstream configuration item values for the configuration item to be enabled. `Kmax`, from the perspective of Kconfig development, has studied the issue of unmet dependencies for enabled configuration items and can detect configuration items that are forcibly enabled but whose dependencies are not satisfied.
[0054] Graphical configuration tools such as `make menuconfig` and `make xconfig` allow users to select configuration items through a graphical interface. However, these tools cannot automatically handle complex dependencies, requiring users to manually resolve dependency conflicts. Experimental results with ConfigFix show that there is approximately a 20% chance of failing to fix dependency conflicts, and generating configuration values that meet user needs requires a significant learning curve. Kmax, from the perspective of Kconfig development, investigated the issue of unmet dependencies for enabling configuration items. This tool suffers from a significant false positive problem and can only resolve the single error scenario of unmet dependencies for enabling configuration items, limiting its application scope.
[0055] To address the issues of complex constraints and configuration errors among kernel configuration items in Linux kernel configuration file inspection scenarios, this invention discloses a deep customization method for the Linux kernel based on Cartesian product.
[0056] The following is combined with Figures 1-5 The embodiments of the present invention are described in detail.
[0057] Figure 1 This is one of the flowcharts illustrating the Linux kernel customization method provided by this invention, such as... Figure 1 As shown, the method includes the following steps: S110. Parse the kernel configuration management system files in the Linux kernel source code, extract all configuration items and their dependencies, and form a configuration item resource pool.
[0058] According to the present invention, a Linux kernel customization method is provided, which parses the kernel configuration management system file in the Linux kernel source code and extracts all configuration items and their dependencies. Specifically, it includes: performing lexical analysis on the kernel configuration management system file in the Linux kernel source code to obtain a lexical unit stream; performing syntactic analysis on the lexical unit stream to obtain a syntax tree; and the syntax tree includes all configuration items and their dependencies.
[0059] Specifically, such as Figure 2The diagram shown illustrates the Linux kernel customization architecture provided by this invention. The input to this invention is the user's kernel customization requirements, and the output is a configuration file and the kernel. This invention mainly consists of three parts: configuration item parsing, configuration generation, and configuration verification.
[0060] The configuration item parsing part mainly preprocesses data and follows the traditional compiler front-end parsing method. It obtains a token stream (lexical unit stream) through lexical analysis, passes it to the parser to build a syntax tree, and obtains the actual semantics of Kconfig.
[0061] Specifically, the computer breaks down the contents of the Kconfig file (such as config DEBUG_KERNEL, depends on EXPERT) into smaller lexical units (called tokens), for example: config → keyword (indicating this is a configuration item); DEBUG_KERNEL → Configuration item name; depends on → Keyword (indicating a dependency relationship); EXPERT → The name of the configuration item that the dependency is.
[0062] Perform syntactic analysis on the decomposed lexical units. For example: config DEBUG_KERNEL depends on EXPERT The computer will parse it as follows: This is a configuration item called DEBUG_KERNEL; it takes effect only if EXPERT is enabled (similar to "B can only be used if A is true"). Ultimately, the computer organizes these rules into a syntax tree.
[0063] A syntax tree is just the structure; the computer also needs to understand the actual meaning of these rules. For example: "depends on EXPERT" means "DEBUG_KERNEL can only be used if the EXPERT option is enabled".
[0064] The menu "Power Management" → indicates that "all sub-configuration items belong to the 'Power Management' category".
[0065] Ultimately, the computer organizes all these dependencies and classifications into a clear "configuration item relationship network" for use in subsequent steps.
[0066] S120. Based on user customization requirements, determine the optimal combination of configuration item values based on the configuration item resource pool.
[0067] According to a Linux kernel customization method provided by the present invention, the optimal combination of configuration item values is determined based on a configuration item resource pool. Specifically, the method includes: selecting a target configuration item from the configuration item resource pool; determining the dependency chain of the target configuration item and generating all configuration item value combinations; constructing a dependency chain conflict matrix and identifying mutually exclusive configuration item value combinations; and determining the optimal combination of configuration item values based on the conflict matrix.
[0068] Specifically, the configuration item generation part mainly determines the value of the configuration item after sorting out the dependency chain and judging mutual exclusion based on the requirements.
[0069] According to a Linux kernel customization method provided by the present invention, determining the dependency chain of a target configuration item specifically includes: determining the dependency chain of the target configuration item based on the Cartesian product algorithm.
[0070] According to a Linux kernel customization method provided by the present invention, the dependency chain of a target configuration item is determined based on the Cartesian product algorithm. Specifically, it includes: traversing the value set of the parent dependency or child configuration item of each target configuration item; and recursively calculating the value combination of all dependencies based on the value set to generate all dependency chains.
[0071] Specifically, for dependency chain analysis, this invention employs the Cartesian product algorithm. For each configuration item, the set of values for its parent dependency or child configuration item is obtained, and these value sets are stored as a list, such as a list containing multiple configuration items. Each configuration item is represented by a dictionary: [{A: [{A:1}, {A:2}]}, {B: [{B:1}, {B:2}]}], where {A: [{A:1}, {A:2}]} indicates that configuration item A has two possible values: A=1 and A=2.
[0072] Starting with the first dependency, perform a Cartesian product operation on its value set with the value sets of subsequent dependencies: [{A:1, B:1}, {A:1, B:2},{A:2, B:1}, {A:2, B:2}]. If there are more dependencies (such as C), perform a Cartesian product operation on the intermediate result with the value set of C: [{A:1, B:1, C:1}, {A:1, B:1,C:2},{A:1, B:2, C:1}, {A:1, B:2, C:2},{A:2, B:1, C:1}, {A:2, B:1, C:2},{A:2, B:2, C:1}, {A:2, B:2, C:2}]. Through recursion, expand the value sets of all dependencies to generate a complete dependency chain. The final result is a list where each element is a complete combination of values.
[0073] According to a Linux kernel customization method provided by the present invention, a dependency chain conflict matrix is constructed, which specifically includes: determining the number of rows and columns of the conflict matrix based on the number of dependency chains; marking the corresponding elements in the conflict matrix according to whether there is a conflict between the dependency chains; wherein, a conflict refers to two dependency chains containing mutually exclusive configuration item values; after marking is completed, the constructed conflict matrix is obtained.
[0074] According to a Linux kernel customization method provided by the present invention, the optimal configuration item value combination is determined based on a conflict matrix, specifically including: determining the maximum independent set based on the conflict matrix; the maximum independent set is the set of dependency chains that are the most numerous and do not conflict with each other from all dependency chains; wherein, conflict refers to two dependency chains containing mutually exclusive configuration item values; and selecting the dependency chain with the highest priority from the maximum independent set as the optimal configuration item value combination.
[0075] Specifically, when modifying multiple configuration items, there may be situations where configuration items are mutually exclusive (e.g., A:1 and B:2 cannot coexist). In such cases, it's necessary to select mutually exclusive dependency chains. This problem can be abstracted as the Maximum Independent Set (MIS) problem. The maximum independent set is a concept in graph theory, referring to an independent set in an undirected graph that contains the largest number of vertices. An independent set is a subset of vertices in a graph such that no two vertices in that subset are connected by an edge. The maximum independent set is the independent set with the largest size, i.e., the independent set containing the largest number of vertices. Treating dependency chains as elements, we construct a conflict matrix for all dependency chains, where 1 represents a conflicting configuration item value on the dependency chain, and 0 represents no conflict. Therefore, the problem to be solved is to select a dependency chain from the multiple dependency chains contained in a configuration item that conflicts with other configuration items as little as possible.
[0076] Example of a conflict matrix:
[0077] (Explanation: a and b conflict, b and c conflict, a and c are compatible) According to a Linux kernel customization method provided by the present invention, the maximum independent set is determined based on the conflict matrix, specifically including: performing dimensionality reduction processing on the conflict matrix; the dimensionality reduction processing includes removing dependency chains with the same conflict relationship, and removing dependency chains that do not conflict with other dependency chains; and determining the maximum independent set based on the dimensionality-reduced conflict matrix.
[0078] Specifically, when many configuration items are modified, the Cartesian product generates more dependency chains, significantly increasing the algorithm's complexity. To address this issue, the conflict matrix of the dependency chains needs to be reduced in dimensionality. This dimensionality reduction can be considered from two aspects: 1) Remove duplicate dependency chains and deduplicate the results. Process the dictionaries in the list: if some dictionaries in the list differ by only one element value, and the set of values for that element in these dictionaries equals all possible values for that element, then merge these dictionaries and delete that element. This method can significantly reduce dimensionality to meet runtime requirements.
[0079] 2) Remove dependency chains that do not conflict with other dependency chains. In practice, tests have shown that this can reduce the dimensionality of the conflict matrix to about half of its original size.
[0080] By determining mutual exclusion among configuration items, mutually exclusive items can be identified. Then, it's necessary to decide which configuration items to discard and modify. The current strategy is to minimize conflict, meaning modifying as many selected configuration items as possible.
[0081] S130. Generate the Linux kernel configuration file based on the optimal combination of configuration item values.
[0082] S140. Verify the Linux kernel configuration file. If the verification is successful, a customized kernel is obtained.
[0083] Specifically, the configuration verification section ensures that the values of all configuration items satisfy the dependencies and mutual exclusion conditions after generating the Linux kernel configuration file, verifies the customized kernel, and ensures that the kernel can be compiled and run correctly.
[0084] like Figure 3 The diagram illustrates the steps of applying the above method according to the present invention.
[0085] Step 1: Users submit their kernel customization requirements based on specific application scenarios and hardware environments. These requirements include specific needs in areas such as performance optimization, hardware support, feature expansion, and security enhancement.
[0086] Step 2: Traverse all Kconfig files in the kernel source code and preprocess them into a single Kconfig collection file.
[0087] Step 3: Extract all relevant configuration items and their attributes, and store all configuration items and their possible values to form a configuration item resource pool. Through this resource pool, the system can quickly access and adjust the values of configuration items, supporting efficient configuration customization. If all configuration items have been processed, proceed to the next step; otherwise, return to continue processing.
[0088] Step 4: Use the Cartesian product algorithm to sort out the dependencies between configuration items and identify potential dependency conflicts and unmet dependencies.
[0089] Step 5: Generate a conflict matrix for the dependency chains of all configuration items to ensure that the dependencies and mutual exclusions between configuration items are fully considered.
[0090] Step 6: Calculate the optimal value for each configuration item based on user needs and dependencies. Use algorithms such as dynamic programming to generate the optimal configuration scheme.
[0091] Step 7: Modify the configuration file and update the values of the configuration items according to the generated configuration scheme.
[0092] Step 8: Verify the generated configuration file to ensure that the values of all configuration items satisfy the dependency and mutual exclusion conditions; Step 9: Verify the customized kernel to ensure that it can be compiled and run correctly.
[0093] During kernel customization, the system checks if the configuration item exists in the current kernel version. If it does, it handles the item's dependencies. It then checks if the configuration item is empty; if not, it enables or disables the item based on a strategy. The system handles dependencies between parent and child configuration items. A dependency chain is generated, and duplicate dependencies are removed. If parent / child configuration items have dependencies, the system calculates the dependency chain to ensure that the configuration item values satisfy the dependency expression.
[0094] This invention, based on the Cartesian product algorithm, not only supports the detection of common dependency conflicts and unsatisfied dependency issues, but also handles complex multi-level and multi-condition dependency relationships. Through comprehensive semantic modeling of kernel configuration items, this invention can identify and resolve dependency problems that existing tools cannot cover, ensuring the integrity and correctness of the configuration.
[0095] By reducing the dimensionality of the dependency chain conflict matrix, this invention solves the problem that when there are many modified configuration items, the Cartesian product generates more dependency chains, which greatly increases the complexity of the algorithm.
[0096] Based on the Maximum Independent Set (MIS) algorithm, this invention selects the optimal combination of configuration item values from multiple dependency chains, thereby selecting a dependency chain from multiple dependency chains contained in a configuration item that is as incompatible as possible with other configuration items.
[0097] This invention has undergone extensive testing on various architectures, including x86, ARM, and RISC-V, across multiple distributions, and on kernel versions ranging from v2.6 to the latest v6.0. Experimental results show that the semantic modeling and dependency analysis of this invention achieved 100% accuracy in all test environments, with no false positives. Based on a single semantic modeling step, it supports multiple runs to check configuration files, ensuring high efficiency in configuration customization. In actual testing, this invention can complete dependency analysis and error detection for over 18,000 configuration items within 2 seconds, significantly improving the efficiency of configuration customization and meeting the needs of users who frequently adjust configurations.
[0098] The Linux kernel customization device provided by the present invention will be described below. The Linux kernel customization device described below and the Linux kernel customization method described above can be referred to in correspondence.
[0099] like Figure 4 The diagram shows a Linux kernel customization device provided by the present invention, comprising: The configuration item parsing module 410 is used to parse the kernel configuration management system file in the Linux kernel source code, extract all configuration items and their dependencies, and form a configuration item resource pool. The configuration generation module 420 is used to determine the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; and to generate a Linux kernel configuration file based on the optimal combination of configuration item values. The configuration verification module 430 is used to verify the Linux kernel configuration file. A customized kernel is obtained after successful verification.
[0100] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540. The processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a Linux kernel customization method. This method includes: parsing the kernel configuration management system file in the Linux kernel source code, extracting all configuration items and their dependencies to form a configuration item resource pool; determining the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; generating a Linux kernel configuration file based on the optimal combination of configuration item values; verifying the Linux kernel configuration file, and obtaining a customized kernel upon successful verification.
[0101] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0102] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the Linux kernel customization method provided by the above methods. The method includes: parsing the kernel configuration management system file in the Linux kernel source code, extracting all configuration items and their dependencies to form a configuration item resource pool; determining the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; generating a Linux kernel configuration file according to the optimal combination of configuration item values; verifying the Linux kernel configuration file, and obtaining a customized kernel after successful verification.
[0103] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the Linux kernel customization method provided by the above methods. The method includes: parsing the kernel configuration management system file in the Linux kernel source code, extracting all configuration items and their dependencies to form a configuration item resource pool; determining the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; generating a Linux kernel configuration file based on the optimal combination of configuration item values; verifying the Linux kernel configuration file, and obtaining a customized kernel upon successful verification.
[0104] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for customizing the Linux kernel, characterized in that, include: The kernel configuration management system files in the Linux kernel source code are parsed to extract all configuration items and their dependencies, forming a configuration item resource pool. Based on the user's customized requirements, the optimal combination of configuration item values is determined based on the configuration item resource pool. Generate a Linux kernel configuration file based on the optimal combination of configuration item values; The Linux kernel configuration file is verified, and a customized kernel is obtained after successful verification.
2. The Linux kernel customization method according to claim 1, characterized in that, The step of determining the optimal combination of configuration item values based on the configuration item resource pool specifically includes: Select the target configuration item from the configuration item resource pool; Determine the dependency chain of the target configuration item and generate all possible combinations of configuration item values; Construct a dependency chain conflict matrix to identify mutually exclusive combinations of configuration item values; The optimal combination of configuration items is determined based on the conflict matrix.
3. The Linux kernel customization method according to claim 2, characterized in that, Determining the dependency chain of the target configuration item specifically includes: The dependency chain of the target configuration item is determined based on the Cartesian product algorithm.
4. The Linux kernel customization method according to claim 3, characterized in that, The determination of the dependency chain of the target configuration item based on the Cartesian product algorithm specifically includes: Iterate through the set of values for the parent dependencies or child configuration items of each target configuration item; Based on the set of values, all combinations of values for all dependencies are recursively calculated to generate all dependency chains.
5. The Linux kernel customization method according to claim 2, characterized in that, The construction of the dependency chain conflict matrix specifically includes: The number of rows and columns of the conflict matrix is determined based on the number of dependency chains; Based on whether there is a conflict between dependency chains, the corresponding elements in the conflict matrix are marked accordingly; where a conflict refers to two dependency chains containing mutually exclusive configuration item values. After marking is completed, the constructed conflict matrix is obtained.
6. The Linux kernel customization method according to claim 1, characterized in that, The process of parsing the kernel configuration management system files in the Linux kernel source code and extracting all configuration items and their dependencies specifically includes: Lexical analysis is performed on the kernel configuration management system files in the Linux kernel source code to obtain a lexical unit stream; The lexical unit stream is parsed to obtain a syntax tree; the syntax tree includes all configuration items and their dependencies.
7. The Linux kernel customization method according to claim 2, characterized in that, The step of determining the optimal combination of configuration items based on the conflict matrix specifically includes: The maximum independent set is determined based on the conflict matrix; the maximum independent set is the set of dependency chains that are the most numerous and do not conflict with each other from all dependency chains; where conflict refers to two dependency chains containing mutually exclusive configuration item values. Select the dependency chain with the highest priority from the largest independent set as the optimal combination of configuration item values.
8. The Linux kernel customization method according to claim 7, characterized in that, The determination of the maximum independent set based on the conflict matrix specifically includes: The conflict matrix is subjected to dimensionality reduction processing; the dimensionality reduction processing includes removing dependency chains with the same conflict relationship, and eliminating dependency chains that do not conflict with other dependency chains; The largest independent set is determined based on the reduced-dimensional conflict matrix.
9. A Linux kernel customization device, characterized in that, include: The configuration item parsing module is used to parse the kernel configuration management system files in the Linux kernel source code, extract all configuration items and their dependencies, and form a configuration item resource pool. The configuration generation module is used to determine the optimal combination of configuration item values based on the configuration item resource pool according to user customization requirements; and to generate a Linux kernel configuration file based on the optimal combination of configuration item values. The configuration verification module is used to verify the Linux kernel configuration file. A customized kernel is obtained after successful verification.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the Linux kernel customization method as described in any one of claims 1 to 8.