public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/igt_kmod: Allow some leeway in igt_kmod_unload_r
@ 2023-01-09 19:25 Jonathan Cavitt
  2023-01-09 19:33 ` Cavitt, Jonathan
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Jonathan Cavitt @ 2023-01-09 19:25 UTC (permalink / raw)
  To: igt-dev; +Cc: jonathan.cavitt

kmod_module_remove_module occasionally returns EAGAIN for mei_gsc
in the setup of some gem_lmem_swapping subtests.  Just because
EAGAIN is returned doesn't mean the module is lost and unable to
be unloaded.  Try again some number of times (currently 10) before
giving up.

Retries will occur for -EBUSY and -EAGAIN, as these imply the
system is waiting for the target module can simply be waited for.
All other errors exit immediately, but as the context for each
error informs their relative severity, no warnings will be issued.

References: VLK-30287, VLK-39629

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Stuart Summers <stuart.summers@intel.com>
CC: Sandeep Kumar Parupalli <sandeep.kumar.parupalli@intel.com>
CC: Chris Wilson <chris.p.wilson@linux.intel.com>
Reviewed-by: Chris Wilson <chris.p.wilson@linux.intel.com>
---
 lib/igt_kmod.c | 41 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 17090110c..c840f9a17 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -253,8 +253,11 @@ out:
 
 static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 {
+#define MAX_TRIES	20
+#define SLEEP_DURATION	500000
 	struct kmod_list *holders, *pos;
-	int err = 0;
+	int err, tries;
+	const char *mod_name = kmod_module_get_name(kmod);
 
 	holders = kmod_module_get_holders(kmod);
 	kmod_list_foreach(pos, holders) {
@@ -269,7 +272,6 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		return err;
 
 	if (igt_kmod_is_loading(kmod)) {
-		const char *mod_name = kmod_module_get_name(kmod);
 		igt_debug("%s still initializing\n", mod_name);
 		err = igt_wait(!igt_kmod_is_loading(kmod), 10000, 100);
 		if (err < 0) {
@@ -279,7 +281,40 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		}
 	}
 
-	return kmod_module_remove_module(kmod, flags);
+	for (tries = 0; tries < MAX_TRIES; tries++) {
+		bool loop = false;
+
+		err = kmod_module_remove_module(kmod, flags);
+
+		/* Only loop in the following cases */
+		switch (err) {
+		case -EBUSY:
+		case -EAGAIN:
+			/* Waiting for module to be available */
+			loop = true;
+			break;
+		default:
+			break;
+                }
+		if (!loop)
+			break;
+
+		igt_debug("Module %s failed to unload with err: %d on attempt: %i\n",
+			  mod_name, err, tries + 1);
+
+		usleep(SLEEP_DURATION);
+	}
+
+	if (err == -ENOENT)
+		igt_debug("Module %s could not be found.  Skipping.\n", mod_name);
+	else if (err)
+		igt_info("Module %s failed to unload with err: %d after ~%.1fms\n",
+			 mod_name, err, SLEEP_DURATION*tries/1000.);
+	else if (tries)
+		igt_info("Module %s unload took ~%.1fms over %i attempts\n",
+			 mod_name, SLEEP_DURATION*tries/1000., tries + 1);
+
+	return err;
 }
 
 /**
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [igt-dev] [PATCH i-g-t] lib/igt_kmod: Allow some leeway in igt_kmod_unload_r
@ 2023-01-17 18:03 Jonathan Cavitt
  2023-01-18 13:10 ` Kamil Konieczny
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cavitt @ 2023-01-17 18:03 UTC (permalink / raw)
  To: igt-dev; +Cc: chris.p.wilson, jonathan.cavitt, sandeep.kumar.parupalli

kmod_module_remove_module occasionally returns EAGAIN for mei_gsc
in the setup of some gem_lmem_swapping subtests.  Just because
EAGAIN is returned doesn't mean the module is lost and unable to
be unloaded.  Try again some number of times (currently 10) before
giving up.

Retries will occur for -EBUSY and -EAGAIN, as these imply the
system is waiting for the target module can simply be waited for.
All other errors exit immediately, but as the context for each
error informs their relative severity, no warnings will be issued.

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Stuart Summers <stuart.summers@intel.com>
CC: Sandeep Kumar Parupalli <sandeep.kumar.parupalli@intel.com>
CC: Chris Wilson <chris.p.wilson@linux.intel.com>
Reviewed-by: Chris Wilson <chris.p.wilson@linux.intel.com>
---
 lib/igt_kmod.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 17090110c..10c79b740 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -253,8 +253,11 @@ out:
 
 static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 {
+#define MAX_TRIES	20
+#define SLEEP_DURATION	500000
 	struct kmod_list *holders, *pos;
-	int err = 0;
+	int err, tries;
+	const char *mod_name = kmod_module_get_name(kmod);
 
 	holders = kmod_module_get_holders(kmod);
 	kmod_list_foreach(pos, holders) {
@@ -269,7 +272,6 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		return err;
 
 	if (igt_kmod_is_loading(kmod)) {
-		const char *mod_name = kmod_module_get_name(kmod);
 		igt_debug("%s still initializing\n", mod_name);
 		err = igt_wait(!igt_kmod_is_loading(kmod), 10000, 100);
 		if (err < 0) {
@@ -279,7 +281,31 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		}
 	}
 
-	return kmod_module_remove_module(kmod, flags);
+	for (tries = 0; tries < MAX_TRIES; tries++) {
+		bool loop = false;
+
+		err = kmod_module_remove_module(kmod, flags);
+
+		/* Only loop in the following cases */
+		loop = err == -EBUSY || err == -EAGAIN;
+
+		if (!loop)
+			break;
+
+		igt_debug("Module %s failed to unload with err: %d on attempt: %i\n",
+			  mod_name, err, tries + 1);
+
+		usleep(SLEEP_DURATION);
+	}
+
+	if (err && err != -ENOENT)
+		igt_info("Module %s failed to unload with err: %d after ~%.1fms\n",
+			 mod_name, err, SLEEP_DURATION*tries/1000.);
+	else if (tries)
+		igt_info("Module %s unload took ~%.1fms over %i attempts\n",
+			 mod_name, SLEEP_DURATION*tries/1000., tries + 1);
+
+	return err;
 }
 
 /**
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [igt-dev] [PATCH i-g-t] lib/igt_kmod: Allow some leeway in igt_kmod_unload_r
@ 2023-01-18 16:06 Jonathan Cavitt
  2023-01-18 19:32 ` Kamil Konieczny
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cavitt @ 2023-01-18 16:06 UTC (permalink / raw)
  To: igt-dev; +Cc: chris.p.wilson, jonathan.cavitt, sandeep.kumar.parupalli

kmod_module_remove_module occasionally returns EAGAIN for mei_gsc
in the setup of some gem_lmem_swapping subtests.  Just because
EAGAIN is returned doesn't mean the module is lost and unable to
be unloaded.  Try again some number of times (currently 20) before
giving up.

Retries will occur for -EBUSY and -EAGAIN, as these imply the
system is waiting for the target module can simply be waited for.
All other errors exit immediately, but as the context for each
error informs their relative severity, no warnings will be issued.

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Stuart Summers <stuart.summers@intel.com>
CC: Sandeep Kumar Parupalli <sandeep.kumar.parupalli@intel.com>
CC: Chris Wilson <chris.p.wilson@linux.intel.com>
Reviewed-by: Chris Wilson <chris.p.wilson@linux.intel.com>
---
 lib/igt_kmod.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 17090110c..4aa5320d0 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -253,8 +253,11 @@ out:
 
 static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 {
+#define MAX_TRIES	20
+#define SLEEP_DURATION	500000
 	struct kmod_list *holders, *pos;
-	int err = 0;
+	int err, tries;
+	const char *mod_name = kmod_module_get_name(kmod);
 
 	holders = kmod_module_get_holders(kmod);
 	kmod_list_foreach(pos, holders) {
@@ -269,7 +272,6 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		return err;
 
 	if (igt_kmod_is_loading(kmod)) {
-		const char *mod_name = kmod_module_get_name(kmod);
 		igt_debug("%s still initializing\n", mod_name);
 		err = igt_wait(!igt_kmod_is_loading(kmod), 10000, 100);
 		if (err < 0) {
@@ -279,7 +281,34 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		}
 	}
 
-	return kmod_module_remove_module(kmod, flags);
+	for (tries = 0; tries < MAX_TRIES; tries++) {
+		err = kmod_module_remove_module(kmod, flags);
+
+		/* Only loop in the following cases */
+		if (err != -EBUSY && err != -EAGAIN)
+			break;
+
+		igt_debug("Module %s failed to unload with err: %d on attempt: %i\n",
+			  mod_name, err, tries + 1);
+
+		if (MAX_TRIES - tries - 1)
+			usleep(SLEEP_DURATION);
+	}
+
+	if (err == -ENOENT)
+		igt_debug("Module %s could not be found or does not exist. err: %d\n",
+			  mod_name, err);
+	else if (err == -ENOTSUP)
+		igt_debug("Module %s cannot be unloaded. err: %d\n",
+			  mod_name, err);
+	else if (err)
+		igt_debug("Module %s failed to unload with err: %d after ~%.1fms\n",
+			  mod_name, err, SLEEP_DURATION*tries/1000.);
+	else if (tries)
+		igt_debug("Module %s unload took ~%.1fms over %i attempts\n",
+			  mod_name, SLEEP_DURATION*tries/1000., tries + 1);
+
+	return err;
 }
 
 /**
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [igt-dev] [PATCH i-g-t] lib/igt_kmod: Allow some leeway in igt_kmod_unload_r
@ 2023-01-18 20:03 Jonathan Cavitt
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cavitt @ 2023-01-18 20:03 UTC (permalink / raw)
  To: igt-dev; +Cc: chris.p.wilson, jonathan.cavitt, sandeep.kumar.parupalli

kmod_module_remove_module occasionally returns EAGAIN for mei_gsc
in the setup of some gem_lmem_swapping subtests.  Just because
EAGAIN is returned doesn't mean the module is lost and unable to
be unloaded.  Try again some number of times (currently 20) before
giving up.

Retries will occur for -EBUSY and -EAGAIN, as these imply the
system is waiting for the target module can simply be waited for.
All other errors exit immediately, but as the context for each
error informs their relative severity, no warnings will be issued.

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
CC: Stuart Summers <stuart.summers@intel.com>
CC: Sandeep Kumar Parupalli <sandeep.kumar.parupalli@intel.com>
CC: Chris Wilson <chris.p.wilson@linux.intel.com>
Reviewed-by: Chris Wilson <chris.p.wilson@linux.intel.com>
---
 lib/igt_kmod.c | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 17090110c..75f1a1035 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -253,8 +253,11 @@ out:
 
 static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 {
+#define MAX_TRIES	20
+#define SLEEP_DURATION	500000
 	struct kmod_list *holders, *pos;
-	int err = 0;
+	int err, tries;
+	const char *mod_name = kmod_module_get_name(kmod);
 
 	holders = kmod_module_get_holders(kmod);
 	kmod_list_foreach(pos, holders) {
@@ -269,7 +272,6 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		return err;
 
 	if (igt_kmod_is_loading(kmod)) {
-		const char *mod_name = kmod_module_get_name(kmod);
 		igt_debug("%s still initializing\n", mod_name);
 		err = igt_wait(!igt_kmod_is_loading(kmod), 10000, 100);
 		if (err < 0) {
@@ -279,7 +281,36 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
 		}
 	}
 
-	return kmod_module_remove_module(kmod, flags);
+	for (tries = 0; tries < MAX_TRIES; tries++) {
+		err = kmod_module_remove_module(kmod, flags);
+
+		/* Only loop in the following cases */
+		if (err != -EBUSY && err != -EAGAIN)
+			break;
+
+		igt_debug("Module %s failed to unload with err: %d on attempt: %i\n",
+			  mod_name, err, tries + 1);
+
+		if (tries < MAX_TRIES - 1)
+			usleep(SLEEP_DURATION);
+	}
+
+	if (err == -ENOENT)
+		igt_debug("Module %s could not be found or does not exist. err: %d\n",
+			  mod_name, err);
+	else if (err == -ENOTSUP)
+		igt_debug("Module %s cannot be unloaded. err: %d\n",
+			  mod_name, err);
+	else if (err)
+		igt_debug("Module %s failed to unload with err: %d after ~%.1fms\n",
+			  mod_name, err, SLEEP_DURATION*tries/1000.);
+	else if (tries)
+		igt_debug("Module %s unload took ~%.1fms over %i attempts\n",
+			  mod_name, SLEEP_DURATION*tries/1000., tries + 1);
+	else
+		igt_debug("Module %s unloaded immediately\n", mod_name);
+
+	return err;
 }
 
 /**
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-01-18 20:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-09 19:25 [igt-dev] [PATCH i-g-t] lib/igt_kmod: Allow some leeway in igt_kmod_unload_r Jonathan Cavitt
2023-01-09 19:33 ` Cavitt, Jonathan
2023-01-09 21:02 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-01-10  6:03 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-01-17 16:06 ` [igt-dev] [PATCH i-g-t] " Kamil Konieczny
2023-01-17 17:56   ` Cavitt, Jonathan
  -- strict thread matches above, loose matches on Subject: below --
2023-01-17 18:03 Jonathan Cavitt
2023-01-18 13:10 ` Kamil Konieczny
2023-01-18 16:06 Jonathan Cavitt
2023-01-18 19:32 ` Kamil Konieczny
2023-01-18 19:56   ` Cavitt, Jonathan
2023-01-18 20:03 Jonathan Cavitt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox