AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Jerry (Junwei)" <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
To: Chunming Zhou <David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Christian.Koenig-5C7GfCeVMHo@public.gmane.org
Subject: Re: [PATCH 3/3] drm/amdgpu: move gtt usage statistic to gtt mgr
Date: Wed, 19 Apr 2017 13:54:30 +0800	[thread overview]
Message-ID: <58F6FB96.5040303@amd.com> (raw)
In-Reply-To: <1492573810-21127-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>

On 04/19/2017 11:50 AM, Chunming Zhou wrote:
> Change-Id: Ifea42c8ae2206143d7e22b35eea537ba9e928fe8
> Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 13 ++++++++++---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c  |  6 ------
>   2 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 85de145..db7bbde 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -97,6 +97,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
>   {
>   	struct amdgpu_gtt_mgr *mgr = man->priv;
>   	struct drm_mm_node *node = mem->mm_node;
> +	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
>   	enum drm_mm_search_flags sflags = DRM_MM_SEARCH_BEST;
>   	enum drm_mm_allocator_flags aflags = DRM_MM_CREATE_DEFAULT;
>   	unsigned long fpfn, lpfn;
> @@ -124,8 +125,10 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
>   	r = drm_mm_insert_node_in_range_generic(&mgr->mm, node, mem->num_pages,
>   						mem->page_alignment, 0,
>   						fpfn, lpfn, sflags, aflags);
> -	if (!r)
> +	if (!r) {
>   		mgr->available -= mem->num_pages;
> +		atomic64_add(mem->size, &adev->gtt_usage);
> +	}
>   	spin_unlock(&mgr->lock);
>
>   	if (!r) {
> @@ -140,10 +143,12 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
>
>   void amdgpu_gtt_mgr_print(struct seq_file *m, struct ttm_mem_type_manager *man)
>   {
> +	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
>   	struct amdgpu_gtt_mgr *mgr = man->priv;
>
> -	seq_printf(m, "man size:%llu pages, gtt available:%llu pages\n",
> -		   man->size,	mgr->available);
> +	seq_printf(m, "man size:%llu pages, gtt available:%llu pages, usage:%lluMB\n",
> +		   man->size,	mgr->available,
> +		   (u64)atomic64_read(&adev->gtt_usage) >> 20);
>   }
>   /**
>    * amdgpu_gtt_mgr_new - allocate a new node
> @@ -214,6 +219,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>   {
>   	struct amdgpu_gtt_mgr *mgr = man->priv;
>   	struct drm_mm_node *node = mem->mm_node;
> +	struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev);
>
>   	if (!node)
>   		return;
> @@ -222,6 +228,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,
>   	if (node->start != AMDGPU_BO_INVALID_OFFSET) {
>   		drm_mm_remove_node(node);
>   		mgr->available += mem->num_pages;
> +		atomic64_sub(mem->size, &adev->gtt_usage);
>   	}
>   	spin_unlock(&mgr->lock);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 3cde1c9..2249eb6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -61,9 +61,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev,
>
>   	if (new_mem) {
>   		switch (new_mem->mem_type) {
> -		case TTM_PL_TT:
> -			atomic64_add(new_mem->size, &adev->gtt_usage);
> -			break;

IMO, we may still need this, since it's updated when bo moves.
For instance, VRAM bo to GTT, it requires to update gtt_usage as well.

>   		case TTM_PL_VRAM:
>   			atomic64_add(new_mem->size, &adev->vram_usage);
>   			vis_size = amdgpu_get_vis_part_size(adev, new_mem);
> @@ -80,9 +77,6 @@ static void amdgpu_update_memory_usage(struct amdgpu_device *adev,
>
>   	if (old_mem) {
>   		switch (old_mem->mem_type) {
> -		case TTM_PL_TT:
> -			atomic64_sub(old_mem->size, &adev->gtt_usage);
> -			break;

Same comment as above.

Jerry
>   		case TTM_PL_VRAM:
>   			atomic64_sub(old_mem->size, &adev->vram_usage);
>   			vis_size = amdgpu_get_vis_part_size(adev, old_mem);
>
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-04-19  5:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-19  3:50 [PATCH 1/3] drm/amdgpu: fix gtt mgr available statistics Chunming Zhou
     [not found] ` <1492573810-21127-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-19  3:50   ` [PATCH 2/3] drm/amdgpu: add gtt print like vram when dump mm table Chunming Zhou
     [not found]     ` <1492573810-21127-2-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-19  6:41       ` Christian König
2017-04-19  3:50   ` [PATCH 3/3] drm/amdgpu: move gtt usage statistic to gtt mgr Chunming Zhou
     [not found]     ` <1492573810-21127-3-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-19  5:54       ` Zhang, Jerry (Junwei) [this message]
2017-04-19  6:45       ` Christian König
2017-04-19  6:38   ` [PATCH 1/3] drm/amdgpu: fix gtt mgr available statistics Christian König
     [not found]     ` <cb40837d-7734-35cb-7983-80c9c2a3943a-5C7GfCeVMHo@public.gmane.org>
2017-04-19  6:52       ` zhoucm1
     [not found]         ` <58F70923.5060705-5C7GfCeVMHo@public.gmane.org>
2017-04-19  6:59           ` Christian König
     [not found]             ` <55d01312-8b28-98d1-fef1-3f74d7ade20c-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-19  9:15               ` zhoucm1
     [not found]                 ` <58F72AB1.7000008-5C7GfCeVMHo@public.gmane.org>
2017-04-19  9:40                   ` Christian König
     [not found]                     ` <14328cdc-598d-7b0d-01cb-1a2d3f46a772-5C7GfCeVMHo@public.gmane.org>
2017-04-20  3:10                       ` zhoucm1
     [not found]                         ` <58F8268E.2040104-5C7GfCeVMHo@public.gmane.org>
2017-04-20  8:54                           ` Christian König
  -- strict thread matches above, loose matches on Subject: below --
2017-04-13  9:02 Chunming Zhou
     [not found] ` <1492074127-6317-1-git-send-email-David1.Zhou-5C7GfCeVMHo@public.gmane.org>
2017-04-13  9:02   ` [PATCH 3/3] drm/amdgpu: move gtt usage statistic to gtt mgr Chunming Zhou

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=58F6FB96.5040303@amd.com \
    --to=jerry.zhang-5c7gfcevmho@public.gmane.org \
    --cc=Christian.Koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-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