intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Somalapuram Amaranath" <Amaranath.Somalapuram@amd.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	dri-devel@lists.freedesktop.org,
	"Paulo Zanoni" <paulo.r.zanoni@intel.com>,
	"Simona Vetter" <simona.vetter@ffwll.ch>
Subject: [PATCH v14 4/8] drm/ttm: Use fault-injection to test error paths
Date: Fri, 15 Nov 2024 16:01:16 +0100	[thread overview]
Message-ID: <20241115150120.3280-5-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20241115150120.3280-1-thomas.hellstrom@linux.intel.com>

Use fault-injection to test partial TTM swapout and interrupted swapin.
Return -EINTR for swapin to test the callers ability to handle and
restart the swapin, and on swapout perform a partial swapout to test that
the swapin and release_shrunken functionality.

v8:
- Use the core fault-injection system.
v9:
- Fix compliation failure for !CONFIG_FAULT_INJECTION

Cc: Christian König <christian.koenig@amd.com>
Cc: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: <dri-devel@lists.freedesktop.org>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com> #v7
---
 drivers/gpu/drm/ttm/ttm_pool.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index f58864439edb..32c3ee255eb2 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -48,6 +48,13 @@
 
 #include "ttm_module.h"
 
+#ifdef CONFIG_FAULT_INJECTION
+#include <linux/fault-inject.h>
+static DECLARE_FAULT_ATTR(backup_fault_inject);
+#else
+#define should_fail(...) false
+#endif
+
 /**
  * struct ttm_pool_dma - Helper object for coherent DMA mappings
  *
@@ -431,6 +438,7 @@ static int ttm_pool_restore_tt(struct ttm_pool_tt_restore *restore,
 			       struct ttm_backup *backup,
 			       struct ttm_operation_ctx *ctx)
 {
+	static unsigned long __maybe_unused swappedin;
 	unsigned int i, nr = 1 << restore->order;
 	int ret = 0;
 
@@ -446,6 +454,12 @@ static int ttm_pool_restore_tt(struct ttm_pool_tt_restore *restore,
 			if (handle == 0)
 				continue;
 
+			if (IS_ENABLED(CONFIG_FAULT_INJECTION) && ctx->interruptible &&
+			    should_fail(&backup_fault_inject, 1)) {
+				ret = -EINTR;
+				break;
+			}
+
 			ret = ttm_backup_copy_page
 				(backup, restore->first_page[i],
 				 handle, ctx->interruptible);
@@ -892,7 +906,14 @@ long ttm_pool_backup_tt(struct ttm_pool *pool, struct ttm_tt *ttm,
 
 	alloc_gfp = GFP_KERNEL | __GFP_HIGH | __GFP_NOWARN | __GFP_RETRY_MAYFAIL;
 
-	for (i = 0; i < ttm->num_pages; ++i) {
+	num_pages = ttm->num_pages;
+
+	/* Pretend doing fault injection by shrinking only half of the pages. */
+
+	if (IS_ENABLED(CONFIG_FAULT_INJECTION) && should_fail(&backup_fault_inject, 1))
+		num_pages = DIV_ROUND_UP(num_pages, 2);
+
+	for (i = 0; i < num_pages; ++i) {
 		page = ttm->pages[i];
 		if (unlikely(!page))
 			continue;
@@ -1180,6 +1201,10 @@ int ttm_pool_mgr_init(unsigned long num_pages)
 			    &ttm_pool_debugfs_globals_fops);
 	debugfs_create_file("page_pool_shrink", 0400, ttm_debugfs_root, NULL,
 			    &ttm_pool_debugfs_shrink_fops);
+#ifdef CONFIG_FAULT_INJECTION
+	fault_create_debugfs_attr("backup_fault_inject", ttm_debugfs_root,
+				  &backup_fault_inject);
+#endif
 #endif
 
 	mm_shrinker = shrinker_alloc(0, "drm-ttm_pool");
-- 
2.46.2


  parent reply	other threads:[~2024-11-15 15:01 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15 15:01 [PATCH v14 0/8] TTM shrinker helpers and xe buffer object shrinker Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 1/8] drm/ttm: Balance ttm_resource_cursor_init() and ttm_resource_cursor_fini() Thomas Hellström
2024-11-20 10:51   ` Christian König
2024-11-21 15:54     ` Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 2/8] drm/ttm: Provide a shmem backup implementation Thomas Hellström
2024-11-19 13:40   ` Christian König
2024-11-20  7:58     ` Thomas Hellström
2024-11-20  9:24       ` Christian König
2024-11-20 10:34         ` Thomas Hellström
2024-11-20 10:50           ` Christian König
2024-11-20 11:07             ` Thomas Hellström
2024-11-20 11:20         ` Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 3/8] drm/ttm/pool: Provide a helper to shrink pages Thomas Hellström
2024-12-03 13:12   ` Christian König
2024-12-03 13:42     ` Thomas Hellström
2024-12-03 14:51       ` Christian König
2024-12-03 15:50         ` Thomas Hellström
2024-12-03 16:20           ` Christian König
2024-12-03 16:31             ` Thomas Hellström
2024-12-03 16:39               ` Christian König
2024-12-03 16:43                 ` Thomas Hellström
2024-12-03 16:46                   ` Christian König
2024-12-03 17:44                     ` Thomas Hellström
2024-12-04  9:16                       ` Christian König
2024-12-04  9:56                         ` Thomas Hellström
2024-12-04 10:56                           ` Christian König
2024-12-04 11:09                             ` Thomas Hellström
2024-12-04 11:24                               ` Christian König
2024-12-04 12:24                                 ` Thomas Hellström
2024-12-18 10:07                                 ` Thomas Hellström
2024-12-18 10:15         ` Thomas Hellström
2024-11-15 15:01 ` Thomas Hellström [this message]
2024-11-15 15:01 ` [PATCH v14 5/8] drm/ttm: Add a macro to perform LRU iteration Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 6/8] drm/ttm: Add helpers for shrinking Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 7/8] drm/xe: Add a shrinker for xe bos Thomas Hellström
2024-11-15 15:01 ` [PATCH v14 8/8] drm/xe: Increase the XE_PL_TT watermark Thomas Hellström
2024-11-15 15:06 ` ✓ CI.Patch_applied: success for TTM shrinker helpers and xe buffer object shrinker (rev13) Patchwork
2024-11-15 15:07 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-15 15:08 ` ✓ CI.KUnit: success " Patchwork
2024-11-15 15:17 ` ✗ CI.Build: failure " Patchwork
2024-11-16 11:26 ` ✓ CI.Patch_applied: success for TTM shrinker helpers and xe buffer object shrinker (rev14) Patchwork
2024-11-16 11:26 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-16 11:28 ` ✓ CI.KUnit: success " Patchwork
2024-11-16 11:46 ` ✓ CI.Build: " Patchwork
2024-11-16 11:46 ` ✗ CI.Hooks: failure " Patchwork
2024-11-16 11:47 ` ✗ CI.checksparse: warning " Patchwork
2024-11-18 12:37 ` ✓ CI.Patch_applied: success for TTM shrinker helpers and xe buffer object shrinker (rev15) Patchwork
2024-11-18 12:37 ` ✗ CI.checkpatch: warning " Patchwork
2024-11-18 12:38 ` ✓ CI.KUnit: success " Patchwork
2024-11-18 12:56 ` ✓ CI.Build: " Patchwork
2024-11-18 12:56 ` ✗ CI.Hooks: failure " Patchwork
2024-11-18 12:58 ` ✗ CI.checksparse: warning " Patchwork
2024-11-18 13:16 ` ✓ CI.BAT: success " Patchwork
2024-11-18 16:29 ` ✗ CI.FULL: 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=20241115150120.3280-5-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=Amaranath.Somalapuram@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=paulo.r.zanoni@intel.com \
    --cc=simona.vetter@ffwll.ch \
    /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;
as well as URLs for NNTP newsgroup(s).