summaryrefslogtreecommitdiffstats
path: root/meta/classes/buildstats.bbclass
diff options
context:
space:
mode:
authorElizabeth Flanagan <elizabeth.flanagan@intel.com>2011-11-01 16:08:50 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-07 14:05:37 +0000
commit8f78cf20303c6c9bedab64bad1c88cca29f5135b (patch)
tree55222da27d3aa25c227aa1244ba5c4c96e4f15fe /meta/classes/buildstats.bbclass
parent953b45841fdcb90080cc72a98ddd14551f85e103 (diff)
downloadpoky-8f78cf20303c6c9bedab64bad1c88cca29f5135b.tar.gz
buildstats: Fix for buildstats on tmpfs
tmpfs/encryptfs/(and most likely, but not confirmed)ramfs TMPDIRs cause diskstats to choke. No device entry ends up in /proc/diskstats for these fs types, which ends up causing the failure. The short term solution is to exclude these fs types from diskstat collection. Longer term we will want to see if we can collect meaningful diskio for each of these, and other, use cases, but for this cleans up Bug 1700. [YOCTO #1700] (From OE-Core rev: 2b14046c12855b6f484ba5bd6bc0a8022de6873e) Signed-off-by: Elizabeth Flanagan <elizabeth.flanagan@intel.com> Corrected YOCTO bug location and format Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/buildstats.bbclass')
-rw-r--r--meta/classes/buildstats.bbclass37
1 files changed, 26 insertions, 11 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 55cbb3cee3..96c98d409f 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -48,13 +48,24 @@ def set_device(e):
48 # something like stick DL_DIR on a different partition and this would 48 # something like stick DL_DIR on a different partition and this would
49 # throw stats gathering off. The same goes with SSTATE_DIR. However, let's 49 # throw stats gathering off. The same goes with SSTATE_DIR. However, let's
50 # get the basics in here and work on the cornercases later. 50 # get the basics in here and work on the cornercases later.
51 # A note. /proc/diskstats does not contain info on encryptfs, tmpfs, etc.
52 # If we end up hitting one of these fs, we'll just skip diskstats collection.
51 ############################################################################ 53 ############################################################################
52 device=os.stat(tmpdir) 54 device=os.stat(tmpdir)
53 majordev=os.major(device.st_dev) 55 majordev=os.major(device.st_dev)
54 minordev=os.minor(device.st_dev) 56 minordev=os.minor(device.st_dev)
57 ############################################################################
58 # Bug 1700:
59 # Because tmpfs/encryptfs/ramfs etc inserts no entry in /proc/diskstats
60 # we set rdev to NoLogicalDevice and search for it later. If we find NLD
61 # we do not collect diskstats as the method to collect meaningful statistics
62 # for these fs types requires a bit more research.
63 ############################################################################
55 for line in open("/proc/diskstats", "r"): 64 for line in open("/proc/diskstats", "r"):
56 if majordev == int(line.split()[0]) and minordev == int(line.split()[1]): 65 if majordev == int(line.split()[0]) and minordev == int(line.split()[1]):
57 rdev=line.split()[2] 66 rdev=line.split()[2]
67 else:
68 rdev="NoLogicalDevice"
58 file = open(bb.data.getVar('DEVFILE', e.data, True), "w") 69 file = open(bb.data.getVar('DEVFILE', e.data, True), "w")
59 file.write(rdev) 70 file.write(rdev)
60 file.close() 71 file.close()
@@ -133,10 +144,11 @@ def write_task_data(status, logfile, dev, e):
133 # For the best information, running things with BB_TOTAL_THREADS = "1" 144 # For the best information, running things with BB_TOTAL_THREADS = "1"
134 # would return accurate per task results. 145 # would return accurate per task results.
135 ############################################################################ 146 ############################################################################
136 diskdata = get_diskdata("__diskdata_task", dev, e.data) 147 if dev != "NoLogicalDevice":
137 if diskdata: 148 diskdata = get_diskdata("__diskdata_task", dev, e.data)
138 for key in sorted(diskdata.iterkeys()): 149 if diskdata:
139 file.write(key + ": " + diskdata[key] + "\n") 150 for key in sorted(diskdata.iterkeys()):
151 file.write(key + ": " + diskdata[key] + "\n")
140 if status is "passed": 152 if status is "passed":
141 file.write("Status: PASSED \n") 153 file.write("Status: PASSED \n")
142 else: 154 else:
@@ -169,7 +181,8 @@ python run_buildstats () {
169 bb.mkdirhier(bsdir) 181 bb.mkdirhier(bsdir)
170 except: 182 except:
171 pass 183 pass
172 set_diskdata("__diskdata_build", device, e.data) 184 if device != "NoLogicalDevice":
185 set_diskdata("__diskdata_build", device, e.data)
173 set_timedata("__timedata_build", e.data) 186 set_timedata("__timedata_build", e.data)
174 build_time = os.path.join(bsdir, "build_stats") 187 build_time = os.path.join(bsdir, "build_stats")
175 # write start of build into build_time 188 # write start of build into build_time
@@ -185,7 +198,7 @@ python run_buildstats () {
185 198
186 elif isinstance(e, bb.event.BuildCompleted): 199 elif isinstance(e, bb.event.BuildCompleted):
187 bn = get_bn(e) 200 bn = get_bn(e)
188 dev = get_device(e) 201 device = get_device(e)
189 bsdir = os.path.join(bb.data.getVar('BUILDSTATS_BASE', e.data, True), bn) 202 bsdir = os.path.join(bb.data.getVar('BUILDSTATS_BASE', e.data, True), bn)
190 taskdir = os.path.join(bsdir, bb.data.expand("${PF}", e.data)) 203 taskdir = os.path.join(bsdir, bb.data.expand("${PF}", e.data))
191 build_time = os.path.join(bsdir, "build_stats") 204 build_time = os.path.join(bsdir, "build_stats")
@@ -201,10 +214,11 @@ python run_buildstats () {
201 file.write("Elapsed time: %0.2f seconds \n" % (time)) 214 file.write("Elapsed time: %0.2f seconds \n" % (time))
202 if cpu: 215 if cpu:
203 file.write("CPU usage: %0.1f%% \n" % cpu) 216 file.write("CPU usage: %0.1f%% \n" % cpu)
204 diskio = get_diskdata("__diskdata_build", dev, e.data) 217 if device != "NoLogicalDevice":
205 if diskio: 218 diskio = get_diskdata("__diskdata_build", device, e.data)
206 for key in sorted(diskio.iterkeys()): 219 if diskio:
207 file.write(key + ": " + diskio[key] + "\n") 220 for key in sorted(diskio.iterkeys()):
221 file.write(key + ": " + diskio[key] + "\n")
208 file.close() 222 file.close()
209 223
210 if isinstance(e, bb.build.TaskStarted): 224 if isinstance(e, bb.build.TaskStarted):
@@ -212,7 +226,8 @@ python run_buildstats () {
212 device = get_device(e) 226 device = get_device(e)
213 bsdir = os.path.join(bb.data.getVar('BUILDSTATS_BASE', e.data, True), bn) 227 bsdir = os.path.join(bb.data.getVar('BUILDSTATS_BASE', e.data, True), bn)
214 taskdir = os.path.join(bsdir, bb.data.expand("${PF}", e.data)) 228 taskdir = os.path.join(bsdir, bb.data.expand("${PF}", e.data))
215 set_diskdata("__diskdata_task", device, e.data) 229 if device != "NoLogicalDevice":
230 set_diskdata("__diskdata_task", device, e.data)
216 set_timedata("__timedata_task", e.data) 231 set_timedata("__timedata_task", e.data)
217 try: 232 try:
218 bb.mkdirhier(taskdir) 233 bb.mkdirhier(taskdir)