[igt-dev] [PATCH i-g-t] runner: Only show the kmsg underflow/overflow message once

Petri Latvala petri.latvala at intel.com
Wed Mar 25 12:52:53 UTC 2020


On Wed, Mar 25, 2020 at 12:33:18PM +0000, Chris Wilson wrote:
> Instead of repeating every single time we underflow the read from kmsg,
> just once per test is enough warning.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Petri Latvala <petri.latvala at intel.com>
> ---
>  runner/executor.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/runner/executor.c b/runner/executor.c
> index a56cb5d66..b26cb7bc7 100644
> --- a/runner/executor.c
> +++ b/runner/executor.c
> @@ -549,6 +549,8 @@ static int dump_dmesg(int kmsgfd, int outfd)
>  	int comparefd;
>  	unsigned flags;
>  	unsigned long long seq, cmpseq, usec;
> +	bool underflow_once = false;
> +	bool overflow_once = false;
>  	char cont;
>  	char buf[2048];
>  	ssize_t r;
> @@ -586,10 +588,16 @@ static int dump_dmesg(int kmsgfd, int outfd)
>  		r = read(kmsgfd, buf, sizeof(buf));
>  		if (r < 0) {
>  			if (errno == EPIPE) {
> -				errf("Warning: kernel log ringbuffer underflow, some records lost.\n");
> +				if (!overflow_once) {
> +					errf("Warning: kernel log ringbuffer underflow, some records lost.\n");
> +					overflow_once = true;
> +				}

if (!overflow_once)
Warning: underflow


And then


if (!underflow_once)
Warning: overflow




>  				continue;
>  			} else if (errno == EINVAL) {
> -				errf("Warning: Buffer too small for kernel log record, record lost.\n");
> +				if (!underflow_once) {
> +					errf("Warning: Buffer too small for kernel log record, record lost.\n");
> +					underflow_once = true;
> +				}

I'd just not bother with once-proofing this case here. If it happens,
we will fix it by increasing buf to 4k from 2k.

For those in the audience, EINVAL happens when the next single kernel
log record is larger than the read() buffer. Whereas EPIPE is about
the number of log records that are unread.


tl;dr: Just once-proof the EPIPE-underflow and call it underflow_once.

Next order of business is hooking that underflow to cause dmesg-warn.


-- 
Petri Latvala


More information about the igt-dev mailing list