[OE-core] [PATCH] buildstats.bbclass: Don't assume /proc/<pid>/io present

Khem Raj raj.khem at gmail.com
Sat Feb 20 19:12:43 UTC 2016


Juro

On Fri, Feb 19, 2016 at 5:37 PM, Juro Bystricky
<juro.bystricky at intel.com> wrote:
> 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 <juro.bystricky at intel.com>
> ---
>  meta/classes/buildstats.bbclass | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
> index e58d37b..72a3dd9 100644
> --- a/meta/classes/buildstats.bbclass
> +++ b/meta/classes/buildstats.bbclass
> @@ -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)")
> +

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 ...."

> +        ########################################################################
> +        # at first pass make the buildstats hierarchy and then
>          # set the buildname
>          ########################################################################
>          bb.utils.mkdirhier(bsdir)
> --
> 1.9.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



More information about the Openembedded-core mailing list