@@ -48,6 +48,7 @@ def __init__(self):
48
48
self .gh_json_file = None
49
49
self .interactive = False
50
50
self .kernel = None
51
+ self .kernel_config = None
51
52
self .kernel_dir = None
52
53
self .memory = '512m'
53
54
self .supports_efi = False
@@ -91,33 +92,40 @@ def _find_dtb(self):
91
92
)
92
93
93
94
def _get_default_smp_value (self ):
94
- if not self .kernel_dir :
95
- raise RuntimeError ('No kernel build folder specified?' )
96
-
97
- # If kernel_dir is the kernel source, the configuration will be at
98
- # <kernel_dir>/.config
99
- #
100
- # If kernel_dir is the direct parent to the full kernel image, the
101
- # configuration could either be:
102
- # * <kernel_dir>/.config (if the image is vmlinux)
103
- # * <kernel_dir>/../../../.config (if the image is in arch/*/boot/)
104
- # * <kernel_dir>/config (if the image is in a TuxMake folder)
105
- possible_locations = ['.config' , '../../../.config' , 'config' ]
106
- configuration = utils .find_first_file (self .kernel_dir ,
107
- possible_locations ,
108
- required = False )
109
-
110
- config_nr_cpus = 8 # sensible default based on treewide defaults,
111
- if configuration :
112
- conf_txt = configuration .read_text (encoding = 'utf-8' )
113
- if (match := re .search (r'CONFIG_NR_CPUS=(\d+)' , conf_txt )):
114
- config_nr_cpus = int (match .groups ()[0 ])
115
-
116
95
# Use the minimum of the number of usable processers for the script or
117
96
# CONFIG_NR_CPUS.
97
+ config_nr_cpus_default = 8 # sensible default based on treewide defaults,
98
+ config_nr_cpus = int (
99
+ self ._get_kernel_config_val ('CONFIG_NR_CPUS' ,
100
+ config_nr_cpus_default ))
118
101
usable_cpus = os .cpu_count ()
119
102
return min (usable_cpus , config_nr_cpus )
120
103
104
+ def _get_kernel_config_val (self , config , default = 'n' ):
105
+ if not self .kernel_config :
106
+ if not self .kernel_dir :
107
+ raise RuntimeError ('No kernel build folder specified?' )
108
+
109
+ # If kernel_dir is the kernel source, the configuration will be at
110
+ # <kernel_dir>/.config
111
+ #
112
+ # If kernel_dir is the direct parent to the full kernel image, the
113
+ # configuration could either be:
114
+ # * <kernel_dir>/.config (if the image is vmlinux)
115
+ # * <kernel_dir>/../../../.config (if the image is in arch/*/boot/)
116
+ # * <kernel_dir>/config (if the image is in a TuxMake folder)
117
+ possible_locations = ['.config' , '../../../.config' , 'config' ]
118
+ self .kernel_config = utils .find_first_file (self .kernel_dir ,
119
+ possible_locations ,
120
+ required = False )
121
+
122
+ if self .kernel_config :
123
+ conf_txt = self .kernel_config .read_text (encoding = 'utf-8' )
124
+ if (match := re .search (fr'^{ config } =(.*)$' , conf_txt , flags = re .M )):
125
+ return match .groups ()[0 ]
126
+
127
+ return default
128
+
121
129
def _get_kernel_ver_tuple (self , decomp_prog ):
122
130
if not self .kernel :
123
131
raise RuntimeError ('No kernel set?' )
0 commit comments