Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, igt-dev@lists.freedesktop.org,
	Isabella Basso <isabbasso@riseup.net>,
	intel-xe@lists.freedesktop.org
Subject: Re: [igt-dev] [Intel-gfx] [PATCH i-g-t v2 12/17] lib/ktap: Use IGT linked lists for storing KTAP results
Date: Fri, 15 Sep 2023 12:44:36 +0200	[thread overview]
Message-ID: <20230915124436.08bc29db@maurocar-mobl2> (raw)
In-Reply-To: <20230908123233.137134-31-janusz.krzysztofik@linux.intel.com>

On Fri,  8 Sep 2023 14:32:46 +0200
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> wrote:

> For code simplicity and clarity, use existing IGT linked lists library
> instead of open coding a custom implementation of a list of KTAP results.
> 
> While being at it, flatten the code by inverting a check for pending
> results.

LGTM.

Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> ---
>  lib/igt_kmod.c | 28 ++++++++++++++++------------
>  lib/igt_ktap.c | 25 +++++--------------------
>  lib/igt_ktap.h |  6 ++++--
>  3 files changed, 25 insertions(+), 34 deletions(-)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 988ac164cb..c692954911 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -760,7 +760,6 @@ static void __igt_kunit(struct igt_ktest *tst, const char *opts)
>  	struct kmod_module *kunit_kmod;
>  	bool is_builtin;
>  	struct ktap_test_results *results;
> -	struct ktap_test_results_element *temp;
>  	unsigned long taints;
>  	int flags, ret;
>  
> @@ -784,28 +783,33 @@ static void __igt_kunit(struct igt_ktest *tst, const char *opts)
>  		igt_skip("Unable to load %s module\n", tst->module_name);
>  	}
>  
> -	while (READ_ONCE(results->still_running) || READ_ONCE(results->head) != NULL)
> +	while (READ_ONCE(results->still_running) || !igt_list_empty(&results->list))
>  	{
> +		struct ktap_test_results_element *result;
> +
>  		if (igt_kernel_tainted(&taints)) {
>  			ktap_parser_cancel();
>  			break;
>  		}
>  
> -		if (READ_ONCE(results->head) != NULL) {
> -			pthread_mutex_lock(&results->mutex);
> +		pthread_mutex_lock(&results->mutex);
> +		if (igt_list_empty(&results->list)) {
> +			pthread_mutex_unlock(&results->mutex);
> +			continue;
> +		}
>  
> -			igt_dynamic(results->head->test_name) {
> -				igt_assert(READ_ONCE(results->head->passed));
> +		result = igt_list_first_entry(&results->list, result, link);
>  
> -				igt_fail_on(igt_kernel_tainted(&taints));
> -			}
> +		igt_list_del(&result->link);
> +		pthread_mutex_unlock(&results->mutex);
>  
> -			temp = results->head;
> -			results->head = results->head->next;
> -			free(temp);
> +		igt_dynamic(result->test_name) {
> +			igt_assert(READ_ONCE(result->passed));
>  
> -			pthread_mutex_unlock(&results->mutex);
> +			igt_fail_on(igt_kernel_tainted(&taints));
>  		}
> +
> +		free(result);
>  	}
>  
>  	ret = ktap_parser_stop();
> diff --git a/lib/igt_ktap.c b/lib/igt_ktap.c
> index 165f6b2cce..5e9967f980 100644
> --- a/lib/igt_ktap.c
> +++ b/lib/igt_ktap.c
> @@ -12,6 +12,7 @@
>  #include "igt_aux.h"
>  #include "igt_core.h"
>  #include "igt_ktap.h"
> +#include "igt_list.h"
>  
>  #define DELIMITER "-"
>  
> @@ -335,7 +336,7 @@ static int parse_tap_level(int fd, char *base_test_name, int test_count, bool *f
>  			   bool *found_tests, bool is_builtin)
>  {
>  	char record[BUF_LEN + 1];
> -	struct ktap_test_results_element *r, *temp;
> +	struct ktap_test_results_element *r;
>  	int internal_test_count;
>  	char test_name[BUF_LEN + 1];
>  	char base_test_name_for_next_level[BUF_LEN + 1];
> @@ -403,17 +404,9 @@ static int parse_tap_level(int fd, char *base_test_name, int test_count, bool *f
>  			r->test_name[BUF_LEN] = '\0';
>  
>  			r->passed = false;
> -			r->next = NULL;
>  
>  			pthread_mutex_lock(&results.mutex);
> -			if (results.head == NULL) {
> -				results.head = r;
> -			} else {
> -				temp = results.head;
> -				while (temp->next != NULL)
> -					temp = temp->next;
> -				temp->next = r;
> -			}
> +			igt_list_add_tail(&r->link, &results.list);
>  			pthread_mutex_unlock(&results.mutex);
>  
>  			test_name[0] = '\0';
> @@ -431,17 +424,9 @@ static int parse_tap_level(int fd, char *base_test_name, int test_count, bool *f
>  			r->test_name[BUF_LEN] = '\0';
>  
>  			r->passed = true;
> -			r->next = NULL;
>  
>  			pthread_mutex_lock(&results.mutex);
> -			if (results.head == NULL) {
> -				results.head = r;
> -			} else {
> -				temp = results.head;
> -				while (temp->next != NULL)
> -					temp = temp->next;
> -				temp->next = r;
> -			}
> +			igt_list_add_tail(&r->link, &results.list);
>  			pthread_mutex_unlock(&results.mutex);
>  
>  			test_name[0] = '\0';
> @@ -523,7 +508,7 @@ static pthread_t ktap_parser_thread;
>  
>  struct ktap_test_results *ktap_parser_start(int fd, bool is_builtin)
>  {
> -	results.head = NULL;
> +	IGT_INIT_LIST_HEAD(&results.list);
>  	pthread_mutex_init(&results.mutex, NULL);
>  	results.still_running = true;
>  
> diff --git a/lib/igt_ktap.h b/lib/igt_ktap.h
> index 991800e912..b4d7a6dbc7 100644
> --- a/lib/igt_ktap.h
> +++ b/lib/igt_ktap.h
> @@ -28,16 +28,18 @@
>  
>  #include <pthread.h>
>  
> +#include "igt_list.h"
> +
>  void *igt_ktap_parser(void *unused);
>  
>  typedef struct ktap_test_results_element {
>  	char test_name[BUF_LEN + 1];
>  	bool passed;
> -	struct ktap_test_results_element *next;
> +	struct igt_list_head link;
>  } ktap_test_results_element;
>  
>  struct ktap_test_results {
> -	ktap_test_results_element *head;
> +	struct igt_list_head list;
>  	pthread_mutex_t mutex;
>  	bool still_running;
>  };

  reply	other threads:[~2023-09-15 10:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 12:32 [igt-dev] [PATCH i-g-t v2 00/17] Fix IGT Kunit implementation issues Janusz Krzysztofik
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 01/17] lib/kunit: Drop unused file stream Janusz Krzysztofik
2023-09-15 10:36   ` Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 02/17] lib/kunit: Stop loading kunit module explicitly Janusz Krzysztofik
2023-09-15 10:36   ` Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 03/17] lib/kunit: Fix struct kmod_module kunit_kmod not freed Janusz Krzysztofik
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 04/17] lib/kunit: Optimize calls to igt_success/skip/fail() Janusz Krzysztofik
2023-09-11  8:49   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 05/17] lib/kunit: Fix illegal igt_fail() calls inside subtest body Janusz Krzysztofik
2023-09-11  8:52   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-11  9:28     ` Janusz Krzysztofik
2023-09-11 11:57       ` Mauro Carvalho Chehab
2023-09-13 13:03         ` Janusz Krzysztofik
2023-09-15  9:58     ` Mauro Carvalho Chehab
2023-09-15 10:08       ` Janusz Krzysztofik
2023-09-15 12:13         ` Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 06/17] lib/ktap: Make sure we fail on premature cancel Janusz Krzysztofik
2023-09-11  8:55   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 07/17] lib/ktap: Don't ignore interrupt signals Janusz Krzysztofik
2023-09-11  9:01   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-13 14:04     ` Janusz Krzysztofik
2023-09-15 12:25       ` Mauro Carvalho Chehab
2023-09-15 13:06         ` Janusz Krzysztofik
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 08/17] lib/kunit: Cancel KTP parser on module load failure Janusz Krzysztofik
2023-09-11  9:02   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 09/17] lib/ktap: Drop is_running flag Janusz Krzysztofik
2023-09-11  9:03   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 10/17] lib/ktap: Read /dev/kmsg in blocking mode Janusz Krzysztofik
2023-09-15 10:42   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 11/17] lib/kunit: Fail / skip on kernel taint Janusz Krzysztofik
2023-09-15 10:43   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 12/17] lib/ktap: Use IGT linked lists for storing KTAP results Janusz Krzysztofik
2023-09-15 10:44   ` Mauro Carvalho Chehab [this message]
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 13/17] lib/ktap: Reimplement KTAP parser Janusz Krzysztofik
2023-09-15 11:45   ` Mauro Carvalho Chehab
2023-09-15 12:28   ` [igt-dev] [Intel-gfx] " Mauro Carvalho Chehab
2023-09-15 13:09     ` Janusz Krzysztofik
2023-09-15 13:35       ` [Intel-xe] " Janusz Krzysztofik
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 14/17] lib/kunit: Load test modules in background Janusz Krzysztofik
2023-09-15 12:11   ` Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 15/17] lib/kunit: Parse KTAP report from the main process thread Janusz Krzysztofik
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 16/17] lib/kunit: Strip "_test" or "_kunit" suffix from subtest names Janusz Krzysztofik
2023-09-15 11:42   ` Mauro Carvalho Chehab
2023-09-08 12:32 ` [igt-dev] [PATCH i-g-t v2 17/17] lib/kunit: Omit suite name prefix if the same as subtest name Janusz Krzysztofik
2023-09-08 14:08 ` [igt-dev] ✗ GitLab.Pipeline: warning for Fix IGT Kunit implementation issues (rev2) Patchwork
2023-09-08 14:46 ` [igt-dev] ✗ Fi.CI.BAT: failure " Patchwork
2023-09-08 15:51 ` [igt-dev] ✓ CI.xeBAT: success " Patchwork
2023-09-11 12:26 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2023-09-11 14:57 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230915124436.08bc29db@maurocar-mobl2 \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=isabbasso@riseup.net \
    --cc=janusz.krzysztofik@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox