From: Roger He <Hongbo.He-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Roger He <Hongbo.He-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 7/7] drm/ttm: enable swapout of per VM BOs during allocation and allows reaping of deleted BOs
Date: Wed, 20 Dec 2017 18:35:01 +0800 [thread overview]
Message-ID: <1513766101-15993-7-git-send-email-Hongbo.He@amd.com> (raw)
In-Reply-To: <1513766101-15993-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
Change-Id: I1e87954564f38ad298bf6e4ff88c9f26f291a62d
Signed-off-by: Roger He <Hongbo.He@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 15 +++++++++++----
drivers/gpu/drm/ttm/ttm_memory.c | 12 ++++++++----
include/drm/ttm/ttm_bo_api.h | 3 ++-
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 313925c..ecb8916 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1686,18 +1686,20 @@ EXPORT_SYMBOL(ttm_bo_synccpu_write_release);
* A buffer object shrink method that tries to swap out the first
* buffer object on the bo_global::swap_lru list.
*/
-int ttm_bo_swapout(struct ttm_bo_global *glob)
+int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
{
struct ttm_buffer_object *bo;
int ret = -EBUSY;
+ bool locked;
unsigned i;
spin_lock(&glob->lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, &glob->swap_lru[i], swap) {
- ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY;
- if (!ret)
+ if (ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) {
+ ret = 0;
break;
+ }
}
if (!ret)
break;
@@ -1773,7 +1775,12 @@ EXPORT_SYMBOL(ttm_bo_swapout);
void ttm_bo_swapout_all(struct ttm_bo_device *bdev)
{
- while (ttm_bo_swapout(bdev->glob) == 0)
+ struct ttm_operation_ctx ctx = {
+ .interruptible = false,
+ .no_wait_gpu = false
+ };
+
+ while (ttm_bo_swapout(bdev->glob, &ctx) == 0)
;
}
EXPORT_SYMBOL(ttm_bo_swapout_all);
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 8df0755..8817b86 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -211,7 +211,7 @@ static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob,
*/
static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq,
- uint64_t extra)
+ uint64_t extra, struct ttm_operation_ctx *ctx)
{
int ret;
@@ -219,7 +219,7 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq,
while (ttm_zones_above_swap_target(glob, from_wq, extra)) {
spin_unlock(&glob->lock);
- ret = ttm_bo_swapout(glob->bo_glob);
+ ret = ttm_bo_swapout(glob->bo_glob, ctx);
spin_lock(&glob->lock);
if (unlikely(ret != 0))
break;
@@ -230,10 +230,14 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq,
static void ttm_shrink_work(struct work_struct *work)
{
+ struct ttm_operation_ctx ctx = {
+ .interruptible = false,
+ .no_wait_gpu = false
+ };
struct ttm_mem_global *glob =
container_of(work, struct ttm_mem_global, work);
- ttm_shrink(glob, true, 0ULL);
+ ttm_shrink(glob, true, 0ULL, &ctx);
}
static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
@@ -520,7 +524,7 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob,
return -ENOMEM;
if (unlikely(count-- == 0))
return -ENOMEM;
- ttm_shrink(glob, false, memory + (memory >> 2) + 16);
+ ttm_shrink(glob, false, memory + (memory >> 2) + 16, ctx);
}
return 0;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 24a8db7..f1c74c2 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -752,7 +752,8 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp,
const char __user *wbuf, char __user *rbuf,
size_t count, loff_t *f_pos, bool write);
-int ttm_bo_swapout(struct ttm_bo_global *glob);
+int ttm_bo_swapout(struct ttm_bo_global *glob,
+ struct ttm_operation_ctx *ctx);
void ttm_bo_swapout_all(struct ttm_bo_device *bdev);
int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo);
#endif
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-12-20 10:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 10:34 [PATCH 1/7] drm/ttm: call ttm_bo_swapout directly when ttm shrink Roger He
2017-12-20 10:34 ` [PATCH 3/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc_page Roger He
[not found] ` <1513766101-15993-3-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 13:35 ` Christian König
[not found] ` <edd81ee9-bb23-84c4-4065-2b424c95724e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-21 6:05 ` He, Roger
[not found] ` <BN6PR1201MB0114CD1510459BE13D0BF292FD0D0-6iU6OBHu2P8MH+E/uqw63WrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-12-21 8:15 ` Thomas Hellstrom
[not found] ` <1513766101-15993-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 10:34 ` [PATCH 2/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc Roger He
[not found] ` <1513766101-15993-2-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-20 13:33 ` Christian König
[not found] ` <15e3b956-8777-8fb1-2709-5409a756f0be-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-24 23:24 ` Sinclair Yeh
[not found] ` <20180124232346.GA59165-WSU1YMatGzO44ywRPIzf9A@public.gmane.org>
2018-01-25 8:31 ` Christian König
2017-12-21 8:07 ` Thomas Hellstrom
2017-12-20 10:34 ` [PATCH 4/7] drm/ttm: use an operation ctx for ttm_tt_populate in ttm_bo_driver Roger He
2017-12-20 14:20 ` Christian König
2017-12-20 10:34 ` [PATCH 5/7] drm/ttm: use an operation ctx for ttm_tt_bind Roger He
2017-12-20 10:35 ` Roger He [this message]
[not found] ` <1513766101-15993-7-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-12-21 7:58 ` [PATCH 7/7] drm/ttm: enable swapout of per VM BOs during allocation and allows reaping of deleted BOs Thomas Hellstrom
2017-12-21 8:18 ` Christian König
2017-12-20 13:29 ` [PATCH 1/7] drm/ttm: call ttm_bo_swapout directly when ttm shrink Christian König
2017-12-21 7:34 ` Thomas Hellstrom
[not found] ` <b0f51ff0-950e-bbe0-0032-e0e714d94350-4+hqylr40dJg9hUCZPvPmw@public.gmane.org>
2017-12-21 9:17 ` He, Roger
2017-12-20 10:35 ` [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout Roger He
2017-12-21 7:50 ` Thomas Hellstrom
2017-12-25 3:10 ` He, Roger
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=1513766101-15993-7-git-send-email-Hongbo.He@amd.com \
--to=hongbo.he-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/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