Commit 1afaeb8
committed
mm/migrate: Trylock device page in do_swap_page
Avoid multiple CPU page faults to the same device page racing by trying
to lock the page in do_swap_page before taking an extra reference to the
page. This prevents scenarios where multiple CPU page faults each take
an extra reference to a device page, which could abort migration in
folio_migrate_mapping. With the device page being locked in
do_swap_page, the migrate_vma_* functions need to be updated to avoid
locking the fault_page argument.
Prior to this change, a livelock scenario could occur in Xe's (Intel GPU
DRM driver) SVM implementation if enough threads faulted the same device
page.
v3:
- Put page after unlocking page (Alistair)
- Warn on spliting a TPH which is fault page (Alistair)
- Warn on dst page == fault page (Alistair)
v6:
- Add more verbose comment around THP (Alistair)
v7:
- Fix migrate_device_finalize alignment (Checkpatch)
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Philip Yang <Philip.Yang@amd.com>
Cc: Felix Kuehling <felix.kuehling@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Simona Vetter <simona.vetter@ffwll.ch>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Tested-by: Alistair Popple <apopple@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250306012657.3505757-4-matthew.brost@intel.com1 parent a14fa8e commit 1afaeb8
2 files changed
+55
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4348 | 4348 | | |
4349 | 4349 | | |
4350 | 4350 | | |
4351 | | - | |
4352 | | - | |
4353 | | - | |
4354 | | - | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
4355 | 4360 | | |
4356 | 4361 | | |
4357 | 4362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
192 | 199 | | |
193 | 200 | | |
194 | 201 | | |
195 | | - | |
| 202 | + | |
196 | 203 | | |
197 | 204 | | |
198 | 205 | | |
| |||
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
207 | | - | |
| 214 | + | |
| 215 | + | |
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
| |||
363 | 371 | | |
364 | 372 | | |
365 | 373 | | |
| 374 | + | |
| 375 | + | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
| |||
427 | 437 | | |
428 | 438 | | |
429 | 439 | | |
430 | | - | |
| 440 | + | |
| 441 | + | |
431 | 442 | | |
432 | 443 | | |
433 | 444 | | |
| |||
536 | 547 | | |
537 | 548 | | |
538 | 549 | | |
| 550 | + | |
| 551 | + | |
539 | 552 | | |
540 | 553 | | |
541 | 554 | | |
| |||
799 | 812 | | |
800 | 813 | | |
801 | 814 | | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
814 | 819 | | |
| 820 | + | |
| 821 | + | |
815 | 822 | | |
816 | 823 | | |
817 | 824 | | |
| |||
824 | 831 | | |
825 | 832 | | |
826 | 833 | | |
| 834 | + | |
827 | 835 | | |
828 | 836 | | |
829 | 837 | | |
| |||
834 | 842 | | |
835 | 843 | | |
836 | 844 | | |
| 845 | + | |
837 | 846 | | |
838 | 847 | | |
839 | 848 | | |
| |||
843 | 852 | | |
844 | 853 | | |
845 | 854 | | |
846 | | - | |
| 855 | + | |
| 856 | + | |
847 | 857 | | |
848 | 858 | | |
849 | 859 | | |
| 860 | + | |
850 | 861 | | |
851 | 862 | | |
852 | 863 | | |
853 | 864 | | |
854 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
855 | 882 | | |
856 | 883 | | |
857 | 884 | | |
| |||
867 | 894 | | |
868 | 895 | | |
869 | 896 | | |
870 | | - | |
| 897 | + | |
| 898 | + | |
871 | 899 | | |
872 | 900 | | |
873 | 901 | | |
| |||
0 commit comments