kernel-yocto: enhance configuration queue analysis capabilities
This should have been tagged with "v2"
Bruce
Quoted 339 lines · Bruce Ashfield via lists.openembedded.org
From: Bruce Ashfield <[email protected]>
Enable the kernel-yocto bbclass to use enhanced capabilities from the kern-tools symbol_why.pl.
We bump the kern-tools SRCREV to pickup the reworking of
symbol_why, which uses Kconfiglib to provide analysis on configuration values.This is useful for debugging why a symbol specified in a fragment did not end up in the final .config.
We introduce two ways to interact with the new
symbol_why:1) a replacement of the existing
kconf_checkscript
2) a dedicated task that is explicitly invoked to dump details on the configuration.The
kconf_checkreplacement is transparent to the user, and is run in exactly the same way as it was previously. But we get better output and more detailed diagnostics if there are symbols that don't make it into the final .configThe second way to interact with symbol why is via the new task
do_config_analysis. This is invoked like any other task, and by default will provide a full configuration analysis and point the user at files to look at for details.If a more targetted analysis is desired, then specific symbols can be set in the
CONFIG_ANALYSISvariable. When this variable is set, the task will only run for the given symbols and provide per-variable links to the user. This variable can be set like any other, including specification in the local.conf:CONFIG_ANALYSIS_pn-linux-yocto-dev = '
NF_CONNTRACKLOCALVERSION'Which produces output as follows:
WARNING: linux-yocto-dev-5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0
do_config_analysis: Configuration analysis executed, see:tmp/work/qemuarm64-poky-linux/linux-yocto-dev/5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0/NF_CONNTRACK-config-analysis.txtfor details
WARNING: linux-yocto-dev-5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0
do_config_analysis: Configuration audit executed, see:tmp/work/qemuarm64-poky-linux/linux-yocto-dev/5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0/NF_CONNTRACK-config-audit.txtfor details
WARNING: linux-yocto-dev-5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0
do_config_analysis: Configuration analysis executed, see:tmp/work/qemuarm64-poky-linux/linux-yocto-dev/5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0/LOCALVERSION-config-analysis.txtfor details
WARNING: linux-yocto-dev-5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0
do_config_analysis: Configuration audit executed, see:work/qemuarm64-poky-linux/linux-yocto-dev/5.8-rc++gitAUTOINC+d22beb8f8a_8fc484ed37-r0/LOCALVERSION-config-audit.txtfor detailsSigned-off-by Bruce Ashfield <[email protected]>---
v2: - removed the bb.debug line that RP had to fixup previously
- fixed the detection of the .kernel-meta directory. This fixes the meta-arm build issue, and should also help meta-intel.Note: you'll actually get a configuration warning out of meta-arm when you build now, but the warning is accurate and isn't a problem (an option goes from =m to =y).
Bruce
meta/classes/kernel-yocto.bbclass | 159 ++++++++++++++---- .../kern-tools/kern-tools-native_git.bb | 2 +- meta/recipes-kernel/linux/linux-yocto_5.4.bb | 2 +- 3 files changed, 128 insertions(+), 35 deletions(-)meta/classes/kernel-yocto.bbclass +22
-0@@ -405,6 +405,67 @@ do_kernel_configme() { } addtask kernel_configme before do_configure after do_patch +addtask config_analysis + +do_config_analysis[depends] = "virtual/kernel:do_configure" +do_config_analysis[depends] += "kern-tools-native:do_populate_sysroot" + +CONFIG_AUDIT_FILE ?= "${WORKDIR}/config-audit.txt" +CONFIG_ANALYSIS_FILE ?= "${WORKDIR}/config-analysis.txt" + +python do_config_analysis() { + import re, string, sys, subprocess + + s = d.getVar('S') + + env = os.environ.copy() + env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") + env['LD'] = d.getVar('KERNEL_LD') + env['CC'] = d.getVar('KERNEL_CC') + env['ARCH'] = d.getVar('ARCH') + env['srctree'] = s + + # read specific symbols from the kernel recipe or from local.conf + # i.e.: CONFIG_ANALYSIS_pn-linux-yocto-dev = 'NF_CONNTRACKLOCALVERSION'
meta/classes/kernel-yocto.bbclass +11
-0+ config = d.getVar( 'CONFIG_ANALYSIS' ) + if not config: + config = [ "" ] + else: + config = config.split() + + for c in config: + for action in ["analysis","audit"]: + if action == "analysis": + try: + analysis = subprocess.check_output(['symbol_why.py','--dotconfig', '{}'.format(
d.getVar('B')+ '/.config' ), '--blame', c], cwd=s, env=env ).decode('utf-8')meta/classes/kernel-yocto.bbclass +2
-0+ except subprocess.CalledProcessError as e: + bb.fatal( "config analysis failed: %s" %
e.output.decode('utf-8'))meta/classes/kernel-yocto.bbclass +6
-0+ + outfile = d.getVar( 'CONFIG_ANALYSIS_FILE' ) + + if action == "audit": + try: + analysis = subprocess.check_output(['symbol_why.py','--dotconfig', '{}'.format(
d.getVar('B')+ '/.config' ), '--summary', '--extended', '--sanity', c], cwd=s, env=env ).decode('utf-8')meta/classes/kernel-yocto.bbclass +2
-0+ except subprocess.CalledProcessError as e: + bb.fatal( "config analysis failed: %s" %
e.output.decode('utf-8'))meta/classes/kernel-yocto.bbclass +15
-0+ + outfile = d.getVar( 'CONFIG_AUDIT_FILE' ) + + if c: + outdir = os.path.dirname( outfile ) + outname = os.path.basename( outfile ) + outfile = outdir + '/'+ c + '-' + outname + + if config and os.path.isfile(outfile): + os.remove(outfile) + + with open(outfile, 'w+') as f: + f.write( analysis ) + + bb.warn( "Configuration {} executed, see: {} fordetails".format(action,outfile ))
meta/classes/kernel-yocto.bbclass +8
-8+ if c: + bb.warn( analysis ) +} python do_kernel_configcheck() { import re, string, sys, subprocess@@ -414,57 +475,89 @@ python do_kernel_configcheck() { # meta-series for processing kmeta = d.getVar("KMETA") or "meta" if not os.path.exists(kmeta): - kmeta = "." + kmeta + kmeta = subprocess.check_output(['kgit', '--meta']).decode('utf-8').rstrip() s = d.getVar('S') env = os.environ.copy() env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") - env['LD'] = "${KERNEL_LD}" + env['LD'] = d.getVar('KERNEL_LD') + env['CC'] = d.getVar('KERNEL_CC') + env['ARCH'] = d.getVar('ARCH') + env['srctree'] = s try: configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8') except subprocess.CalledProcessError as e: bb.fatal( "Cannot gather config fragments for audit: %s" % e.output.decode("utf-8") ) - try: - subprocess.check_call(['kconf_check', '--report', '-o', - '%s/%s/cfg' % (s, kmeta), d.getVar('B') + '/.config', s, configs], cwd=s, env=env) - except subprocess.CalledProcessError: - # The configuration gathering can return different exit codes, but - # we interpret them based on the KCONF_AUDIT_LEVEL variable, sowe catch
meta/classes/kernel-yocto.bbclass +0
-4- # everything here, and let the run continue. - pass - config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0) bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0) - # if config check visibility is non-zero, report droppedconfiguration values
meta/classes/kernel-yocto.bbclass +1
-4- mismatch_file = d.expand("${S}/%s/cfg/mismatch.txt" % kmeta) - if os.path.exists(mismatch_file): - if config_check_visibility: - with open (mismatch_file, "r") as myfile: + # if config check visibility is "1", that's the lowest level ofaudit. So
meta/classes/kernel-yocto.bbclass +2
-0+ # we add the --classify option to the run, since classification will + # streamline the output to only report options that could be bootissues,
meta/classes/kernel-yocto.bbclass +8
-0+ # or are otherwise required for proper operation. + extra_params = "" + if config_check_visibility == 1: + extra_params = "--classify" + + # category #1: mismatches + try: + analysis = subprocess.check_output(['symbol_why.py','--dotconfig', '{}'.format(
d.getVar('B')+ '/.config' ), '--mismatches',extra_params], cwd=s, env=env ).decode('utf-8')meta/classes/kernel-yocto.bbclass +12
-0+ except subprocess.CalledProcessError as e: + bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) + + if analysis: + outfile = "{}/{}/cfg/mismatch.txt".format( s, kmeta ) + if os.path.isfile(outfile): + os.remove(outfile) + with open(outfile, 'w+') as f: + f.write( analysis ) + + if config_check_visibility and os.stat(outfile).st_size > 0: + with open (outfile, "r") as myfile: results = myfile.read() bb.warn( "[kernel config]: specified values did not makeit into the kernel's final configuration:\n\n%s" % results)
meta/classes/kernel-yocto.bbclass +0
-3- if bsp_check_visibility: - invalid_file = d.expand("${S}/%s/cfg/invalid.cfg" % kmeta) - if os.path.exists(invalid_file) and os.stat(invalid_file).st_sizeQuoted 1 line
0:
meta/classes/kernel-yocto.bbclass +0
-3- with open (invalid_file, "r") as myfile: - results = myfile.read() - bb.warn( "[kernel config]: This BSP sets config optionsthat are not offered anywhere within this kernel:\n\n%s" % results)
meta/classes/kernel-yocto.bbclass +0
-2- errors_file = d.expand("${S}/%s/cfg/fragment_errors.txt" % kmeta) - if os.path.exists(errors_file) and os.stat(errors_file).st_size >0:
meta/classes/kernel-yocto.bbclass +6
-1- with open (errors_file, "r") as myfile: + # category #2: invalid fragment elements + extra_params = "" + if bsp_check_visibility > 1: + extra_params = "--strict" + try: + analysis = subprocess.check_output(['symbol_why.py','--dotconfig', '{}'.format(
d.getVar('B')+ '/.config' ), '--invalid',extra_params], cwd=s, env=env ).decode('utf-8')meta/classes/kernel-yocto.bbclass +12
-1+ except subprocess.CalledProcessError as e: + bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) + + if analysis: + outfile = "{}/{}/cfg/invalid.txt".format(s,kmeta) + if os.path.isfile(outfile): + os.remove(outfile) + with open(outfile, 'w+') as f: + f.write( analysis ) + + if bsp_check_visibility and os.stat(outfile).st_size > 0: + with open (outfile, "r") as myfile: results = myfile.read() - bb.warn( "[kernel config]: This BSP contains fragmentswith errors:\n\n%s" % results)
meta/classes/kernel-yocto.bbclass +0
-2- - # if the audit level is greater than two, we report if a fragment hasoverriden
- # a value from a base fragment. This is really only used for new
kernel introductionmeta/classes/kernel-yocto.bbclass +0
-2- if bsp_check_visibility > 2: - redefinition_file = d.expand("${S}/%s/cfg/redefinition.txt" %kmeta)
- ifos.path.exists(redefinition_file)and
os.stat(redefinition_file).st_size > 0:meta/classes/kernel-yocto.bbclass +1
-1- with open (redefinition_file, "r") as myfile: + bb.warn( "[kernel config]: This BSP contains fragmentswith warnings:\n\n%s" % results)
meta/classes/kernel-yocto.bbclass +2
-0+ + # category #3: redefined options (this is pretty verbose and is debugonly)
meta/classes/kernel-yocto.bbclass +2
-0+ try: + analysis = subprocess.check_output(['symbol_why.py','--dotconfig', '{}'.format(
d.getVar('B')+ '/.config' ), '--sanity'], cwd=s, env=env ).decode('utf-8')meta/classes/kernel-yocto.bbclass +11
-0+ except subprocess.CalledProcessError as e: + bb.fatal( "config analysis failed: %s" % e.output.decode('utf-8')) + + if analysis: + outfile = "{}/{}/cfg/redefinition.txt".format(s,kmeta) + if os.path.isfile(outfile): + os.remove(outfile) + with open(outfile, 'w+') as f: + f.write( analysis ) + + # if the audit level is greater than two, we report if a fragmenthas overriden
+ # a value from a base fragment. This is really only used for new
kernel introductionmeta/classes/kernel-yocto.bbclass +2
-0+ if bsp_check_visibility > 2 and os.stat(outfile).st_size > 0: + with open (outfile, "r") as myfile: results = myfile.read() bb.warn( "[kernel config]: This BSP has configurationoptions defined in more than one config, with differing values:\n\n%s" % results)
}meta/recipes-kernel/kern-tools/kern-tools-native_git.bb +0
-0@@ -4,7 +4,7 @@ LIC_FILES_CHKSUM ="file://tools/kgit;beginline=5;endline=9;md5=9c30e971d435e249
DEPENDS = "git-native"
meta/recipes-kernel/kern-tools/kern-tools-native_git.bb +1
-1-SRCREV = "c66833e1caac25279a5052fceb13213f5e4f79f9" +SRCREV = "8b6fa727013daba5e8d72e5fc61d80caed944c6a" PR = "r12" PV = "0.2+git${SRCPV}"meta/recipes-kernel/linux/linux-yocto_5.4.bb +1
-2@@ -38,7 +38,7 @@ DEPENDS += "openssl-native util-linux-native" PV = "${LINUX_VERSION}+git${SRCPV}" KMETA = "kernel-meta" -KCONF_BSP_AUDIT_LEVEL = "2" +KCONF_BSP_AUDIT_LEVEL = "1" KERNEL_DEVICETREE_qemuarmv5 = "versatile-pb.dtb" --2.19.1
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end - "Use the force Harry" - Gandalf, Star Trek II