Don't assume /proc/<pid>/io present
cover Don't assume /proc/<pid>/io present
Latest enhancements to collect task statistics in the file buildstats.bbclass also collect task I/O statistics using procfs interface. However, it is not guaranteed the I/O counters are actually present. This depends on how the kernel was configured. If the kernel was configured without CONFIG_TASK_IO_ACCOUNTING=y, the corresponding procfs entries are missing. This has been in fact observed in the wild (Build Appliance).
If we try to read the non-existent counters, we will basically hang bitbake. The attached patch file checks for missing procfs entries and avoids reading them if not present.
Bitbake will also issue a one-time warning message at the start of a build.
Juro Bystricky (1):
buildstats.bbclass: Don't assume /proc/<pid>/io present
meta/classes/buildstats.bbclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/1 buildstats.bbclass: Don't assume /proc/<pid>/io present
It is not guaranteed Linux kernel was configured with process I/O statistics enabled. If process I/O statistcs are not present, issue a one time warning and do not attempt to read the non-existing stats counters.
[YOCTO#9025]
--- meta/classes/buildstats.bbclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
meta/classes/buildstats.bbclass +16 -8
@@ -25,13 +25,14 @@ def get_process_cputime(pid): 'cstime' : fields[16], } iostats = {} - with open("/proc/%d/io" % pid, "r") as f: - while True: - i = f.readline().strip() - if not i: - break - i = i.split(": ") - iostats[i[0]] = i[1] + if os.path.isfile("/proc/%d/io" % pid): + with open("/proc/%d/io" % pid, "r") as f: + while True: + i = f.readline().strip() + if not i: + break + i = i.split(": ") + iostats[i[0]] = i[1] resources = resource.getrusage(resource.RUSAGE_SELF) childres = resource.getrusage(resource.RUSAGE_CHILDREN) return stats, iostats, resources, childres
@@ -111,7 +112,14 @@ python run_buildstats () { if isinstance(e, bb.event.BuildStarted): ######################################################################## - # at first pass make the buildstats heriarchy and then + # If the kernel was not configured to provide I/O statistics, issue + # a one time warning. + ######################################################################## + if not os.path.isfile("/proc/%d/io" % os.getpid()): + bb.warn("The Linux kernel was not configured to provide process I/O statistics. (CONFIG_TASK_IO_ACCOUNTING is not set)") + + ######################################################################## + # at first pass make the buildstats hierarchy and then # set the buildname ######################################################################## bb.utils.mkdirhier(bsdir)
Signature · 1 line
1.9.1
Re: [PATCH] buildstats.bbclass: Don't assume /proc/<pid>/io present
Juro
Quoted 39 lines · Juro Bystricky
It is not guaranteed Linux kernel was configured with process I/O statistics enabled. If process I/O statistcs are not present, issue a one time warning and do not attempt to read the non-existing stats counters.
[YOCTO#9025]
Signed-off-by Juro Bystricky <[email protected]>--- meta/classes/buildstats.bbclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)meta/classes/buildstats.bbclass +8
-7@@ -25,13 +25,14 @@ def get_process_cputime(pid): 'cstime' : fields[16], } iostats = {} - with open("/proc/%d/io" % pid, "r") as f: - while True: - i = f.readline().strip() - if not i: - break - i = i.split(": ") - iostats[i[0]] = i[1] + if os.path.isfile("/proc/%d/io" % pid): + with open("/proc/%d/io" % pid, "r") as f: + while True: + i = f.readline().strip() + if not i: + break + i = i.split(": ") + iostats[i[0]] = i[1] resources = resource.getrusage(resource.RUSAGE_SELF) childres = resource.getrusage(resource.RUSAGE_CHILDREN) return stats, iostats, resources, childres
meta/classes/buildstats.bbclass python run_buildstats () { · line 120
Quoted 10 lines
meta/classes/buildstats.bbclass +6
-1@@ -111,7 +112,14 @@ python run_buildstats () { if isinstance(e, bb.event.BuildStarted): ######################################################################## - # at first pass make the buildstats heriarchy and then + # If the kernel was not configured to provide I/O statistics, issue + # a one time warning. + ######################################################################## + if not os.path.isfile("/proc/%d/io" % os.getpid()): + bb.warn("The Linux kernel was not configured to provide process I/O statistics. (CONFIG_TASK_IO_ACCOUNTING is not set)") +
It would be nicer if we also clarified its not the kernel that they will build but the kernel on their build host. So something like 'Linux kernel on your build host ...."
Quoted 13 lines
meta/classes/buildstats.bbclass +2
-1+ ######################################################################## + # at first pass make the buildstats hierarchy and then # set the buildname ######################################################################## bb.utils.mkdirhier(bsdir) --1.9.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH] buildstats.bbclass: Don't assume /proc/<pid>/io present
I agree, the message can be confusing, as there can be some ambiguity as to which kernel was implied by the warning.
Right now it says:
WARNING: The Linux kernel was not configured to provide ....
As you suggested, I will change it to:
WARNING: The Linux kernel on your build host was not configured to provide...
Thanks
Juro
Quoted 88 lines
-----Original Message-----
From: Khem Raj [mailto:[email protected]]
Sent: Saturday, February 20, 2016 11:13 AM
To: Bystricky, Juro <[email protected]>
Cc: Patches and discussions about the oe-core layer <openembedded- [email protected]>; Juro Bystricky <[email protected]>
Subject: Re: [OE-core] [PATCH] buildstats.bbclass: Don't assume /proc/<pid>/io presentJuro
Quoted 40 lines · Juro Bystricky
It is not guaranteed Linux kernel was configured with process I/O statistics enabled. If process I/O statistcs are not present, issue a one time warning and do not attempt to read the non-existing stats counters.
[YOCTO#9025]
Signed-off-by Juro Bystricky <[email protected]>--- meta/classes/buildstats.bbclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)(quoted diff) +0
-0b/meta/classes/buildstats.bbclass index e58d37b..72a3dd9 100644
meta/classes/buildstats.bbclass +8
-7@@ -25,13 +25,14 @@ def get_process_cputime(pid): 'cstime' : fields[16], } iostats = {} - with open("/proc/%d/io" % pid, "r") as f: - while True: - i = f.readline().strip() - if not i: - break - i = i.split(": ") - iostats[i[0]] = i[1] + if os.path.isfile("/proc/%d/io" % pid): + with open("/proc/%d/io" % pid, "r") as f: + while True: + i = f.readline().strip() + if not i: + break + i = i.split(": ") + iostats[i[0]] = i[1] resources = resource.getrusage(resource.RUSAGE_SELF) childres = resource.getrusage(resource.RUSAGE_CHILDREN) return stats, iostats, resources, childres @@ -111,7 +112,14 @@python
run_buildstats() {Quoted 2 lines
if
isinstance(e, bb.event.BuildStarted):#################################################################
#######meta/classes/buildstats.bbclass python run_buildstats () { · line 120
Quoted 4 lines
meta/classes/buildstats.bbclass +3
-1- # at first pass make the buildstats heriarchy and then + # If the kernel was not configured to provide I/O statistics, issue + # a one time warning. +#################################################################
#######meta/classes/buildstats.bbclass python run_buildstats () { · line 120
Quoted 4 lines
meta/classes/buildstats.bbclass +4
-0+ if not os.path.isfile("/proc/%d/io" % os.getpid()): + bb.warn("The Linux kernel was not configured to provide + process I/O statistics. (CONFIG_TASK_IO_ACCOUNTING is not set)") +It would be nicer if we also clarified its not the kernel that they will build but the kernel on their build host. So something like 'Linux kernel on your build host ...."
Quoted 1 line
+
#################################################################
#######Quoted 3 lines
+ # at first pass make the buildstats hierarchy and then
# set the buildname#################################################################
#######Quoted 9 lines
bb.utils.mkdirhier(bsdir)
--
1.9.1--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core