Skip to contentSkip to conversation

drm/ttm: increase ttm pre-fault value to PMD size

PATCH In review Zhu Lingshan 6 participants 11 messages Jun 4, 2024 – Aug 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/ttm: increase ttm pre-fault value to PMD size

ttm page fault handler ttm_bo_vm_fault_reserved() maps TTM_BO_VM_NUM_PREFAULT more pages beforehand due to the principle of locality.

However, on some platform the page faults are more costly, this patch intends to increase the number of ttm pre-fault to relieve the number of page faults.

When multiple levels of page table is supported, the new default value would be the PMD size, similar to huge page.

---
 include/drm/ttm/ttm_bo.h | 4 ++++
 1 file changed, 4 insertions(+)
include/drm/ttm/ttm_bo.h +4 -0
index 6ccf96c91f3a..ef0f52f56ebc 100644
@@ -39,7 +39,11 @@
 #include "ttm_device.h"
 
 /* Default number of pre-faulted pages in the TTM fault handler */
+#if CONFIG_PGTABLE_LEVELS > 2
+#define TTM_BO_VM_NUM_PREFAULT (1 << (PMD_SHIFT - PAGE_SHIFT))
+#else
 #define TTM_BO_VM_NUM_PREFAULT 16
+#endif
 
 struct iosys_map;
 
Signature · 1 line
2.45.1
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Lingshan

ttm page fault handler ttm_bo_vm_fault_reserved() maps TTM_BO_VM_NUM_PREFAULT more pages beforehand due to the principle of locality.

However, on some platform the page faults are more costly, this patch intends to increase the number of ttm pre-fault to relieve the number of page faults.

Quoted 5 lines

When multiple levels of page table is supported, the new default value would be the PMD size, similar to huge page.

Quoted 23 lines
---
 include/drm/ttm/ttm_bo.h | 4 ++++
 1 file changed, 4 insertions(+)
include/drm/ttm/ttm_bo.h +4 -0
index 6ccf96c91f3a..ef0f52f56ebc 100644
@@ -39,7 +39,11 @@
 #include "ttm_device.h"
 
 /* Default number of pre-faulted pages in the TTM fault handler */
+#if CONFIG_PGTABLE_LEVELS > 2
+#define TTM_BO_VM_NUM_PREFAULT (1 << (PMD_SHIFT - PAGE_SHIFT))
+#else
 #define TTM_BO_VM_NUM_PREFAULT 16
+#endif
 
 struct iosys_map;
 
Signature · 1 line
2.45.1
Reviewed-by
#2 lore raw

Am 04.06.24 um 12:18 schrieb Huang Rui:

Quoted 9 lines · Lingshan
Quoted 8 lines

ttm page fault handler ttm_bo_vm_fault_reserved() maps TTM_BO_VM_NUM_PREFAULT more pages beforehand due to the principle of locality.

However, on some platform the page faults are more costly, this patch intends to increase the number of ttm pre-fault to relieve the number of page faults.

Quoted 6 lines
Quoted 5 lines

When multiple levels of page table is supported, the new default value would be the PMD size, similar to huge page.

Not sure if there really is an architecture with less than 3 page table levels, but the build robots should be able to tell us if everything is fine here.

Quoted 24 lines
Quoted 24 lines
---
  include/drm/ttm/ttm_bo.h | 4 ++++
  1 file changed, 4 insertions(+)
include/drm/ttm/ttm_bo.h +4 -0
index 6ccf96c91f3a..ef0f52f56ebc 100644
@@ -39,7 +39,11 @@
  #include "ttm_device.h"
 
  /* Default number of pre-faulted pages in the TTM fault handler */
+#if CONFIG_PGTABLE_LEVELS > 2
+#define TTM_BO_VM_NUM_PREFAULT (1 << (PMD_SHIFT - PAGE_SHIFT))
+#else
  #define TTM_BO_VM_NUM_PREFAULT 16
+#endif
 
  struct iosys_map;
 
Signature · 1 line
2.45.1
#3 lore raw
Quoted 16 lines · Christian König

Am 04.06.24 um 12:18 schrieb Huang Rui:

Quoted 14 lines · Lingshan
Quoted 13 lines

ttm page fault handler ttm_bo_vm_fault_reserved() maps TTM_BO_VM_NUM_PREFAULT more pages beforehand due to the principle of locality.

However, on some platform the page faults are more costly, this patch intends to increase the number of ttm pre-fault to relieve the number of page faults.

When multiple levels of page table is supported, the new default value would be the PMD size, similar to huge page.

Quoted 7 lines
Quoted 1 line

Not sure if there really is an architecture with less than 3 page table levels, but the build robots should be able to tell us if everything is fine here.

Has this been pushed to drm-misc? If not, can you push it?

Thanks,

Alex

Quoted 26 lines
Quoted 25 lines
Quoted 25 lines

---
  include/drm/ttm/ttm_bo.h | 4 ++++
  1 file changed, 4 insertions(+)
include/drm/ttm/ttm_bo.h +4 -1
index 6ccf96c91f3a..ef0f52f56ebc 100644
@@ -39,7 +39,11 @@
  #include "ttm_device.h"
 
  /* Default number of pre-faulted pages in the TTM fault handler */
+#if CONFIG_PGTABLE_LEVELS > 2
+#define TTM_BO_VM_NUM_PREFAULT (1 << (PMD_SHIFT - PAGE_SHIFT))
+#else
  #define TTM_BO_VM_NUM_PREFAULT 16
+#endif
 
  struct iosys_map;
 
--

2.45.1

#4 lore raw

Am 19.06.24 um 18:09 schrieb Alex Deucher:

Quoted 17 lines
Quoted 15 lines · Christian König

Am 04.06.24 um 12:18 schrieb Huang Rui:

Quoted 14 lines · Lingshan
Quoted 13 lines

ttm page fault handler ttm_bo_vm_fault_reserved() maps TTM_BO_VM_NUM_PREFAULT more pages beforehand due to the principle of locality.

However, on some platform the page faults are more costly, this patch intends to increase the number of ttm pre-fault to relieve the number of page faults.

When multiple levels of page table is supported, the new default value would be the PMD size, similar to huge page.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Not sure if there really is an architecture with less than 3 page table levels, but the build robots should be able to tell us if everything is fine here.

Has this been pushed to drm-misc? If not, can you push it?

Done.

Christian.

Quoted 28 lines

Thanks,

Alex

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
---
   include/drm/ttm/ttm_bo.h | 4 ++++
   1 file changed, 4 insertions(+)
include/drm/ttm/ttm_bo.h +4 -1
index 6ccf96c91f3a..ef0f52f56ebc 100644
@@ -39,7 +39,11 @@
   #include "ttm_device.h"
 
   /* Default number of pre-faulted pages in the TTM fault handler */
+#if CONFIG_PGTABLE_LEVELS > 2
+#define TTM_BO_VM_NUM_PREFAULT (1 << (PMD_SHIFT - PAGE_SHIFT))
+#else
   #define TTM_BO_VM_NUM_PREFAULT 16
+#endif
 
   struct iosys_map;
 
--

2.45.1

#5 lore raw

bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

In reply to Zhu Lingshan

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
https://www.youtube.com/watch?v=uOpl2XNOgMA
google-chrome-stable-126.0.6478.182-1.x86_64
VP9 video,
Chrome -> Override software rendering list -> on
Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko

#6 lore raw

Re: bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

Hi Yanko,

interesting. What do you mean with "choppy"? E.g. lag on startup?

Regards,
Christian.

Am 23.07.24 um 21:42 schrieb Yanko Kaneti:

Quoted 25 lines

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
https://www.youtube.com/watch?v=uOpl2XNOgMA
google-chrome-stable-126.0.6478.182-1.x86_64
VP9 video,
Chrome -> Override software rendering list -> on
Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko

#7 lore raw

Re: bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

Hi,

Well, it starts, then within a second or two it begins stuttering with long (half a second/second) freezes of the video , while the audio seems to work fine. Nothing in the log from chrome or kernel , AFAICS, to show anything is wrong.

Regards
Yanko

Quoted 34 lines · Christian König

Hi Yanko,

interesting. What do you mean with "choppy"? E.g. lag on startup?

Regards,
Christian.

Am 23.07.24 um 21:42 schrieb Yanko Kaneti:

Quoted 25 lines

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
https://www.youtube.com/watch?v=uOpl2XNOgMA
google-chrome-stable-126.0.6478.182-1.x86_64
VP9 video,
Chrome -> Override software rendering list -> on
Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko

#8 lore raw

Re: bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

Hi,

So, can't reproduce this any more with with recent rawhide (rc1+). Tried also with the same old kernels but this time its with newer mesa and google-chrome (126 -> 127). The same scenario as before now works ok.

Cheers and sorry for the noise.
- Yanko

Quoted 46 lines · Yanko Kaneti

Hi,

Well, it starts, then within a second or two it begins stuttering with long (half a second/second) freezes of the video , while the audio seems to work fine. Nothing in the log from chrome or kernel , AFAICS, to show anything is wrong.

Regards
Yanko

Quoted 34 lines · Christian König

Hi Yanko,

interesting. What do you mean with "choppy"? E.g. lag on startup?

Regards,
Christian.

Am 23.07.24 um 21:42 schrieb Yanko Kaneti:

Quoted 25 lines

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
https://www.youtube.com/watch?v=uOpl2XNOgMA
google-chrome-stable-126.0.6478.182-1.x86_64
VP9 video,
Chrome -> Override software rendering list -> on
Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko

#9 lore raw

Re: bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

I'm still scratching my head what the heck this could be.

Increasing the TTM prefault number has minimal more CPU overhead on the first access but makes subsequent accesses to the same buffer faster (because the buffer is already completely present).

So as long as Chrome didn't wrote some single bytes repeatably on newly allocated buffers I don't see how the change could affect video playback at all.

Maybe Chrome did exactly that because of a bug or something, but in general such an application behavior wouldn't make much sense (except if you want to burn CPU cycles).

Anyway not going to look further into that issue.

Thanks,
Christian.

Am 02.08.24 um 11:40 schrieb Yanko Kaneti:

Quoted 55 lines

Hi,

So, can't reproduce this any more with with recent rawhide (rc1+). Tried also with the same old kernels but this time its with newer mesa and google-chrome (126 -> 127). The same scenario as before now works ok.

Cheers and sorry for the noise.
- Yanko

Quoted 44 lines · Yanko Kaneti

Hi,

Well, it starts, then within a second or two it begins stuttering with long (half a second/second) freezes of the video , while the audio seems to work fine. Nothing in the log from chrome or kernel , AFAICS, to show anything is wrong.

Regards
Yanko

Quoted 33 lines · Christian König

Hi Yanko,

interesting. What do you mean with "choppy"? E.g. lag on startup?

Regards,
Christian.

Am 23.07.24 um 21:42 schrieb Yanko Kaneti:

Quoted 25 lines

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
https://www.youtube.com/watch?v=uOpl2XNOgMA
google-chrome-stable-126.0.6478.182-1.x86_64
VP9 video,
Chrome -> Override software rendering list -> on
Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko

#10 lore raw

Re: bisected/regression: choopy youtube video on Ryzen IGP - 0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

Apologies for resurrecting an old thread, but I'm experiencing the same issue.

For me it manifests mostly as choppy scrolling in Mullvad Browser (Flatpak), also Firefox.

E.g. on https://github.com/dandavison/delta, when trackpad flick-scrolling down the page, it's quite smooth up until the sections headed "Line numbers" and "Merge conflicts", there the scrolling hangs for maybe half a sec, then continues onwards.

I've yet to debug further why these sections in particular trip up scrolling. But it happens on other websites too (not all, i.e. simple pages are fine).

I independently bisected it down to the same commit as Yanko; commit 0ddd2ae586d28e521d37393364d989ce118802e0: drm/ttm: increase ttm pre-fault value to PMD size.

Reverting this commit on top of mainline master (d74da846046a) fixes the problem and scrolling is then smooth again.

I'm also using a Ryzen IGP; Radeon 780M (1002:15bf) as part of 7840U. I'm running Arch Linux with all packages up to date, nothing else really abstract about my setup.

Please let me know if I can help to investigate further.

Quoted 70 lines · Christian König

I'm still scratching my head what the heck this could be.

Increasing the TTM prefault number has minimal more CPU overhead on the first access but makes subsequent accesses to the same buffer faster (because the buffer is already completely present).

So as long as Chrome didn't wrote some single bytes repeatably on newly allocated buffers I don't see how the change could affect video playback at all.

Maybe Chrome did exactly that because of a bug or something, but in general such an application behavior wouldn't make much sense (except if you want to burn CPU cycles).

Anyway not going to look further into that issue.

Thanks,
Christian.

Am 02.08.24 um 11:40 schrieb Yanko Kaneti:

Quoted 55 lines

Hi,

So, can't reproduce this any more with with recent rawhide (rc1+). Tried also with the same old kernels but this time its with newer mesa and google-chrome (126 -> 127). The same scenario as before now works ok.

Cheers and sorry for the noise.
- Yanko

Quoted 44 lines · Yanko Kaneti

Hi,

Well, it starts, then within a second or two it begins stuttering with long (half a second/second) freezes of the video , while the audio seems to work fine. Nothing in the log from chrome or kernel , AFAICS,  to show anything is wrong.

Regards
Yanko

Quoted 33 lines · Christian König

Hi Yanko,

interesting. What do you mean with "choppy"? E.g. lag on startup?

Regards,
Christian.

Am 23.07.24 um 21:42 schrieb Yanko Kaneti:

Quoted 25 lines

Hello,

Noticed and bisected a rawhide (with the new 6.11-rc0 snapshots) regression to this commit:

    0ddd2ae586d2 drm/ttm: increase ttm pre-fault value to PMD size

The regression manifests in choppy youtube video playback in google-chrome-stable.
   https://www.youtube.com/watch?v=uOpl2XNOgMA
   google-chrome-stable-126.0.6478.182-1.x86_64
   VP9 video,
   Chrome -> Override software rendering list -> on
   Chrome -> Hardware-accelerated video decode - default enabled

No other visible graphics issues.

Its a desktop system with Ryzen 7 5700GRyzen 7 5700G  IGP [AMD/ATI] Cezanne [Radeon Vega Series / Radeon Vega Mobile Series] [1002:1638]

Tested with linus tip and just reverting the commit fixes the issue.

Sorry for the brevity, not sure what other details might be relevant.

- Yanko