mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Balbir Singh <balbirs@nvidia.com>
To: Bert Karwatzki <spasswolf@web.de>, Alex Deucher <alexdeucher@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>, Kees Cook <kees@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org
Subject: Re: commit 7ffb791423c7 breaks steam game
Date: Fri, 21 Mar 2025 15:55:49 +1100	[thread overview]
Message-ID: <d3580fa0-df0c-49ce-aa4e-e8c945172939@nvidia.com> (raw)
In-Reply-To: <841287f296579671dcd91329a49feed97186bcd3.camel@web.de>

On 3/21/25 10:43, Bert Karwatzki wrote:
> I did some monitoring using this patch (on top of 6.12.18):
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 0760e70402ec..ccd0c9058cee 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -121,6 +121,8 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager
> *man,
>  	int r;
> 
>  	node = kzalloc(struct_size(node, mm_nodes, 1), GFP_KERNEL);
> +	if (!strcmp(get_current()->comm, "stellaris"))
> +		printk(KERN_INFO "%s: node = %px\n", __func__, node);
>  	if (!node)
>  		return -ENOMEM;
> 
> @@ -142,10 +144,16 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager
> *man,
>  			goto err_free;
> 
>  		node->base.start = node->mm_nodes[0].start;
> +		if (!strcmp(get_current()->comm, "stellaris"))
> +			printk(KERN_INFO "%s %d: node->base.start = 0x%lx node-
>> base.size = 0x%lx\n",
> +				__func__, __LINE__, node->base.start, node-
>> base.size);
>  	} else {
>  		node->mm_nodes[0].start = 0;
>  		node->mm_nodes[0].size = PFN_UP(node->base.size);
>  		node->base.start = AMDGPU_BO_INVALID_OFFSET;
> +		if (!strcmp(get_current()->comm, "stellaris"))
> +			printk(KERN_INFO "%s %d: node->base.start = 0x%lx node-
>> base.size = 0x%lx\n",
> +				__func__, __LINE__, node->base.start, node-
>> base.size);
>  	}
> 
>  	*res = &node->base;
> @@ -170,6 +178,8 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager
> *man,
>  {
>  	struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(res);
>  	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> +	if (!strcmp(get_current()->comm, "stellaris"))
> +		printk(KERN_INFO "%s: node = %px\n", __func__, node);
> 
>  	spin_lock(&mgr->lock);
>  	if (drm_mm_node_allocated(&node->mm_nodes[0]))
> @@ -217,7 +227,11 @@ static bool amdgpu_gtt_mgr_intersects(struct
> ttm_resource_manager *man,
>  				      const struct ttm_place *place,
>  				      size_t size)
>  {
> -	return !place->lpfn || amdgpu_gtt_mgr_has_gart_addr(res);
> +	bool ret;
> +	ret = !place->lpfn || amdgpu_gtt_mgr_has_gart_addr(res);
> +	if (!strcmp(get_current()->comm, "stellaris"))
> +		printk(KERN_INFO, "%s: returning ret = %d", __func__, ret);
> +	return ret;
>  }
> 
>  /**
> @@ -235,7 +249,11 @@ static bool amdgpu_gtt_mgr_compatible(struct
> ttm_resource_manager *man,
>  				      const struct ttm_place *place,
>  				      size_t size)
>  {
> -	return !place->lpfn || amdgpu_gtt_mgr_has_gart_addr(res);
> +	bool ret;
> +	ret = !place->lpfn || amdgpu_gtt_mgr_has_gart_addr(res);
> +	if (!strcmp(get_current()->comm, "stellaris"))
> +		printk(KERN_INFO, "%s: returning ret = %d", __func__, ret);
> +	return ret;
>  }
> 
>  /**
> @@ -288,6 +306,8 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t
> gtt_size)
>  	drm_mm_init(&mgr->mm, start, size);
>  	spin_lock_init(&mgr->lock);
> 
> +	dev_info(adev->dev, "%s: start = 0x%llx size = 0x%llx\n", __func__,
> start, size);
> +
>  	ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, &mgr->manager);
>  	ttm_resource_manager_set_used(man, true);
>  	return 0;
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index 1ed68d3cd80b..e525a1276304 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -223,6 +223,13 @@ static void insert_hole_size(struct rb_root_cached *root,
>  	struct rb_node **link = &root->rb_root.rb_node, *rb = NULL;
>  	u64 x = node->hole_size;
>  	bool first = true;
> +	int count = 0;
> +
> +	if (!strcmp(get_current()->comm, "stellaris")) {
> +		for(struct rb_node *first = rb_first_cached(root); first; first
> = rb_next(first))
> +			count++;
> +		printk(KERN_INFO "%s: RB count = %d\n", __func__, count);
> +	}
> 
>  	while (*link) {
>  		rb = *link;
> @@ -247,6 +254,13 @@ static void insert_hole_addr(struct rb_root *root, struct
> drm_mm_node *node)
>  	struct rb_node **link = &root->rb_node, *rb_parent = NULL;
>  	u64 start = HOLE_ADDR(node), subtree_max_hole = node->subtree_max_hole;
>  	struct drm_mm_node *parent;
> +	int count = 0;
> +
> +	if (!strcmp(get_current()->comm, "stellaris")) {
> +		for(struct rb_node *first = rb_first(root); first; first =
> rb_next(first))
> +			count++;
> +		printk(KERN_INFO "%s: RB count = %d\n", __func__, count);
> +	}
> 
>  	while (*link) {
>  		rb_parent = *link;
> 
> 
> With this I ran stellaris (just opening the game the closing it again from the
> game menu)
> 
> The findings are:
> (a) The size of the RB tree is the same in the working and non-working case (50-
> 60)
> (b) The number of calls to amdgpu_gtt_mgr_new() is ~2000 in both cases
> (c) In the non-working case amdgpu_gtt_mgr_del() is called far more often then
> in the working case:
> Non-working case (cmdline: nokaslr) 834 calls to amdgpu_gtt_mgt_del()
> Working case (cmdline: nokaslr amdgpu.vramlimit=512) 51 calls to
> amdgpu_gtt_mgr_del()
> Working case (cmdline: no additional arguments) 44 calls to amdgpu_gtt_mgr_del()
> 

I am not an expert in amdgpu or gtt_mgr, but I wonder if some of the deletes are coming
from forceful eviction  of memory during allocation?

Have you filed a bug report for the nokaslr case?

Balbir Singh

  reply	other threads:[~2025-03-21  4:55 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 11:22 Bert Karwatzki
2025-03-10 21:48 ` Balbir Singh
2025-03-11  7:19   ` Balbir Singh
2025-03-11  7:28     ` Ingo Molnar
2025-03-11 11:15     ` Bert Karwatzki
2025-03-11 18:24       ` Bert Karwatzki
2025-03-11 22:10         ` Balbir Singh
2025-03-11 23:09           ` Bert Karwatzki
2025-03-12  0:26             ` Bert Karwatzki
2025-03-12  2:23               ` Balbir Singh
2025-03-12  1:24             ` Balbir Singh
2025-03-13  9:22               ` Bert Karwatzki
2025-03-13 10:40                 ` Balbir Singh
2025-03-13 10:53                   ` Bert Karwatzki
2025-03-13 11:47                     ` Balbir Singh
2025-03-13 18:12                       ` Bert Karwatzki
2025-03-13 21:54                         ` Balbir Singh
2025-03-13 22:22                           ` Bert Karwatzki
2025-03-14  6:14                             ` Balbir Singh
2025-03-14 13:34                               ` Balbir Singh
2025-03-14 14:18                                 ` Bert Karwatzki
2025-03-15  0:16                                   ` Balbir Singh
2025-03-15 17:40                                     ` Alex Deucher
2025-03-16 13:09                                       ` Bert Karwatzki
2025-03-16 20:06                                         ` Bert Karwatzki
2025-03-17  9:13                                         ` Balbir Singh
2025-03-20  9:01                                           ` Ingo Molnar
2025-03-20 23:55                                             ` Balbir Singh
2025-03-21 10:24                                               ` Ingo Molnar
2025-03-21 11:05                                                 ` Balbir Singh
2025-03-22  8:04                                                   ` Ingo Molnar
2025-03-22  9:40                                                     ` Balbir Singh
2025-03-20 23:43                                           ` Bert Karwatzki
2025-03-21  4:55                                             ` Balbir Singh [this message]
2025-03-21 12:26                                               ` Bert Karwatzki
2025-03-22  2:06                                                 ` Balbir Singh
2025-03-22 12:23 Bert Karwatzki
2025-03-23  6:51 ` Balbir Singh
2025-03-24 11:23   ` Bert Karwatzki
2025-03-24 12:14     ` Christian König
2025-03-24 22:48       ` Balbir Singh
     [not found]         ` <938c2cbd-c47f-4925-ba82-94eef54d9ebc@amd.com>
2025-03-25 22:45           ` Balbir Singh
2025-03-25 23:21             ` Bert Karwatzki
2025-03-25 23:43               ` Balbir Singh
2025-03-26  1:50                 ` Balbir Singh
2025-03-26 10:10                   ` Bert Karwatzki
2025-03-26 10:36                     ` Balbir Singh
2025-03-26 11:14                       ` Bert Karwatzki
2025-03-27 10:53                       ` Ingo Molnar
2025-03-27 22:03                         ` Balbir Singh
2025-03-24 21:43     ` Balbir Singh
2025-03-24 23:07 Bert Karwatzki
     [not found] ` <634e77d7-4f3c-4d1a-8aa3-1978896f9bf2@amd.com>
2025-03-25 10:25   ` Balbir Singh
2025-03-25 10:14 Bert Karwatzki
2025-03-25 12:23 ` Christian König
2025-03-26 22:00   ` Bert Karwatzki
2025-03-26 22:58     ` Linus Torvalds
2025-03-27  0:57       ` Balbir Singh
2025-03-27  0:58       ` Bert Karwatzki
2025-03-27 10:40       ` Ingo Molnar

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=d3580fa0-df0c-49ce-aa4e-e8c945172939@nvidia.com \
    --to=balbirs@nvidia.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=bhelgaas@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=spasswolf@web.de \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®