Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 464792 - sys-power/powertop doesn't find kernel .config
Summary: sys-power/powertop doesn't find kernel .config
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Rick Farina (Zero_Chaos)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-06 02:43 UTC by cujyaz
Modified: 2013-04-08 03:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch against powertop-2.3.ebuild rv. 1.2 (powertop.patch,4.53 KB, patch)
2013-04-07 20:20 UTC, cujyaz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cujyaz 2013-04-06 02:43:12 UTC
sys-power/powertop doesn't find kernel .config


Reproducible: Always

Steps to Reproduce:
1. emerge powertop

Actual Results:  
Ebuild says: "unable to find kernel config, all checks disabled"


Expected Results:  
Should find kernel .config


Reason is that linux-info_pkg_setup is called after linux_config_exists, while it must be called before to work.

BTW, powertop 2.3 is available and has no ebuild yet.
Comment 1 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-07 15:15:52 UTC
version bumped as requested.
Comment 2 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-07 15:22:44 UTC
The proper way to check the kernel config for options is to first check if a config exists, and then to check it for options if it does exist.

if linux-info fails to find your kernel config in both /proc/config.gz and /usr/src/linux/.config AND IT ACTUALLY EXISTS in one of those places please file a bug on linux-info.eclass.  In the vastly more likely possibility that your system is not configured properly please ensure that your config is available via either /proc/config.gz or /usr/src/linux/.config
Comment 3 cujyaz 2013-04-07 18:03:09 UTC
http://devmanual.gentoo.org/eclass-reference/linux-info.eclass/index.html says:

| Before using any of the config-handling functions in this eclass, you must
| ensure that one of the following functions has been called (in order of
| preference), otherwise you will get bugs like #364041):
| linux-info_pkg_setup linux-info_get_any_version get_version
| get_running_version

And in fact linux_config_exists() returns false unless /proc/config.gz exists if none of these functions has been called before to set up $KV_OUT_DIR. Error handling should be done in linux-info_pkg_setup(); there's no need to do that in the ebuild.

However, the way linux-info.eclass works isn't very intuitive. Perhaps linux_config_exists should be changed to automatically set up $KV_OUT_DIR. The mentioned bug #364041 has been reintroduced in 2.20.0 just 3 weeks after it has been fixed in 2.19.0, and probably there are more ebuilds out there that just silently fail to check the kernel .config if /proc/config.gz doesn't exist.

For reference, my kernel sources are indeed at a non-standard location. I have them in /var/src and /usr/src is a symlink to /var/src (my /var is a separate partition to keep volatile files out of the root file system). But linux-info.eclass has no problems to find them if it is used as documented.
Comment 4 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-07 18:31:57 UTC
I've moved the requested command to the top of pkg_setup.  As long as it doesn't break catalyst builds it stays.  I suspect the requested change is fine but due to other current breakage in the tree I can't test this change in catalyst.

+  07 Apr 2013; Rick Farina <zerochaos@gentoo.org> powertop-2.3.ebuild,
+  powertop-9999.ebuild:
+  moving linux-info_pkg_setup in the hopes that it fixes bug 464792
Comment 5 cujyaz 2013-04-07 19:30:11 UTC
The move won't work; linux-info_pkg_setup must be called after setting of the env vars too. AIUI, the way it is supposed to work would be:

pkg_setup() {
	CONFIG_CHECK="
		~X86_MSR
		~DEBUG_FS
		~PERF_EVENTS
		~TRACEPOINTS
		~NO_HZ
		~HIGH_RES_TIMERS
		~HPET_TIMER
		~CPU_FREQ_STAT
		~CPU_FREQ_GOV_ONDEMAND
		~USB_SUSPEND
		~FTRACE
		~BLK_DEV_IO_TRACE
		~TIMER_STATS
		~EVENT_POWER_TRACING_DEPRECATED
		~TRACING
	"
	ERROR_KERNEL_X86_MSR="X86_MSR is not enabled in the kernel, you almost certainly need it"
	ERROR_KERNEL_DEBUG_FS="DEBUG_FS is not enabled in the kernel, you almost certainly need it"
	ERROR_KERNEL_PERF_EVENTS="PERF_EVENTS should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_TRACEPOINTS="TRACEPOINTS should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_NO_HZ="NO_HZ should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_HIGH_RES_TIMERS="HIGH_RES_TIMERS should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_HPET_TIMER="HPET_TIMER should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_CPU_FREQ_STAT="CPU_FREQ_STAT should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_CPU_FREQ_GOV_ONDEMAND="CPU_FREQ_GOV_ONDEMAND should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_USB_SUSPEND="USB_SUSPEND should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_FTRACE="FTRACE needs to be turned on to enable BLK_DEV_IO_TRACE"
	ERROR_KERNEL_BLK_DEV_IO_TRACE="BLK_DEV_IO_TRACE needs to be turned on to enable TIMER_STATS, TRACING and EVENT_POWER_TRACING_DEPRECATED"
	ERROR_KERNEL_TIMER_STATS="TIMER_STATS should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_EVENT_POWER_TRACING_DEPRECATED="EVENT_POWER_TRACING_DEPRECATED should be enabled in the kernel for full powertop function"
	ERROR_KERNEL_TRACING="TRACING should be enabled in the kernel for full powertop function"
	linux-info_pkg_setup
	if linux_config_exists; then
		if kernel_is -lt 3 7 0; then
			linux_chkconfig_present SND_HDA_INTEL && CONFIG_CHECK+="~SND_HDA_POWER_SAVE"
			linux_chkconfig_present SND_HDA_INTEL && ERROR_KERNEL_SND_HDA_POWER_SAVE="SND_HDA_POWER_SAVE should be enabled in the kernel for full powertop function"
		fi
	fi
}

linux-info_pkg_setup works without conditionals, but linux_chkconfig_present should only be called if linux_config_exists() is true. With the above code I get

 * Determining the location of the kernel source code
 * Found kernel source directory:
 *     /usr/src/linux
 * Found sources for kernel version:
 *     3.8.6-gentoo-v0
 * Checking for suitable kernel configuration options...                 [ ok ]

If I remove /usr/src, then linux-info.eclass outputs:

 * Determining the location of the kernel source code
 * Unable to find kernel sources at /usr/src/linux
 * Please make sure that /usr/src/linux points at your running kernel, 
 * (or the kernel you wish to build against).
 * Alternatively, set the KERNEL_DIR environment variable to the kernel sources location
 * Unable to calculate Linux Kernel version for build, attempting to use running version
 * Unable to check for the following kernel config options due
 * to absence of any configured kernel sources or compiled
 * config:
 *  - X86_MSR
 *  - DEBUG_FS
 *  - PERF_EVENTS
 *  - TRACEPOINTS
 *  - NO_HZ
 *  - HIGH_RES_TIMERS
 *  - HPET_TIMER
 *  - CPU_FREQ_STAT
 *  - CPU_FREQ_GOV_ONDEMAND
 *  - USB_SUSPEND
 *  - FTRACE
 *  - BLK_DEV_IO_TRACE
 *  - TIMER_STATS
 *  - EVENT_POWER_TRACING_DEPRECATED
 *  - TRACING
 * You're on your own to make sure they are set if needed.
Comment 6 cujyaz 2013-04-07 19:47:29 UTC
Er, the "if kernel_is -lt 3 7 0" clause still won't work. Must be something like

        if linux_config_exists; then
                if kernel_is -lt 3 7 0; then
                        if linux_chkconfig_present SND_HDA_INTEL; then
                                CONFIG_CHECK="~SND_HDA_POWER_SAVE"
                                ERROR_KERNEL_SND_HDA_POWER_SAVE="SND_HDA_POWER_SAVE should be enabled in the kernel for full powertop function"
                                check_extra_config
                        fi
                fi
        fi
Comment 7 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-07 20:04:43 UTC
how about an ebuild patch?
Comment 8 cujyaz 2013-04-07 20:20:46 UTC
Created attachment 344754 [details, diff]
Patch against powertop-2.3.ebuild rv. 1.2
Comment 9 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-08 01:44:42 UTC
        linux-info_pkg_setup
        if linux_config_exists; then
                if kernel_is -lt 3 7 0; then
                        if linux_chkconfig_present SND_HDA_INTEL; then
                                CONFIG_CHECK="~SND_HDA_POWER_SAVE"
                                ERROR_KERNEL_SND_HDA_POWER_SAVE="SND_HDA_POWER_SAVE should be enabled in the kernel for full powertop function"
                        fi
                fi
                check_extra_config
        fi


that doesn't really paste well but at any point I think the check_extra_config should happen no matter what, in your version it only happened for kernel lt 3.7.0 and snd_hda_intel is set... commiting now, please to let me know if you agree.
Comment 10 cujyaz 2013-04-08 02:39:59 UTC
check_extra_config will be called at least once because linux-info_pkg_setup calls it if CONFIG_CHECK is set. That is documented:

"and then check if the kernel is configured to support the options specified in CONFIG_CHECK (if not null)"
Comment 11 Rick Farina (Zero_Chaos) gentoo-dev 2013-04-08 03:09:14 UTC
(In reply to comment #10)
> check_extra_config will be called at least once because linux-info_pkg_setup
> calls it if CONFIG_CHECK is set. That is documented:
> 
> "and then check if the kernel is configured to support the options specified
> in CONFIG_CHECK (if not null)"

got confused between your changes and my changes, yes, you are right.

Thanks for the help, dealing with all the changes to the config checks has been like 99% of my work with powertop.