Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 608804

Summary: dev-util/cmake waits forever for sysclt to finish on kernel >= 4.9.9
Product: Gentoo Linux Reporter: John Wrist <chris.andersonc>
Component: Current packagesAssignee: Gentoo KDE team <kde>
Status: RESOLVED NEEDINFO    
Severity: normal CC: chris.andersonc, polynomial-c
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: CMakeLists.txt
ProcessorCountTest.cmake

Description John Wrist 2017-02-09 23:02:03 UTC
In /usr/share/cmake/Modules/ProcessorCount.cmake cmake checks for the number of processors using sysctl -n hw.ncpu

This is done in the line:
  execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu

In kernel 4.9.9 the /proc/sys/hw/ncpu is missing and sysctl just stays there forever.

As a work around, I changed the line to read 
      execute_process(COMMAND echo 48
as I have 48 cpus and I can continue doing work.
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2017-02-10 09:18:51 UTC
Can you tell which package failed for you because of this?

Also, I just added cmake-3.8.0_rc1 to the tree but without any KEYWORDS. Can you perhaps test if this is still an issue with cmake-3.8?
Comment 2 Michael Palimaka (kensington) gentoo-dev 2017-02-12 01:41:52 UTC
Are you certain that it's sysctl -n hw.ncpu that's hanging?

With kernel-4.7.10, cmake-3.7.2 and procps-3.3.12 I have the sysctl failure:

# sysctl -n hw.ncpu
sysctl: cannot stat /proc/sys/hw/ncpu: No such file or directory

but cmake is successfully able to still continue (I guess with getconf _NPROCESSORS_ONLN).
Comment 3 Michael Palimaka (kensington) gentoo-dev 2017-02-12 01:42:44 UTC
Created attachment 463386 [details]
CMakeLists.txt

Test case to see how far cmake is getting.
Comment 4 Michael Palimaka (kensington) gentoo-dev 2017-02-12 01:43:08 UTC
Created attachment 463388 [details]
ProcessorCountTest.cmake

Module for testcase.
Comment 5 John Wrist 2017-02-12 06:47:43 UTC
No, I don't know which package is affected.
No, I don't know if it is the kernel version.

But, before going home Thursday, I setup a build of the kernel to 4.9.9 and did the upgrade then poweroff. 

In the morning of Friday, I came to work, tried to open a project that I had been working on the previous day and Qt Creator would just sit there with the spinning circle. So I ran cmake manually and it would just stall completely. I ran strace and then found a coredump on the sysctl and discovered that the proc/sys/vm/ncpus was missing. I then fired up a fedora 25 VM with kernel 4.8 (I think) and found that this did exist there). I removed the line and was able to do work.

I then decided to add the bug in case someone else had the same problem. I now realize that this was a mistake, and I apologize. I cannot tell you how sorry that I am, as I totally forgot that gentoo is all about the build system and nothing about the operating system.
Comment 6 Michael Palimaka (kensington) gentoo-dev 2017-02-12 07:02:09 UTC
There's no problem with this bug at all, I was just trying to narrow down further exactly what component could be causing it.

Since your investigation seems to point to sysctl hanging (which as far as I know it should not), I suspect this is a problem in sys-process/procps.

Are you able to add your emerge --info and procps version? Then we can ping the base-system team if they have some idea why this might happen.