Skip to contentSkip to conversation

drm/nouneau: 5.11 cycle regression bisected to 461619f5c324 "drm/nouveau: switch to new allocator"

DISCUSSION Mike Galbraith 2 participants 14 messages Feb 10, 2021

Subsystems (3)
lore
Share & tools
lore

Mike Galbraith

author Reviewed-by Dave Airlie Reviewed-by Madhav Chauhan Tested-by Huang Rui
#0 lore raw

Greetings,

The symptom is tasks stuck waiting for lord knows what by calling sched_yield() in a loop (less than wonderful, sched_yield() sucks). After boot to KDE login, I immediately see tracker-extract chewing cpu in aforementioned loop. Firing up evolution and poking 'new' to compose, WebKitWebProcess joins in the yield loop fun.

Hand rolled reverts of 256dd44b "drm/ttm: nuke old page allocator" and the fingered commit cures the problem for me at 207665fd in the bisect log below, and at master and tip HEAD.

There's a "things that make ya go hmm" aspect to this thing though. If you look at the bisect log below, the starting "bad" is 207665fd. That commit DOES NOT exhibit the yield loop symptom immediately out of the box, but DOES after applying the much needed fix...

660a59953f4f "drm/nouveau: fix multihop when move doesn't work"

...to prevent an earlier regression from quickly appearing, one which Dave will likely recall having fixed. Relevant? No idea, but seems worth mentioning.

Box: aging generic i4790 box with its equally aged Nvidia GTX 980.

461619f5c3242aaee9ec3f0b7072719bd86ea207 is the first bad commit commit 461619f5c3242aaee9ec3f0b7072719bd86ea207

Author: Christian König <[email protected]>
Date:   Sat Oct 24 13:13:25 2020 +0200

drm/nouveau: switch to new allocator

It should be able to handle all cases now.

 drivers/gpu/drm/nouveau/nouveau_bo.c  | 30 ++----------------------------
 drivers/gpu/drm/nouveau/nouveau_drv.h |  1 -
 2 files changed, 2 insertions(+), 29 deletions(-)

git bisect start
# good: [2c85ebc57b3e1817b6ce1a6b703928e113a90442] Linux 5.10
git bisect good 3f995f8e0b540342612d3f6b1fc299f5bf486987
# bad: [207665fd37561f97591e74d0ee80f24bdf06b789] Merge tag 'exynos-drm-next-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next git bisect bad 207665fd37561f97591e74d0ee80f24bdf06b789
# good: [f8394f232b1eab649ce2df5c5f15b0e528c92091] Linux 5.10-rc3
git bisect good f8394f232b1eab649ce2df5c5f15b0e528c92091
# good: [b3bf99daaee96a141536ce5c60a0d6dba6ec1d23] drm/i915/display: Defer initial modeset until after GGTT is initialised
git bisect good b3bf99daaee96a141536ce5c60a0d6dba6ec1d23
# good: [dfbbfe3c17651fa0fcf2658fb90317df08e52bb2] drm/amd/display: Add formats for DCC with 2/3 planes.
git bisect good dfbbfe3c17651fa0fcf2658fb90317df08e52bb2
# bad: [112e505a76de69f8667e2fe8da38433f754364a8] Merge drm/drm-next into drm-misc-next
git bisect bad 112e505a76de69f8667e2fe8da38433f754364a8
# bad: [49a3f51dfeeecb52c5aa28c5cb9592fe5e39bf95] drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends
git bisect bad 49a3f51dfeeecb52c5aa28c5cb9592fe5e39bf95
# bad: [d7e0798925ea9272f8c8e66ceb1f7c51823e50ab] dt-bindings: display: bridge: Intel KeemBay DSI
git bisect bad d7e0798925ea9272f8c8e66ceb1f7c51823e50ab
# bad: [c489573b5b6ce6442ad4658d9d5ec77839b91622] Merge drm/drm-next into drm-misc-next
git bisect bad c489573b5b6ce6442ad4658d9d5ec77839b91622
# bad: [8567d51555c12d169c4e0f796030051fff1c318d] drm/vmwgfx: switch to new allocator
git bisect bad 8567d51555c12d169c4e0f796030051fff1c318d
# good: [5144eead3f8c80ac7f913c07139442fede94003e] drm: xlnx: Use dma_request_chan for DMA channel request
git bisect good 5144eead3f8c80ac7f913c07139442fede94003e
# good: [e93b2da9799e5cb97760969f3e1f02a5bdac29fe] drm/amdgpu: switch to new allocator v2
git bisect good e93b2da9799e5cb97760969f3e1f02a5bdac29fe
# bad: [461619f5c3242aaee9ec3f0b7072719bd86ea207] drm/nouveau: switch to new allocator
git bisect bad 461619f5c3242aaee9ec3f0b7072719bd86ea207
# good: [0fe3cf3a53b5c1205ec7d321be1185b075dff205] drm/radeon: switch to new allocator v2
git bisect good 0fe3cf3a53b5c1205ec7d321be1185b075dff205

# first bad commit: [461619f5c3242aaee9ec3f0b7072719bd86ea207] drm/nouveau: switch to new allocator

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#1 lore raw

Hi Mike,

do you have more information than just system stuck in a loop?

What seems to happen here is that your system is low on resources and we just try to free up pages.

Previously the allocation would just have failed with an out of memory condition.

Regards,
Christian.

Am 10.02.21 um 11:13 schrieb Mike Galbraith:

Quoted 74 lines

Greetings,

The symptom is tasks stuck waiting for lord knows what by calling sched_yield() in a loop (less than wonderful, sched_yield() sucks). After boot to KDE login, I immediately see tracker-extract chewing cpu in aforementioned loop. Firing up evolution and poking 'new' to compose, WebKitWebProcess joins in the yield loop fun.

Hand rolled reverts of 256dd44b "drm/ttm: nuke old page allocator" and the fingered commit cures the problem for me at 207665fd in the bisect log below, and at master and tip HEAD.

There's a "things that make ya go hmm" aspect to this thing though. If you look at the bisect log below, the starting "bad" is 207665fd. That commit DOES NOT exhibit the yield loop symptom immediately out of the box, but DOES after applying the much needed fix...

660a59953f4f "drm/nouveau: fix multihop when move doesn't work"

...to prevent an earlier regression from quickly appearing, one which Dave will likely recall having fixed. Relevant? No idea, but seems worth mentioning.

Box: aging generic i4790 box with its equally aged Nvidia GTX 980.

461619f5c3242aaee9ec3f0b7072719bd86ea207 is the first bad commit commit 461619f5c3242aaee9ec3f0b7072719bd86ea207

Author: Christian König <[email protected]>
Date:   Sat Oct 24 13:13:25 2020 +0200

drm/nouveau: switch to new allocator

It should be able to handle all cases now.

  drivers/gpu/drm/nouveau/nouveau_bo.c  | 30 ++----------------------------
  drivers/gpu/drm/nouveau/nouveau_drv.h |  1 -
  2 files changed, 2 insertions(+), 29 deletions(-)

git bisect start
# good: [2c85ebc57b3e1817b6ce1a6b703928e113a90442] Linux 5.10
git bisect good 3f995f8e0b540342612d3f6b1fc299f5bf486987
# bad: [207665fd37561f97591e74d0ee80f24bdf06b789] Merge tag 'exynos-drm-next-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next git bisect bad 207665fd37561f97591e74d0ee80f24bdf06b789
# good: [f8394f232b1eab649ce2df5c5f15b0e528c92091] Linux 5.10-rc3
git bisect good f8394f232b1eab649ce2df5c5f15b0e528c92091
# good: [b3bf99daaee96a141536ce5c60a0d6dba6ec1d23] drm/i915/display: Defer initial modeset until after GGTT is initialised
git bisect good b3bf99daaee96a141536ce5c60a0d6dba6ec1d23
# good: [dfbbfe3c17651fa0fcf2658fb90317df08e52bb2] drm/amd/display: Add formats for DCC with 2/3 planes.
git bisect good dfbbfe3c17651fa0fcf2658fb90317df08e52bb2
# bad: [112e505a76de69f8667e2fe8da38433f754364a8] Merge drm/drm-next into drm-misc-next
git bisect bad 112e505a76de69f8667e2fe8da38433f754364a8
# bad: [49a3f51dfeeecb52c5aa28c5cb9592fe5e39bf95] drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends
git bisect bad 49a3f51dfeeecb52c5aa28c5cb9592fe5e39bf95
# bad: [d7e0798925ea9272f8c8e66ceb1f7c51823e50ab] dt-bindings: display: bridge: Intel KeemBay DSI
git bisect bad d7e0798925ea9272f8c8e66ceb1f7c51823e50ab
# bad: [c489573b5b6ce6442ad4658d9d5ec77839b91622] Merge drm/drm-next into drm-misc-next
git bisect bad c489573b5b6ce6442ad4658d9d5ec77839b91622
# bad: [8567d51555c12d169c4e0f796030051fff1c318d] drm/vmwgfx: switch to new allocator
git bisect bad 8567d51555c12d169c4e0f796030051fff1c318d
# good: [5144eead3f8c80ac7f913c07139442fede94003e] drm: xlnx: Use dma_request_chan for DMA channel request
git bisect good 5144eead3f8c80ac7f913c07139442fede94003e
# good: [e93b2da9799e5cb97760969f3e1f02a5bdac29fe] drm/amdgpu: switch to new allocator v2
git bisect good e93b2da9799e5cb97760969f3e1f02a5bdac29fe
# bad: [461619f5c3242aaee9ec3f0b7072719bd86ea207] drm/nouveau: switch to new allocator
git bisect bad 461619f5c3242aaee9ec3f0b7072719bd86ea207
# good: [0fe3cf3a53b5c1205ec7d321be1185b075dff205] drm/radeon: switch to new allocator v2
git bisect good 0fe3cf3a53b5c1205ec7d321be1185b075dff205

Quoted 2 lines
# first bad commit: [461619f5c3242aaee9ec3f0b7072719bd86ea207] drm/nouveau: switch to new allocator

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#2 lore raw
Quoted 3 lines · Christian König

Hi Mike,

do you have more information than just system stuck in a loop?

No, strace shows no syscalls but sched_yield().

-Mike

#3 lore raw

Am 10.02.21 um 11:40 schrieb Mike Galbraith:

Quoted 5 lines · Christian König
Quoted 3 lines

Hi Mike,

do you have more information than just system stuck in a loop?

No, strace shows no syscalls but sched_yield().

Well you can try to comment out the call to register_shrinker() in ttm_pool.c, but apart from that I don't have much ideas.

Christian.

Quoted 3 lines

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#4 lore raw
Quoted 10 lines · Christian König

Am 10.02.21 um 11:40 schrieb Mike Galbraith:

Quoted 5 lines · Christian König
Quoted 3 lines

Hi Mike,

do you have more information than just system stuck in a loop?

No, strace shows no syscalls but sched_yield().

Well you can try to comment out the call to register_shrinker() in ttm_pool.c, but apart from that I don't have much ideas.

Nogo.. off to suggestion #2 I go.

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#6 lore raw

Am 10.02.21 um 11:46 schrieb Mike Galbraith:

Quoted 4 lines · Christian König
Quoted 2 lines

What seems to happen here is that your system is low on resources and we just try to free up pages.

FWIW, box has oodles generic ram free right after boot.

Then I have no idea what happens here.

The returned pages are identical, only the overhead to allocate them is reduced significantly.

The only other idea I have is that this somehow changes the timing and exposes a bug somewhere else.

You could try to replace the "for (order = min(MAX_ORDER - 1UL, __fls(num_pages)); num_pages;" in ttm_pool_alloc() with "for (order = 0; num_pages;" to get the old behavior.

Regards,
Christian.

Quoted 3 lines

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#8 lore raw

Please try to add a "return NULL" at the beginning of ttm_pool_type_take().

That should effectively disable using the pool.

Thanks for testing,
Christian.

Am 10.02.21 um 12:22 schrieb Mike Galbraith:

Quoted 9 lines · Christian König
Quoted 4 lines

You could try to replace the "for (order = min(MAX_ORDER - 1UL, __fls(num_pages)); num_pages;" in ttm_pool_alloc() with "for (order = 0; num_pages;" to get the old behavior.

That's a nogo too.

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#9 lore raw
Quoted 3 lines · Christian König

Please try to add a "return NULL" at the beginning of ttm_pool_type_take().

That should effectively disable using the pool.

That did away with the yield looping, but it doesn't take long for the display to freeze. I ssh'd in from lappy, but there was nada in dmesg.

Quoted 1 line

Thanks for testing,

Happy to.

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#10 lore raw

Am 10.02.21 um 13:22 schrieb Mike Galbraith:

Quoted 6 lines · Christian König
Quoted 3 lines

Please try to add a "return NULL" at the beginning of ttm_pool_type_take().

That should effectively disable using the pool.

That did away with the yield looping, but it doesn't take long for the display to freeze. I ssh'd in from lappy, but there was nada in dmesg.

Yeah, that is expected. Without taking pages from the pool we leak memory like sieve.

At least we could narrow down the problem quite a bit with that.

Can you test the attached patch and see if it helps?

Thanks,
Christian.

Quoted 6 lines
Quoted 2 lines

Thanks for testing,

Happy to.

-Mike

From 1e623dc5c535de2d0af3c5c6107c08ffffa4fe07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <[email protected]>
Date: Wed, 10 Feb 2021 14:24:27 +0100
Subject: [PATCH] drm/ttm: make sure pool pages are cleared
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The old implementation wasn't consistend on this.

---
 drivers/gpu/drm/ttm/ttm_pool.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/gpu/drm/ttm/ttm_pool.c +10 -0
index 74bf1c84b637..6e27cb1bf48b 100644
@@ -33,6 +33,7 @@
 
 #include <linux/module.h>
 #include <linux/dma-mapping.h>
+#include <linux/highmem.h>
 
 #ifdef CONFIG_X86
 #include <asm/set_memory.h>
@@ -218,6 +219,15 @@ static void ttm_pool_unmap(struct ttm_pool *pool, dma_addr_t dma_addr,
 /* Give pages into a specific pool_type */
 static void ttm_pool_type_give(struct ttm_pool_type *pt, struct page *p)
 {
+	unsigned int i, num_pages = 1 << pt->order;
+
+	for (i = 0; i < num_pages; ++i) {
+		if (PageHighMem(p))
+			clear_highpage(p + i);
+		else
+			clear_page(page_address(p + i));
+	}
+
 	spin_lock(&pt->lock);
 	list_add(&p->lru, &pt->pages);
 	spin_unlock(&pt->lock);
Signature · 1 line
2.25.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#11 lore raw
Quoted 9 lines · Christian König

Am 10.02.21 um 13:22 schrieb Mike Galbraith:

Quoted 6 lines · Christian König
Quoted 3 lines

Please try to add a "return NULL" at the beginning of ttm_pool_type_take().

That should effectively disable using the pool.

That did away with the yield looping, but it doesn't take long for the display to freeze. I ssh'd in from lappy, but there was nada in dmesg.

Quoted 6 lines

Yeah, that is expected. Without taking pages from the pool we leak memory like sieve.

At least we could narrow down the problem quite a bit with that.

Can you test the attached patch and see if it helps?

Yup, that seems to have fixed it all up. Another one bites the dust ;)

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#12 lore raw

Am 10.02.21 um 16:30 schrieb Mike Galbraith:

Quoted 8 lines · Christian König
Quoted 7 lines

Am 10.02.21 um 13:22 schrieb Mike Galbraith:

Quoted 6 lines · Christian König
Quoted 3 lines

Please try to add a "return NULL" at the beginning of ttm_pool_type_take().

That should effectively disable using the pool.

That did away with the yield looping, but it doesn't take long for the display to freeze. I ssh'd in from lappy, but there was nada in dmesg.

Quoted 7 lines
Quoted 6 lines

Yeah, that is expected. Without taking pages from the pool we leak memory like sieve.

At least we could narrow down the problem quite a bit with that.

Can you test the attached patch and see if it helps?

Yup, that seems to have fixed it all up. Another one bites the dust ;)

Ah! So basically nouveau relies on that the pages are cleared.

Yeah, that wasn't consitently implemented before. Some code path was clearing the page, some wasn't.

Any objections that I add a Reported-and-tested-by: Mike Galbraith <[email protected]> ?

Regards,
Christian.

Quoted 3 lines

-Mike

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau