* [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped
@ 2025-01-26 9:32 Zhaoyu Liu
2025-02-04 2:25 ` 刘照玉
2025-02-04 7:59 ` Christian König
0 siblings, 2 replies; 4+ messages in thread
From: Zhaoyu Liu @ 2025-01-26 9:32 UTC (permalink / raw)
To: christian.koenig, ray.huang, maarten.lankhorst, mripard,
tzimmermann, airlied, simona
Cc: dri-devel, linux-kernel
TTM always uses pin_count and ttm_resource_is_swapped() together to
determine whether a BO is unevictable.
Now use ttm_resource_unevictable() to replace them.
Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@bytedance.com>
---
drivers/gpu/drm/ttm/ttm_resource.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index cc29bbf3eabb..a8f9f7ed6c6e 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -252,11 +252,16 @@ static bool ttm_resource_is_swapped(struct ttm_resource *res, struct ttm_buffer_
return ttm_tt_is_swapped(bo->ttm);
}
+static bool ttm_resource_unevictable(struct ttm_resource *res, struct ttm_buffer_object *bo)
+{
+ return bo->pin_count || ttm_resource_is_swapped(res, bo);
+}
+
/* Add the resource to a bulk move if the BO is configured for it */
void ttm_resource_add_bulk_move(struct ttm_resource *res,
struct ttm_buffer_object *bo)
{
- if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
+ if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
ttm_lru_bulk_move_add(bo->bulk_move, res);
}
@@ -264,7 +269,7 @@ void ttm_resource_add_bulk_move(struct ttm_resource *res,
void ttm_resource_del_bulk_move(struct ttm_resource *res,
struct ttm_buffer_object *bo)
{
- if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
+ if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
ttm_lru_bulk_move_del(bo->bulk_move, res);
}
@@ -276,10 +281,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resource *res)
lockdep_assert_held(&bo->bdev->lru_lock);
- if (bo->pin_count || ttm_resource_is_swapped(res, bo)) {
+ if (ttm_resource_unevictable(res, bo)) {
list_move_tail(&res->lru.link, &bdev->unevictable);
- } else if (bo->bulk_move) {
+ } else if (bo->bulk_move) {
struct ttm_lru_bulk_move_pos *pos =
ttm_lru_bulk_move_pos(bo->bulk_move, res);
@@ -318,7 +323,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
man = ttm_manager_type(bo->bdev, place->mem_type);
spin_lock(&bo->bdev->lru_lock);
- if (bo->pin_count || ttm_resource_is_swapped(res, bo))
+ if (ttm_resource_unevictable(res, bo))
list_add_tail(&res->lru.link, &bo->bdev->unevictable);
else
list_add_tail(&res->lru.link, &man->lru[bo->priority]);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped
2025-01-26 9:32 [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped Zhaoyu Liu
@ 2025-02-04 2:25 ` 刘照玉
2025-02-04 7:59 ` Christian König
1 sibling, 0 replies; 4+ messages in thread
From: 刘照玉 @ 2025-02-04 2:25 UTC (permalink / raw)
To: christian.koenig, ray.huang, maarten.lankhorst, mripard,
tzimmermann, airlied, simona, thomas.hellstrom@linux.intel.com
Cc: dri-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3157 bytes --]
> From: "Zhaoyu Liu"<liuzhaoyu.zackary@bytedance.com> > Date: Sun, Jan 26,
2025, 17:33 > Subject: [PATCH] drm/ttm: use ttm_resource_unevictable() to
replace pin_count and swapped > To: <christian.koenig@amd.com>, <
ray.huang@amd.com>, <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>,
<tzimmermann@suse.de>, <airlied@gmail.com>, <simona@ffwll.ch> > Cc: <
dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org> > TTM
always uses pin_count and ttm_resource_is_swapped() together to > determine
whether a BO is unevictable. > Now use ttm_resource_unevictable() to
replace them. > > Signed-off-by: Zhaoyu Liu <
liuzhaoyu.zackary@bytedance.com> > --- >
drivers/gpu/drm/ttm/ttm_resource.c | 15 ++++++++++----- > 1 file changed,
10 insertions(+), 5 deletions(-) > > diff --git
a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c >
index cc29bbf3eabb..a8f9f7ed6c6e 100644 > ---
a/drivers/gpu/drm/ttm/ttm_resource.c > +++
b/drivers/gpu/drm/ttm/ttm_resource.c > @@ -252,11 +252,16 @@ static bool
ttm_resource_is_swapped(struct ttm_resource *res, struct ttm_buffer_ >
return ttm_tt_is_swapped(bo->ttm); > } > > +static bool
ttm_resource_unevictable(struct ttm_resource *res, struct ttm_buffer_object
*bo) > +{ > + return bo->pin_count || ttm_resource_is_swapped(res,
bo); > +} > + > /* Add the resource to a bulk move if the BO is configured
for it */ > void ttm_resource_add_bulk_move(struct ttm_resource *res, >
struct ttm_buffer_object *bo) > { > -
if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
> + if (bo->bulk_move && !ttm_resource_unevictable(res, bo)) >
ttm_lru_bulk_move_add(bo->bulk_move, res); > } > > @@ -264,7
+269,7 @@ void ttm_resource_add_bulk_move(struct ttm_resource *res, > void
ttm_resource_del_bulk_move(struct ttm_resource *res, >
struct ttm_buffer_object *bo) > { > - if
(bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo)) > +
if (bo->bulk_move && !ttm_resource_unevictable(res, bo)) >
ttm_lru_bulk_move_del(bo->bulk_move, res); > } > > @@ -276,10
+281,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resource *res) >
> lockdep_assert_held(&bo->bdev->lru_lock); > > - if
(bo->pin_count || ttm_resource_is_swapped(res, bo)) { > + if
(ttm_resource_unevictable(res, bo)) { >
list_move_tail(&res->lru.link, &bdev->unevictable); > > - } else
if (bo->bulk_move) { > + } else if (bo->bulk_move) { >
struct ttm_lru_bulk_move_pos *pos = >
ttm_lru_bulk_move_pos(bo->bulk_move, res); > > @@ -318,7 +323,7 @@ void
ttm_resource_init(struct ttm_buffer_object *bo, > > man =
ttm_manager_type(bo->bdev, place->mem_type); >
spin_lock(&bo->bdev->lru_lock); > - if (bo->pin_count ||
ttm_resource_is_swapped(res, bo)) > + if
(ttm_resource_unevictable(res, bo)) >
list_add_tail(&res->lru.link, &bo->bdev->unevictable); > else >
list_add_tail(&res->lru.link, &man->lru[bo->priority]); >
-- > 2.25.1 > Hi, Could you help me to review it, thx.
[-- Attachment #2: Type: text/html, Size: 4774 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped
2025-01-26 9:32 [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped Zhaoyu Liu
2025-02-04 2:25 ` 刘照玉
@ 2025-02-04 7:59 ` Christian König
2025-02-08 9:15 ` Zhaoyu Liu
1 sibling, 1 reply; 4+ messages in thread
From: Christian König @ 2025-02-04 7:59 UTC (permalink / raw)
To: Zhaoyu Liu, ray.huang, maarten.lankhorst, mripard, tzimmermann,
airlied, simona
Cc: dri-devel, linux-kernel
Am 26.01.25 um 10:32 schrieb Zhaoyu Liu:
> TTM always uses pin_count and ttm_resource_is_swapped() together to
> determine whether a BO is unevictable.
> Now use ttm_resource_unevictable() to replace them.
>
> Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@bytedance.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
I will pick this up for drm-misc-next.
> ---
> drivers/gpu/drm/ttm/ttm_resource.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index cc29bbf3eabb..a8f9f7ed6c6e 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -252,11 +252,16 @@ static bool ttm_resource_is_swapped(struct ttm_resource *res, struct ttm_buffer_
> return ttm_tt_is_swapped(bo->ttm);
> }
>
> +static bool ttm_resource_unevictable(struct ttm_resource *res, struct ttm_buffer_object *bo)
> +{
> + return bo->pin_count || ttm_resource_is_swapped(res, bo);
> +}
> +
> /* Add the resource to a bulk move if the BO is configured for it */
> void ttm_resource_add_bulk_move(struct ttm_resource *res,
> struct ttm_buffer_object *bo)
> {
> - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
> + if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
> ttm_lru_bulk_move_add(bo->bulk_move, res);
> }
>
> @@ -264,7 +269,7 @@ void ttm_resource_add_bulk_move(struct ttm_resource *res,
> void ttm_resource_del_bulk_move(struct ttm_resource *res,
> struct ttm_buffer_object *bo)
> {
> - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
> + if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
> ttm_lru_bulk_move_del(bo->bulk_move, res);
> }
>
> @@ -276,10 +281,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resource *res)
>
> lockdep_assert_held(&bo->bdev->lru_lock);
>
> - if (bo->pin_count || ttm_resource_is_swapped(res, bo)) {
> + if (ttm_resource_unevictable(res, bo)) {
> list_move_tail(&res->lru.link, &bdev->unevictable);
>
> - } else if (bo->bulk_move) {
> + } else if (bo->bulk_move) {
> struct ttm_lru_bulk_move_pos *pos =
> ttm_lru_bulk_move_pos(bo->bulk_move, res);
>
> @@ -318,7 +323,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
>
> man = ttm_manager_type(bo->bdev, place->mem_type);
> spin_lock(&bo->bdev->lru_lock);
> - if (bo->pin_count || ttm_resource_is_swapped(res, bo))
> + if (ttm_resource_unevictable(res, bo))
> list_add_tail(&res->lru.link, &bo->bdev->unevictable);
> else
> list_add_tail(&res->lru.link, &man->lru[bo->priority]);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped
2025-02-04 7:59 ` Christian König
@ 2025-02-08 9:15 ` Zhaoyu Liu
0 siblings, 0 replies; 4+ messages in thread
From: Zhaoyu Liu @ 2025-02-08 9:15 UTC (permalink / raw)
To: Christian König, ray.huang, maarten.lankhorst, mripard,
tzimmermann, airlied, simona
Cc: dri-devel, linux-kernel
On Tue, Feb 04, 2025 at 08:59:08AM +0100, Christian König wrote:
> Am 26.01.25 um 10:32 schrieb Zhaoyu Liu:
> > TTM always uses pin_count and ttm_resource_is_swapped() together to
> > determine whether a BO is unevictable.
> > Now use ttm_resource_unevictable() to replace them.
> >
> > Signed-off-by: Zhaoyu Liu <liuzhaoyu.zackary@bytedance.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> I will pick this up for drm-misc-next.
>
Thanks,
but I don't see it in drm-misc-next(https://cgit.freedesktop.org/drm/drm-misc/log),
is it not merged yet?
---
All The Best
> > ---
> > drivers/gpu/drm/ttm/ttm_resource.c | 15 ++++++++++-----
> > 1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> > index cc29bbf3eabb..a8f9f7ed6c6e 100644
> > --- a/drivers/gpu/drm/ttm/ttm_resource.c
> > +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> > @@ -252,11 +252,16 @@ static bool ttm_resource_is_swapped(struct ttm_resource *res, struct ttm_buffer_
> > return ttm_tt_is_swapped(bo->ttm);
> > }
> > +static bool ttm_resource_unevictable(struct ttm_resource *res, struct ttm_buffer_object *bo)
> > +{
> > + return bo->pin_count || ttm_resource_is_swapped(res, bo);
> > +}
> > +
> > /* Add the resource to a bulk move if the BO is configured for it */
> > void ttm_resource_add_bulk_move(struct ttm_resource *res,
> > struct ttm_buffer_object *bo)
> > {
> > - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
> > + if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
> > ttm_lru_bulk_move_add(bo->bulk_move, res);
> > }
> > @@ -264,7 +269,7 @@ void ttm_resource_add_bulk_move(struct ttm_resource *res,
> > void ttm_resource_del_bulk_move(struct ttm_resource *res,
> > struct ttm_buffer_object *bo)
> > {
> > - if (bo->bulk_move && !bo->pin_count && !ttm_resource_is_swapped(res, bo))
> > + if (bo->bulk_move && !ttm_resource_unevictable(res, bo))
> > ttm_lru_bulk_move_del(bo->bulk_move, res);
> > }
> > @@ -276,10 +281,10 @@ void ttm_resource_move_to_lru_tail(struct ttm_resource *res)
> > lockdep_assert_held(&bo->bdev->lru_lock);
> > - if (bo->pin_count || ttm_resource_is_swapped(res, bo)) {
> > + if (ttm_resource_unevictable(res, bo)) {
> > list_move_tail(&res->lru.link, &bdev->unevictable);
> > - } else if (bo->bulk_move) {
> > + } else if (bo->bulk_move) {
> > struct ttm_lru_bulk_move_pos *pos =
> > ttm_lru_bulk_move_pos(bo->bulk_move, res);
> > @@ -318,7 +323,7 @@ void ttm_resource_init(struct ttm_buffer_object *bo,
> > man = ttm_manager_type(bo->bdev, place->mem_type);
> > spin_lock(&bo->bdev->lru_lock);
> > - if (bo->pin_count || ttm_resource_is_swapped(res, bo))
> > + if (ttm_resource_unevictable(res, bo))
> > list_add_tail(&res->lru.link, &bo->bdev->unevictable);
> > else
> > list_add_tail(&res->lru.link, &man->lru[bo->priority]);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-09 13:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 9:32 [PATCH] drm/ttm: use ttm_resource_unevictable() to replace pin_count and swapped Zhaoyu Liu
2025-02-04 2:25 ` 刘照玉
2025-02-04 7:59 ` Christian König
2025-02-08 9:15 ` Zhaoyu Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.