[igt-dev] [PATCH i-g-t 1/2] lib: Process kernel taints
Petri Latvala
petri.latvala at intel.com
Fri Jan 8 12:26:46 UTC 2021
On Thu, Jan 07, 2021 at 10:43:27AM +0000, Chris Wilson wrote:
> A small library routine to read '/proc/sys/kernel/taints' and check for
> a fatal condition. This is currently used by the runner, but is also
> useful for some tests.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> lib/Makefile.sources | 2 ++
> lib/igt_taints.c | 65 +++++++++++++++++++++++++++++++++++++++
> lib/igt_taints.h | 19 ++++++++++++
> lib/meson.build | 1 +
> runner/executor.c | 73 +++++++++-----------------------------------
> 5 files changed, 101 insertions(+), 59 deletions(-)
> create mode 100644 lib/igt_taints.c
> create mode 100644 lib/igt_taints.h
>
> diff --git a/lib/Makefile.sources b/lib/Makefile.sources
> index 67b386457..7102f95e7 100644
> --- a/lib/Makefile.sources
> +++ b/lib/Makefile.sources
> @@ -64,6 +64,8 @@ lib_source_list = \
> igt_sysfs.h \
> igt_sysrq.c \
> igt_sysrq.h \
> + igt_taints.c \
> + igt_taints.h \
> igt_thread.c \
> igt_thread.h \
> igt_x86.h \
> diff --git a/lib/igt_taints.c b/lib/igt_taints.c
> new file mode 100644
> index 000000000..f9b32d106
> --- /dev/null
> +++ b/lib/igt_taints.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2021 Intel Corporation
> + */
> +
> +#include <stdio.h>
> +
> +#include "igt_taints.h"
> +
> +/* see Linux's include/linux/kernel.h */
> +static const struct {
> + int bit;
> + int bad;
> + const char *explanation;
> +} abort_taints[] = {
> + { 5, 1, "TAINT_BAD_PAGE: Bad page reference or an unexpected page flags." },
> + { 7, 1, "TAINT_DIE: Kernel has died - BUG/OOPS." },
> + { 9, 1, "TAINT_WARN: WARN_ON has happened." },
> + { -1 }
> +};
> +
> +const char *igt_explain_taints(unsigned long *taints)
> +{
> + for (typeof(*abort_taints) *taint = abort_taints;
> + taint->bit >= 0;
> + taint++) {
> + if (*taints & (1ul << taint->bit)) {
> + *taints &= ~(1ul << taint->bit);
> + return taint->explanation;
> + }
> + }
> +
> + return NULL;
> +}
Docs for these functions are now in order now that they found a place
in lib/. Especially this function with the required "call until funny"
semantics.
--
Petri Latvala
More information about the igt-dev
mailing list